65#define PQS_POLICY_DATABASE_MAGIC "PQSPOLICYDB1"
70#define PQS_POLICY_DEFAULT_GUEST "guest"
75#define PQS_POLICY_DEFAULT_USER "user"
80#define PQS_POLICY_DEFAULT_ADMIN "admin"
98 char name[PQS_POLICY_NAME_MAX];
113 char path[QSC_SYSTEM_MAX_PATH];
PQS_EXPORT_API bool pqs_policy_store_assign_privilege(pqs_policy_store *store, pqs_user_privileges privilege, const char *policy)
Assign a named policy to a privilege level.
Definition pqspolicy.c:566
PQS_EXPORT_API bool pqs_policy_store_set_mode(pqs_policy_store *store, const char *name, pqs_policy_modes mode)
Set the enforcement mode of a command policy.
Definition pqspolicy.c:973
PQS_EXPORT_API bool pqs_policy_store_remove(pqs_policy_store *store, const char *name)
Remove a command policy record from a policy store.
Definition pqspolicy.c:828
PQS_EXPORT_API bool pqs_policy_store_remove_command(pqs_policy_store *store, const char *name, const char *command, bool allowed)
Remove a command verb from a policy allow-list or deny-list.
Definition pqspolicy.c:864
PQS_EXPORT_API bool pqs_policy_store_save(const pqs_policy_store *store)
Save a command policy store to persistent storage.
Definition pqspolicy.c:894
PQS_EXPORT_API bool pqs_policy_store_add_command(pqs_policy_store *store, const char *name, const char *command, bool allowed)
Add a command verb to a policy allow-list or deny-list.
Definition pqspolicy.c:538
PQS_EXPORT_API bool pqs_policy_store_set_forced(pqs_policy_store *store, const char *name, const char *command)
Set the forced command associated with a command policy.
Definition pqspolicy.c:953
PQS_EXPORT_API bool pqs_policy_store_initialize(pqs_policy_store *store, const char *path)
Initialize a command policy store from persistent storage.
Definition pqspolicy.c:758
PQS_EXPORT_API const pqs_policy_record * pqs_policy_store_find(const pqs_policy_store *store, const char *name)
Find a command policy record by name.
Definition pqspolicy.c:710
PQS_EXPORT_API uint32_t pqs_policy_privilege_to_mask(pqs_user_privileges privilege)
Convert a PQS user privilege level to a policy privilege mask.
Definition pqspolicy.c:1047
PQS_EXPORT_API const char * pqs_policy_mode_to_string(pqs_policy_modes mode)
Convert a policy mode enumeration value to a string.
Definition pqspolicy.c:992
PQS_EXPORT_API bool pqs_policy_store_add(pqs_policy_store *store, const char *name, pqs_policy_modes mode, uint32_t privilege_mask, bool enabled)
Add a command policy record to a policy store.
Definition pqspolicy.c:515
PQS_EXPORT_API bool pqs_policy_command_is_safe(const char *command)
Authorize a command for a privilege level using the active policy assignment.
Definition pqspolicy.c:601
pqs_policy_modes
Command policy execution modes.
Definition pqspolicy.h:86
@ pqs_policy_mode_none
Definition pqspolicy.h:87
@ pqs_policy_mode_raw
Definition pqspolicy.h:90
@ pqs_policy_mode_restricted
Definition pqspolicy.h:88
@ pqs_policy_mode_forced
Definition pqspolicy.h:89
PQS_EXPORT_API bool pqs_policy_store_authorize(const pqs_policy_store *store, pqs_user_privileges privilege, const char *command, const pqs_policy_record **matched)
Authorizes a command request against the policy assigned to a privilege class.
Definition pqspolicy.c:641
PQS_EXPORT_API pqs_policy_modes pqs_policy_mode_from_string(const char *value)
Convert a policy mode string to a policy mode enumeration value.
Definition pqspolicy.c:1018
PQS_EXPORT_API bool pqs_policy_store_enable(pqs_policy_store *store, const char *name, bool enabled)
Enable or disable a command policy record.
Definition pqspolicy.c:691
PQS_EXPORT_API pqs_policy_record * pqs_policy_store_find_mutable(pqs_policy_store *store, const char *name)
Find a mutable command policy record by name.
Definition pqspolicy.c:734
A PQS server command policy record.
Definition pqspolicy.h:97
pqs_policy_modes mode
Definition pqspolicy.h:103
char forced[PQS_POLICY_COMMAND_MAX]
Definition pqspolicy.h:101
char denylist[PQS_POLICY_COMMAND_LIST_MAX]
Definition pqspolicy.h:100
uint32_t privilege_mask
Definition pqspolicy.h:102
bool enabled
Definition pqspolicy.h:104
char allowlist[PQS_POLICY_COMMAND_LIST_MAX]
Definition pqspolicy.h:99
char name[PQS_POLICY_NAME_MAX]
Definition pqspolicy.h:98
The fixed-size PQS command policy database.
Definition pqspolicy.h:111
char user_policy[PQS_POLICY_NAME_MAX]
Definition pqspolicy.h:115
char guest_policy[PQS_POLICY_NAME_MAX]
Definition pqspolicy.h:114
size_t count
Definition pqspolicy.h:117
char path[QSC_SYSTEM_MAX_PATH]
Definition pqspolicy.h:113
char admin_policy[PQS_POLICY_NAME_MAX]
Definition pqspolicy.h:116
pqs_policy_record records[PQS_POLICY_DATABASE_MAX]
Definition pqspolicy.h:112
bool initialized
Definition pqspolicy.h:118