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) {
251 while (status == 0) {
252 if (strncmp(data.
category,
"enforcer", 8) == 0) {
257 if (strncmp(data.
category,
"zone", 4) == 0) {
267 if (strncmp(data.
category,
"parent", 6) == 0) {
273 if (strncmp(data.
category,
"signature", 9) == 0) {
281 if (strncmp(data.
category,
"denial", 6) == 0) {
290 if (strncmp(data.
category,
"zsk", 3) == 0) {
293 if (strncmp(data.
name,
"repository",10) == 0) policy->
zsk->
sm=data.
value;
299 if (strncmp(data.
category,
"ksk", 3) == 0) {
302 if (strncmp(data.
name,
"repository",10) == 0) policy->
ksk->
sm=data.
value;
310 if (strncmp(data.
category,
"keys", 4) == 0) {
386 else if (status == -1) {}
432 if (policy == NULL) {
458 else if (status == -1) {}
505 char* hex_chars =
"0123456789abcdef";
508 if (policy == NULL) {
515 if (datetime_now == NULL) {
516 printf(
"Couldn't turn \"now\" into a date, quitting...\n");
553 else if (status == -1) {
593 #ifdef HAVE_ARC4RANDOM
595 salt[i] = hex_chars[arc4random()%strlen(hex_chars)];
600 salt[i] = hex_chars[rand()%strlen(hex_chars)];
616 nchar = snprintf(buffer,
sizeof(buffer),
617 "UPDATE policies SET salt = '%s', salt_stamp = '%s' WHERE ID = %lu",
620 nchar = snprintf(buffer,
sizeof(buffer),
621 "UPDATE policies SET salt = '%s', salt_stamp = DATETIME('%s') WHERE ID = %lu",
624 if (nchar <
sizeof(buffer)) {
681 nchar = snprintf(buffer,
sizeof(buffer),
682 "UPDATE policies SET salt_stamp = NULL WHERE ID = %lu",
683 (
unsigned long) policy_id);
685 if (nchar <
sizeof(buffer)) {
713 if (policy == NULL) {
740 else if (status == -1) {}
777 else if (status == -1) {}
809 if (policy == NULL || policy->
name[0] ==
'\0') {
822 else if (status == -1) {
885 DbInt(row, 1, policy_id);
887 else if (status == -1) {}
922 if (policy_id <= 0) {
950 if (policy == NULL) {
970 policy->
keys == NULL ||
971 policy->
ksk == NULL ||
972 policy->
zsk == NULL ||
974 policy->
zone == 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
void DusConditionInt(char **query, const char *field, DQS_COMPARISON compare, int value, int clause)
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)
int DbQuoteString(DB_HANDLE handle, const char *in, char *buffer, size_t buflen)
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
int KsmPolicyUpdateDesc(int policy_id, const char *policy_description)
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)
char * DusInit(const char *table)
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)
void DusSetString(char **sql, const char *field, const char *data, int clause)
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