41 #include <libxml/parser.h>
42 #include <libxml/xpath.h>
43 #include <libxml/xpathInternals.h>
44 #include <libxml/xmlreader.h>
47 static const char* parser_str =
"parser";
58 xmlXPathContextPtr xpathCtx = NULL;
59 xmlXPathObjectPtr xpathObj = NULL;
60 xmlNode* curNode = NULL;
61 xmlChar* xexpr = NULL;
66 char* algorithm = NULL;
67 int ksk, zsk, publish, i;
70 ods_log_error(
"[%s] could not parse <Keys>, no cfgfile given",
77 doc = xmlParseFile(cfgfile);
79 ods_log_error(
"[%s] could not parse <Keys>, xmlParseFile failed",
84 xpathCtx = xmlXPathNewContext(doc);
85 if(xpathCtx == NULL) {
87 ods_log_error(
"[%s] could not parse <Keys>, xmlXPathNewContext failed",
92 xexpr = (xmlChar*)
"//SignerConfiguration/Zone/Keys/Key";
93 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
94 if(xpathObj == NULL) {
95 xmlXPathFreeContext(xpathCtx);
97 ods_log_error(
"[%s] could not parse <Keys>, xmlXPathEvalExpression "
98 "failed", parser_str);
103 if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
104 for (i = 0; i < xpathObj->nodesetval->nodeNr; i++) {
112 curNode = xpathObj->nodesetval->nodeTab[i]->xmlChildrenNode;
114 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Locator")) {
115 locator = (
char *) xmlNodeGetContent(curNode);
116 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Algorithm")) {
117 algorithm = (
char *) xmlNodeGetContent(curNode);
118 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Flags")) {
119 flags = (
char *) xmlNodeGetContent(curNode);
120 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"KSK")) {
122 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"ZSK")) {
124 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Publish")) {
127 curNode = curNode->next;
129 if (locator && algorithm && flags) {
133 new_key->
algorithm == (uint8_t) atoi(algorithm) &&
134 new_key->
flags == (uint32_t) atoi(flags) &&
136 new_key->
ksk == ksk &&
137 new_key->
zsk == zsk) {
140 parser_str, locator);
143 (uint8_t) atoi(algorithm), (uint32_t) atoi(flags),
147 parser_str, locator);
151 ods_log_error(
"[%s] Key missing required elements, skipping",
154 free((
void*)locator);
155 free((
void*)algorithm);
160 xmlXPathFreeObject(xpathObj);
161 xmlXPathFreeContext(xpathCtx);
178 "//SignerConfiguration/Zone/Signatures/Resign",
194 "//SignerConfiguration/Zone/Signatures/Refresh",
210 "//SignerConfiguration/Zone/Signatures/Validity/Default",
226 "//SignerConfiguration/Zone/Signatures/Validity/Denial",
242 "//SignerConfiguration/Zone/Signatures/Jitter",
258 "//SignerConfiguration/Zone/Signatures/InceptionOffset",
274 "//SignerConfiguration/Zone/Keys/TTL",
290 "//SignerConfiguration/Zone/Denial/NSEC3/TTL",
306 "//SignerConfiguration/Zone/SOA/TTL",
322 "//SignerConfiguration/Zone/SOA/Minimum",
341 "//SignerConfiguration/Zone/Denial/NSEC3",
345 return LDNS_RR_TYPE_NSEC3;
349 "//SignerConfiguration/Zone/Denial/NSEC",
353 return LDNS_RR_TYPE_NSEC;
356 return LDNS_RR_TYPE_FIRST;
369 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Algorithm",
372 if (strlen(str) > 0) {
386 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Iterations",
389 if (strlen(str) > 0) {
403 "//SignerConfiguration/Zone/Denial/NSEC3/OptOut",
418 "//SignerConfiguration/Zone/Audit",
435 const char* dup = NULL;
438 "//SignerConfiguration/Zone/SOA/Serial",
452 const char* dup = NULL;
455 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Salt",
duration_type * parse_sc_sig_validity_default(const char *cfgfile)
duration_type * parse_sc_sig_validity_denial(const char *cfgfile)
uint32_t parse_sc_nsec3_algorithm(const char *cfgfile)
duration_type * parse_sc_soa_ttl(const char *cfgfile)
const char * parse_sc_soa_serial(allocator_type *allocator, const char *cfgfile)
void ods_log_error(const char *format,...)
duration_type * parse_sc_sig_inception_offset(const char *cfgfile)
ods_status keylist_push(keylist_type *kl, key_type *key)
key_type * key_create(allocator_type *allocator, const char *locator, uint8_t algorithm, uint32_t flags, int publish, int ksk, int zsk)
keylist_type * parse_sc_keys(allocator_type *allocator, const char *cfgfile)
const char * parse_sc_nsec3_salt(allocator_type *allocator, const char *cfgfile)
keylist_type * keylist_create(allocator_type *allocator)
duration_type * parse_sc_dnskey_ttl(const char *cfgfile)
duration_type * parse_sc_sig_jitter(const char *cfgfile)
duration_type * parse_sc_nsec3param_ttl(const char *cfgfile)
char * allocator_strdup(allocator_type *allocator, const char *string)
duration_type * parse_sc_sig_refresh_interval(const char *cfgfile)
int parse_sc_nsec3_optout(const char *cfgfile)
duration_type * parse_sc_soa_min(const char *cfgfile)
const char * parse_conf_string(const char *cfgfile, const char *expr, int required)
key_type * keylist_lookup(keylist_type *list, const char *locator)
ldns_rr_type parse_sc_nsec_type(const char *cfgfile)
int parse_sc_audit(const char *cfgfile)
#define ods_log_assert(x)
duration_type * duration_create_from_string(const char *str)
duration_type * parse_sc_sig_resign_interval(const char *cfgfile)
void ods_log_warning(const char *format,...)
uint32_t parse_sc_nsec3_iterations(const char *cfgfile)