PQS: Post Quantum Shell Protocol 1.1.0.0a (A2)
A quantum secure secure shell protocol
pqsshell.h File Reference

PQS server-side shell profile database functions. More...

#include "pqs.h"

Go to the source code of this file.

Data Structures

struct  pqs_shell_profile
 A PQS server shell profile record. More...
struct  pqs_shell_store
 The fixed-size PQS server shell profile database. More...

Macros

#define PQS_SHELL_DATABASE_MAGIC   "PQSSHELLDB1"
 The fixed text header written to PQS shell profile database files.
#define PQS_SHELL_PRIVILEGE_GUEST   0x01U
 Shell profile privilege mask bit for guest users.
#define PQS_SHELL_PRIVILEGE_USER   0x02U
 Shell profile privilege mask bit for standard users.
#define PQS_SHELL_PRIVILEGE_ADMIN   0x04U
 Shell profile privilege mask bit for administrative users.
#define PQS_SHELL_PRIVILEGE_ALL   (PQS_SHELL_PRIVILEGE_GUEST | PQS_SHELL_PRIVILEGE_USER | PQS_SHELL_PRIVILEGE_ADMIN)
 Shell profile privilege mask for all defined privilege levels.

Typedefs

typedef PQS_EXPORT_API struct pqs_shell_profile pqs_shell_profile
typedef PQS_EXPORT_API struct pqs_shell_store pqs_shell_store

Functions

PQS_EXPORT_API bool pqs_shell_store_add (pqs_shell_store *store, const char *name, const char *type, const char *path, uint32_t privilege_mask, bool enabled)
 Add or replace a shell profile record in a PQS shell profile store.
PQS_EXPORT_API bool pqs_shell_store_enable (pqs_shell_store *store, const char *name, bool enabled)
 Enable or disable an existing shell profile record.
PQS_EXPORT_API const pqs_shell_profilepqs_shell_store_find (const pqs_shell_store *store, const char *name)
 Find a shell profile record by name.
PQS_EXPORT_API pqs_shell_profilepqs_shell_store_find_mutable (pqs_shell_store *store, const char *name)
 Find a mutable shell profile record by name.
PQS_EXPORT_API const pqs_shell_profilepqs_shell_store_default (const pqs_shell_store *store)
 Find the default shell profile in a PQS shell profile store.
PQS_EXPORT_API bool pqs_shell_store_initialize (pqs_shell_store *store, const char *path)
 Initialize a PQS shell profile store and load or create its persistent database file.
PQS_EXPORT_API bool pqs_shell_store_remove (pqs_shell_store *store, const char *name)
 Remove a shell profile record from a PQS shell profile store.
PQS_EXPORT_API bool pqs_shell_store_save (const pqs_shell_store *store)
 Save a PQS shell profile store to its persistent database file.
PQS_EXPORT_API bool pqs_shell_store_set_default (pqs_shell_store *store, const char *name)
 Set the default shell profile for a PQS shell profile store.
PQS_EXPORT_API bool pqs_shell_store_set_privilege (pqs_shell_store *store, const char *name, pqs_user_privileges privilege, bool allowed)
 Enable or disable shell profile access for a specific PQS user privilege level.
PQS_EXPORT_API uint32_t pqs_shell_privilege_to_mask (pqs_user_privileges privilege)
 Convert a PQS user privilege value to the corresponding shell profile privilege-mask bit.
PQS_EXPORT_API bool pqs_shell_profile_allows_privilege (const pqs_shell_profile *profile, pqs_user_privileges privilege)
 Test whether a shell profile permits access for a specified PQS user privilege level.

Detailed Description

PQS server-side shell profile database functions.

Function Documentation

◆ pqs_shell_privilege_to_mask()

PQS_EXPORT_API uint32_t pqs_shell_privilege_to_mask ( pqs_user_privileges privilege)

Convert a PQS user privilege value to the corresponding shell profile privilege-mask bit.

Parameters
privilege[enum] The PQS user privilege value.
Returns
Returns the privilege-mask bit for the supplied privilege, or zero if the privilege is not recognized.

◆ pqs_shell_profile_allows_privilege()

PQS_EXPORT_API bool pqs_shell_profile_allows_privilege ( const pqs_shell_profile * profile,
pqs_user_privileges privilege )

Test whether a shell profile permits access for a specified PQS user privilege level.

Parameters
profile[const struct] A pointer to the shell profile record.
privilege[enum] The PQS user privilege value to test.
Returns
Returns true if the profile is enabled and permits the supplied privilege level; otherwise, false.

◆ pqs_shell_store_add()

PQS_EXPORT_API bool pqs_shell_store_add ( pqs_shell_store * store,
const char * name,
const char * type,
const char * path,
uint32_t privilege_mask,
bool enabled )

Add or replace a shell profile record in a PQS shell profile store.

Parameters
store[struct] A pointer to the initialized shell profile store.
name[const] The shell profile name.
type[const] The shell type identifier, such as cmd, powershell, sh, bash, zsh, or custom.
path[const] The absolute or configured executable path for the shell profile.
privilege_maskThe privilege mask controlling which PQS user privilege levels may use this profile.
enabledThe profile enabled state.
Returns
Returns true if the shell profile was added or replaced; otherwise, false.

◆ pqs_shell_store_default()

PQS_EXPORT_API const pqs_shell_profile * pqs_shell_store_default ( const pqs_shell_store * store)

Find the default shell profile in a PQS shell profile store.

Parameters
store[const struct] A pointer to the initialized shell profile store.
Returns
Returns a const pointer to the default shell profile, or NULL if no default profile is configured.

◆ pqs_shell_store_enable()

PQS_EXPORT_API bool pqs_shell_store_enable ( pqs_shell_store * store,
const char * name,
bool enabled )

Enable or disable an existing shell profile record.

Parameters
store[struct] A pointer to the initialized shell profile store.
name[const] The shell profile name.
enabledThe requested enabled state.
Returns
Returns true if the profile was found and updated; otherwise, false.

◆ pqs_shell_store_find()

PQS_EXPORT_API const pqs_shell_profile * pqs_shell_store_find ( const pqs_shell_store * store,
const char * name )

Find a shell profile record by name.

Parameters
store[const struct] A pointer to the initialized shell profile store.
name[const] The shell profile name.
Returns
Returns a const pointer to the matching profile, or NULL if the profile was not found.

◆ pqs_shell_store_find_mutable()

PQS_EXPORT_API pqs_shell_profile * pqs_shell_store_find_mutable ( pqs_shell_store * store,
const char * name )

Find a mutable shell profile record by name.

Parameters
store[struct] A pointer to the initialized shell profile store.
name[const] The shell profile name.
Returns
Returns a mutable pointer to the matching profile, or NULL if the profile was not found.

◆ pqs_shell_store_initialize()

PQS_EXPORT_API bool pqs_shell_store_initialize ( pqs_shell_store * store,
const char * path )

Initialize a PQS shell profile store and load or create its persistent database file.

Parameters
store[struct] A pointer to the shell profile store to initialize.
path[const] The persistent shell profile database file path.
Returns
Returns true if the store was initialized successfully; otherwise, false.

◆ pqs_shell_store_remove()

PQS_EXPORT_API bool pqs_shell_store_remove ( pqs_shell_store * store,
const char * name )

Remove a shell profile record from a PQS shell profile store.

Parameters
store[struct] A pointer to the initialized shell profile store.
name[const] The shell profile name.
Returns
Returns true if the profile was found and removed; otherwise, false.

◆ pqs_shell_store_save()

PQS_EXPORT_API bool pqs_shell_store_save ( const pqs_shell_store * store)

Save a PQS shell profile store to its persistent database file.

Parameters
store[const struct] A pointer to the initialized shell profile store.
Returns
Returns true if the store was written successfully; otherwise, false.

◆ pqs_shell_store_set_default()

PQS_EXPORT_API bool pqs_shell_store_set_default ( pqs_shell_store * store,
const char * name )

Set the default shell profile for a PQS shell profile store.

Parameters
store[struct] A pointer to the initialized shell profile store.
name[const] The shell profile name to mark as the default profile.
Returns
Returns true if the named profile was found and marked as default; otherwise, false.

◆ pqs_shell_store_set_privilege()

PQS_EXPORT_API bool pqs_shell_store_set_privilege ( pqs_shell_store * store,
const char * name,
pqs_user_privileges privilege,
bool allowed )

Enable or disable shell profile access for a specific PQS user privilege level.

Parameters
store[struct] A pointer to the initialized shell profile store.
name[const] The shell profile name.
privilege[enum] The PQS user privilege level to allow or deny.
allowedThe requested access state for the privilege level.
Returns
Returns true if the profile was found and updated; otherwise, false.