39 #include <libxml/xpath.h>
40 #include <libxml/relaxng.h>
41 #include <libxml/xmlreader.h>
45 static const char* parser_str =
"parser";
56 xmlDocPtr rngdoc = NULL;
57 xmlRelaxNGParserCtxtPtr rngpctx = NULL;
58 xmlRelaxNGValidCtxtPtr rngctx = NULL;
59 xmlRelaxNGPtr schema = NULL;
62 if (!cfgfile || !rngfile) {
65 ods_log_debug(
"[%s] check cfgfile %s with rngfile %s", parser_str,
68 doc = xmlParseFile(cfgfile);
70 ods_log_error(
"[%s] unable to parse file: failed to load cfgfile %s",
75 rngdoc = xmlParseFile(rngfile);
77 ods_log_error(
"[%s] unable to parse file: failed to load rngfile %s",
83 rngpctx = xmlRelaxNGNewDocParserCtxt(rngdoc);
84 if (rngpctx == NULL) {
86 "xmlRelaxNGNewDocParserCtxt() failed", parser_str);
94 schema = xmlRelaxNGParse(rngpctx);
96 ods_log_error(
"[%s] unable to parse file: xmlRelaxNGParse() failed",
98 xmlRelaxNGFreeParserCtxt(rngpctx);
104 rngctx = xmlRelaxNGNewValidCtxt(schema);
105 if (rngctx == NULL) {
106 ods_log_error(
"[%s] unable to parse file: xmlRelaxNGNewValidCtxt() "
107 "failed", parser_str);
108 xmlRelaxNGFree(schema);
109 xmlRelaxNGFreeParserCtxt(rngpctx);
115 status = xmlRelaxNGValidateDoc(rngctx,doc);
117 ods_log_error(
"[%s] unable to parse file: xmlRelaxNGValidateDoc() "
118 "failed", parser_str);
119 xmlRelaxNGFreeValidCtxt(rngctx);
120 xmlRelaxNGFree(schema);
121 xmlRelaxNGFreeParserCtxt(rngpctx);
126 xmlRelaxNGFreeValidCtxt(rngctx);
127 xmlRelaxNGFree(schema);
128 xmlRelaxNGFreeParserCtxt(rngpctx);
147 char* address = NULL;
149 xmlDocPtr doc = NULL;
150 xmlXPathContextPtr xpathCtx = NULL;
151 xmlXPathObjectPtr xpathObj = NULL;
152 xmlNode* curNode = NULL;
153 xmlChar* xexpr = NULL;
159 doc = xmlParseFile(cfgfile);
162 "xmlParseFile() failed", parser_str);
166 xpathCtx = xmlXPathNewContext(doc);
167 if(xpathCtx == NULL) {
170 "xmlXPathNewContext() failed", parser_str);
174 xexpr = (xmlChar*)
"//Configuration/Signer/Listener/Interface";
175 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
176 if(xpathObj == NULL) {
177 xmlXPathFreeContext(xpathCtx);
180 "xmlXPathEvalExpression failed", parser_str);
186 if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
187 for (i = 0; i < xpathObj->nodesetval->nodeNr; i++) {
191 curNode = xpathObj->nodesetval->nodeTab[i]->xmlChildrenNode;
193 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Address")) {
194 address = (
char *) xmlNodeGetContent(curNode);
195 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Port")) {
196 port = (
char *) xmlNodeGetContent(curNode);
198 curNode = curNode->next;
202 acl_parse_family(address), port);
211 "listener_push() failed", parser_str, address?address:
"",
215 parser_str, address?address:
"", port?port:
"");
218 free((
void*)address);
221 xmlXPathFreeObject(xpathObj);
222 xmlXPathFreeContext(xpathCtx);
237 xmlDocPtr doc = NULL;
238 xmlXPathContextPtr xpathCtx = NULL;
239 xmlXPathObjectPtr xpathObj = NULL;
240 xmlChar *xexpr = NULL;
241 const char*
string = NULL;
247 doc = xmlParseFile(cfgfile);
249 ods_log_error(
"[%s] unable to parse file %s: xmlParseFile() failed",
250 parser_str, cfgfile);
254 xpathCtx = xmlXPathNewContext(doc);
255 if (xpathCtx == NULL) {
256 ods_log_error(
"[%s] unable to parse file %s: xmlXPathNewContext() "
257 "failed", parser_str, cfgfile);
262 xexpr = (
unsigned char*) expr;
263 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
264 if (xpathObj == NULL || xpathObj->nodesetval == NULL ||
265 xpathObj->nodesetval->nodeNr <= 0) {
267 ods_log_error(
"[%s] unable to evaluate expression %s in cfgile %s",
268 parser_str, (
char*) xexpr, cfgfile);
270 xmlXPathFreeContext(xpathCtx);
272 xmlXPathFreeObject(xpathObj);
277 if (xpathObj->nodesetval != NULL &&
278 xpathObj->nodesetval->nodeNr > 0) {
279 string = (
const char*) xmlXPathCastToString(xpathObj);
280 xmlXPathFreeContext(xpathCtx);
281 xmlXPathFreeObject(xpathObj);
285 xmlXPathFreeContext(xpathCtx);
286 xmlXPathFreeObject(xpathObj);
295 const char* dup = NULL;
298 "//Configuration/Common/ZoneListFile",
312 const char* dup = NULL;
314 "//Configuration/Common/Logging/Syslog/Facility",
318 "//Configuration/Common/Logging/File/Filename",
332 const char* dup = NULL;
335 "//Configuration/Signer/PidFile",
351 const char* dup = NULL;
354 "//Configuration/Signer/NotifyCommand",
368 const char* dup = NULL;
371 "//Configuration/Signer/SocketFile",
387 const char* dup = NULL;
390 "//Configuration/Signer/WorkingDirectory",
407 const char* dup = NULL;
410 "//Configuration/Signer/Privileges/User",
424 const char* dup = NULL;
427 "//Configuration/Signer/Privileges/Group",
441 const char* dup = NULL;
444 "//Configuration/Signer/Privileges/Directory",
463 "//Configuration/Common/Logging/Syslog/Facility",
475 int verbosity = ODS_SE_VERBOSITY;
477 "//Configuration/Common/Logging/Verbosity",
480 if (strlen(str) > 0) {
481 verbosity = atoi(str);
492 int numwt = ODS_SE_WORKERTHREADS;
494 "//Configuration/Signer/WorkerThreads",
497 if (strlen(str) > 0) {
509 int numwt = ODS_SE_WORKERTHREADS;
511 "//Configuration/Signer/SignerThreads",
514 if (strlen(str) > 0) {
int parse_conf_worker_threads(const char *cfgfile)
void ods_log_debug(const char *format,...)
int parse_conf_use_syslog(const char *cfgfile)
const char * parse_conf_zonelist_filename(allocator_type *allocator, const char *cfgfile)
enum ods_enum_status ods_status
ods_status parse_file_check(const char *cfgfile, const char *rngfile)
const char * parse_conf_log_filename(allocator_type *allocator, const char *cfgfile)
void ods_log_error(const char *format,...)
listener_type * parse_conf_listener(allocator_type *allocator, const char *cfgfile)
listener_type * listener_create(allocator_type *allocator)
const char * parse_conf_group(allocator_type *allocator, const char *cfgfile)
int parse_conf_signer_threads(const char *cfgfile)
const char * parse_conf_chroot(allocator_type *allocator, const char *cfgfile)
const char * parse_conf_clisock_filename(allocator_type *allocator, const char *cfgfile)
char * allocator_strdup(allocator_type *allocator, const char *string)
const char * parse_conf_string(const char *cfgfile, const char *expr, int required)
const char * parse_conf_notify_command(allocator_type *allocator, const char *cfgfile)
const char * parse_conf_working_dir(allocator_type *allocator, const char *cfgfile)
int parse_conf_verbosity(const char *cfgfile)
const char * parse_conf_username(allocator_type *allocator, const char *cfgfile)
const char * parse_conf_pid_filename(allocator_type *allocator, const char *cfgfile)
#define ods_log_assert(x)
interface_type * listener_push(listener_type *listener, char *address, int family, char *port)