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) {
390 else if (status == -1) {}
436 if (policy == NULL) {
462 else if (status == -1) {}
509 char* hex_chars =
"0123456789abcdef";
512 if (policy == NULL) {
519 if (datetime_now == NULL) {
520 printf(
"Couldn't turn \"now\" into a date, quitting...\n");
557 else if (status == -1) {
597 #ifdef HAVE_ARC4RANDOM
599 salt[i] = hex_chars[arc4random()%strlen(hex_chars)];
604 salt[i] = hex_chars[rand()%strlen(hex_chars)];
620 nchar = snprintf(buffer,
sizeof(buffer),
621 "UPDATE policies SET salt = '%s', salt_stamp = '%s' WHERE ID = %lu",
624 nchar = snprintf(buffer,
sizeof(buffer),
625 "UPDATE policies SET salt = '%s', salt_stamp = DATETIME('%s') WHERE ID = %lu",
628 if (nchar <
sizeof(buffer)) {
685 nchar = snprintf(buffer,
sizeof(buffer),
686 "UPDATE policies SET salt_stamp = NULL WHERE ID = %lu",
687 (
unsigned long) policy_id);
689 if (nchar <
sizeof(buffer)) {
717 if (policy == NULL) {
744 else if (status == -1) {}
781 else if (status == -1) {}
813 if (policy == NULL || policy->
name[0] ==
'\0') {
826 else if (status == -1) {
889 DbInt(row, 1, policy_id);
891 else if (status == -1) {}
926 if (policy_id <= 0) {
954 if (policy == NULL) {
974 policy->
keys == NULL ||
975 policy->
ksk == NULL ||
976 policy->
zsk == NULL ||
978 policy->
zone == NULL ||
void DbFreeResult(DB_RESULT result)
int KsmPolicy(DB_RESULT result, KSM_POLICY *data)
char name[KSM_NAME_LENGTH]
int KsmPolicyNameFromId(KSM_POLICY *policy)
int KsmPolicySetIdFromName(KSM_POLICY *policy)
unsigned long sm_capacity
KSM_POLICY * KsmPolicyAlloc()
int DbFetchRow(DB_RESULT result, DB_ROW *row)
#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
void KsmPolicyFree(KSM_POLICY *policy)
int KsmPolicyUpdateDesc(int policy_id, const char *policy_description)
KSM_COMMON_KEY_POLICY * keys
void DqsConditionKeyword(char **query, const char *field, DQS_COMPARISON compare, const char *value, int index)
int KsmPolicyReadFromId(KSM_POLICY *policy)
void DqsOrderBy(char **query, const char *field)
char sm_name[KSM_NAME_LENGTH]
int MsgLog(int status,...)
#define DB_SECURITY_MODULE_REQUIREBACKUP
void DqsFree(char *query)
int KsmPolicyUpdateSalt(KSM_POLICY *policy)
#define DB_POLICY_PARAMETER_CATEGORY
void DusConditionInt(char **query, const char *field, DQS_COMPARISON compare, int value, int clause)
int KsmPolicyRead(KSM_POLICY *policy)
char salt_stamp[KSM_TIME_LENGTH]
int KsmPolicyParametersInit(DB_RESULT *result, const char *name)
void DqsConditionInt(char **query, const char *field, DQS_COMPARISON compare, int value, int index)
char salt[KSM_SALT_LENGTH]
int DbQuoteString(DB_HANDLE handle, const char *in, char *buffer, size_t buflen)
char * DtParseDateTimeString(const char *string)
KSM_PARENT_POLICY * parent
KSM_DENIAL_POLICY * denial
void StrStrncpy(char *dest, const char *src, size_t destlen)
int KsmPolicyParameter(DB_RESULT result, KSM_POLICY_PARAMETER *data)
const char * DbErrmsg(DB_HANDLE handle)
void DbFreeRow(DB_ROW row)
KSM_SIGNER_POLICY * signer
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 KsmPolicyInit(DB_RESULT *result, const char *name)
int DbUnsignedLong(DB_ROW row, int field_index, unsigned long *value)
char * DusInit(const char *table)
#define DB_SECURITY_MODULE_CAPACITY
void KsmParameterEnd(DB_RESULT result)
char name[KSM_NAME_LENGTH]
#define DB_POLICY_SALT_STAMP
int KsmPolicyIdFromZoneId(int zone_id, int *policy_id)
#define DB_POLICY_DESCRIPTION
KSM_ENFORCER_POLICY * enforcer
int DbInt(DB_ROW row, int field_index, int *value)
int KsmPolicyNullSaltStamp(int policy_id)
int KsmPolicyExists(const char *name)
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)
int KsmPolicyPopulateSMFromIds(KSM_POLICY *policy)
void DqsConditionString(char **query, const char *field, DQS_COMPARISON compare, const char *value, int index)
#define DB_POLICY_PARAMETER_NAME
KSM_SIGNATURE_POLICY * signature