77 sql =
DqsSpecifyInit(
"policies",
"id, name, description, audit, salt");
118 sql =
DqsSpecifyInit(
"policies p, parameters_policies x, parameters y, categories c ",
"y.name, c.name, x.value");
208 else if (status == -1) {}
239 if (policy == NULL) {
255 while (status == 0) {
256 if (strncmp(data.
category,
"enforcer", 8) == 0) {
261 if (strncmp(data.
category,
"zone", 4) == 0) {
271 if (strncmp(data.
category,
"parent", 6) == 0) {
277 if (strncmp(data.
category,
"signature", 9) == 0) {
285 if (strncmp(data.
category,
"denial", 6) == 0) {
294 if (strncmp(data.
category,
"zsk", 3) == 0) {
297 if (strncmp(data.
name,
"repository",10) == 0) policy->
zsk->
sm=data.
value;
303 if (strncmp(data.
category,
"ksk", 3) == 0) {
306 if (strncmp(data.
name,
"repository",10) == 0) policy->
ksk->
sm=data.
value;
314 if (strncmp(data.
category,
"keys", 4) == 0) {
393 else if (status == -1) {}
439 if (policy == NULL) {
465 else if (status == -1) {}
512 char* hex_chars =
"0123456789abcdef";
515 if (policy == NULL) {
522 if (datetime_now == NULL) {
523 printf(
"Couldn't turn \"now\" into a date, quitting...\n");
560 else if (status == -1) {
600 #ifdef HAVE_ARC4RANDOM
602 salt[i] = hex_chars[arc4random()%strlen(hex_chars)];
607 salt[i] = hex_chars[rand()%strlen(hex_chars)];
623 nchar = snprintf(buffer,
sizeof(buffer),
624 "UPDATE policies SET salt = '%s', salt_stamp = \"%s\" WHERE ID = %lu",
627 nchar = snprintf(buffer,
sizeof(buffer),
628 "UPDATE policies SET salt = '%s', salt_stamp = DATETIME('%s') WHERE ID = %lu",
631 if (nchar <
sizeof(buffer)) {
688 nchar = snprintf(buffer,
sizeof(buffer),
689 "UPDATE policies SET salt_stamp = NULL WHERE ID = %lu",
690 (
unsigned long) policy_id);
692 if (nchar <
sizeof(buffer)) {
720 if (policy == NULL) {
747 else if (status == -1) {}
784 else if (status == -1) {}
816 if (policy == NULL || policy->
name[0] ==
'\0') {
830 else if (status == -1) {
893 DbInt(row, 1, policy_id);
895 else if (status == -1) {}
929 policy->
keys == NULL ||
930 policy->
ksk == NULL ||
931 policy->
zsk == NULL ||
933 policy->
zone == NULL ||
935 policy->
audit == NULL) {
void DbFreeResult(DB_RESULT result)
int KsmPolicyInit(DB_RESULT *handle, const char *name)
char name[KSM_NAME_LENGTH]
unsigned long sm_capacity
int DbFetchRow(DB_RESULT result, DB_ROW *row)
int KsmPolicy(DB_RESULT handle, KSM_POLICY *data)
#define DB_SECURITY_MODULE_NAME
char category[KSM_NAME_LENGTH]
char * DqsSpecifyInit(const char *table, const char *fields)
#define DB_SECURITY_MODULE_FIELDS
#define DB_SECURITY_MODULE_TABLE
KSM_POLICY * KsmPolicyAlloc()
KSM_COMMON_KEY_POLICY * keys
int KsmPolicySetIdFromName(KSM_POLICY *policy)
void DqsConditionKeyword(char **query, const char *field, DQS_COMPARISON compare, const char *value, int index)
void DqsOrderBy(char **query, const char *field)
char sm_name[KSM_NAME_LENGTH]
int MsgLog(int status,...)
int KsmPolicyUpdateSalt(KSM_POLICY *policy)
int KsmPolicyRead(KSM_POLICY *policy)
#define DB_SECURITY_MODULE_REQUIREBACKUP
void DqsFree(char *query)
#define DB_POLICY_PARAMETER_CATEGORY
int KsmPolicyParameter(DB_RESULT handle, KSM_POLICY_PARAMETER *data)
char salt_stamp[KSM_TIME_LENGTH]
void DqsConditionInt(char **query, const char *field, DQS_COMPARISON compare, int value, int index)
int KsmPolicyReadFromId(KSM_POLICY *policy)
char salt[KSM_SALT_LENGTH]
int KsmPolicyIdFromZoneId(int zone_id, int *policy_id)
char * DtParseDateTimeString(const char *string)
int KsmPolicyParametersInit(DB_RESULT *handle, const char *name)
KSM_PARENT_POLICY * parent
KSM_DENIAL_POLICY * denial
void StrStrncpy(char *dest, const char *src, size_t destlen)
const char * DbErrmsg(DB_HANDLE handle)
void KsmPolicyFree(KSM_POLICY *policy)
void DbFreeRow(DB_ROW row)
KSM_SIGNER_POLICY * signer
#define KSM_POLICY_AUDIT_LENGTH
int KsmPolicyNullSaltStamp(int policy_id)
int DbExecuteSql(DB_HANDLE handle, const char *stmt_str, DB_RESULT *result)
#define KSM_POLICY_DESC_LENGTH
int DbStringBuffer(DB_ROW row, int field_index, char *buffer, size_t buflen)
#define DB_POLICY_PARAMETER_VALUE
int DbUnsignedLong(DB_ROW row, int field_index, unsigned long *value)
int KsmPolicyPopulateSMFromIds(KSM_POLICY *policy)
#define DB_SECURITY_MODULE_CAPACITY
void KsmParameterEnd(DB_RESULT result)
char name[KSM_NAME_LENGTH]
#define DB_POLICY_SALT_STAMP
#define DB_POLICY_DESCRIPTION
int KsmPolicyExists(const char *name)
KSM_ENFORCER_POLICY * enforcer
int DbInt(DB_ROW row, int field_index, int *value)
int KsmPolicyNameFromId(KSM_POLICY *policy)
int DtDateDiff(const char *date1, const char *date2, int *result)
int DbExecuteSqlNoResult(DB_HANDLE handle, const char *stmt_str)
void DqsConditionString(char **query, const char *field, DQS_COMPARISON compare, const char *value, int index)
#define DB_POLICY_PARAMETER_NAME
KSM_SIGNATURE_POLICY * signature