41 #include <libxml/xpath.h>
42 #include <libxml/relaxng.h>
43 #include <libxml/xmlreader.h>
47 static const char* parser_str =
"parser";
58 xmlDocPtr rngdoc = NULL;
59 xmlRelaxNGParserCtxtPtr rngpctx = NULL;
60 xmlRelaxNGValidCtxtPtr rngctx = NULL;
61 xmlRelaxNGPtr schema = NULL;
64 if (!cfgfile || !rngfile) {
67 ods_log_debug(
"[%s] check cfgfile %s with rngfile %s", parser_str,
70 doc = xmlParseFile(cfgfile);
72 ods_log_error(
"[%s] unable to parse file: failed to load cfgfile %s",
77 rngdoc = xmlParseFile(rngfile);
79 ods_log_error(
"[%s] unable to parse file: failed to load rngfile %s",
85 rngpctx = xmlRelaxNGNewDocParserCtxt(rngdoc);
86 if (rngpctx == NULL) {
88 "xmlRelaxNGNewDocParserCtxt() failed", parser_str);
96 schema = xmlRelaxNGParse(rngpctx);
98 ods_log_error(
"[%s] unable to parse file: xmlRelaxNGParse() failed",
100 xmlRelaxNGFreeParserCtxt(rngpctx);
106 rngctx = xmlRelaxNGNewValidCtxt(schema);
107 if (rngctx == NULL) {
108 ods_log_error(
"[%s] unable to parse file: xmlRelaxNGNewValidCtxt() "
109 "failed", parser_str);
110 xmlRelaxNGFree(schema);
111 xmlRelaxNGFreeParserCtxt(rngpctx);
117 status = xmlRelaxNGValidateDoc(rngctx,doc);
119 ods_log_error(
"[%s] unable to parse file: xmlRelaxNGValidateDoc() "
120 "failed", parser_str);
121 xmlRelaxNGFreeValidCtxt(rngctx);
122 xmlRelaxNGFree(schema);
123 xmlRelaxNGFreeParserCtxt(rngpctx);
128 xmlRelaxNGFreeValidCtxt(rngctx);
129 xmlRelaxNGFree(schema);
130 xmlRelaxNGFreeParserCtxt(rngpctx);
149 char* address = NULL;
151 xmlDocPtr doc = NULL;
152 xmlXPathContextPtr xpathCtx = NULL;
153 xmlXPathObjectPtr xpathObj = NULL;
154 xmlNode* curNode = NULL;
155 xmlChar* xexpr = NULL;
161 doc = xmlParseFile(cfgfile);
164 "xmlParseFile() failed", parser_str);
168 xpathCtx = xmlXPathNewContext(doc);
169 if(xpathCtx == NULL) {
172 "xmlXPathNewContext() failed", parser_str);
176 xexpr = (xmlChar*)
"//Configuration/Signer/Listener/Interface";
177 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
178 if(xpathObj == NULL) {
179 xmlXPathFreeContext(xpathCtx);
182 "xmlXPathEvalExpression failed", parser_str);
188 if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
189 for (i = 0; i < xpathObj->nodesetval->nodeNr; i++) {
193 curNode = xpathObj->nodesetval->nodeTab[i]->xmlChildrenNode;
195 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Address")) {
196 address = (
char *) xmlNodeGetContent(curNode);
197 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Port")) {
198 port = (
char *) xmlNodeGetContent(curNode);
200 curNode = curNode->next;
204 acl_parse_family(address), port);
213 "listener_push() failed", parser_str, address?address:
"",
217 parser_str, address?address:
"", port?port:
"");
220 free((
void*)address);
223 xmlXPathFreeObject(xpathObj);
224 xmlXPathFreeContext(xpathCtx);
239 xmlDocPtr doc = NULL;
240 xmlXPathContextPtr xpathCtx = NULL;
241 xmlXPathObjectPtr xpathObj = NULL;
242 xmlChar *xexpr = NULL;
243 const char*
string = NULL;
249 doc = xmlParseFile(cfgfile);
251 ods_log_error(
"[%s] unable to parse file %s: xmlParseFile() failed",
252 parser_str, cfgfile);
256 xpathCtx = xmlXPathNewContext(doc);
257 if (xpathCtx == NULL) {
258 ods_log_error(
"[%s] unable to parse file %s: xmlXPathNewContext() "
259 "failed", parser_str, cfgfile);
264 xexpr = (
unsigned char*) expr;
265 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
266 if (xpathObj == NULL || xpathObj->nodesetval == NULL ||
267 xpathObj->nodesetval->nodeNr <= 0) {
269 ods_log_error(
"[%s] unable to evaluate expression %s in cfgile %s",
270 parser_str, (
char*) xexpr, cfgfile);
272 xmlXPathFreeContext(xpathCtx);
274 xmlXPathFreeObject(xpathObj);
279 if (xpathObj->nodesetval != NULL &&
280 xpathObj->nodesetval->nodeNr > 0) {
281 string = (
const char*) xmlXPathCastToString(xpathObj);
282 xmlXPathFreeContext(xpathCtx);
283 xmlXPathFreeObject(xpathObj);
287 xmlXPathFreeContext(xpathCtx);
288 xmlXPathFreeObject(xpathObj);
297 const char* dup = NULL;
300 "//Configuration/Common/ZoneListFile",
314 const char* dup = NULL;
316 "//Configuration/Common/Logging/Syslog/Facility",
320 "//Configuration/Common/Logging/File/Filename",
334 const char* dup = NULL;
337 "//Configuration/Signer/PidFile",
353 const char* dup = NULL;
356 "//Configuration/Signer/NotifyCommand",
370 const char* dup = NULL;
373 "//Configuration/Signer/SocketFile",
389 const char* dup = NULL;
392 "//Configuration/Signer/WorkingDirectory",
409 const char* dup = NULL;
412 "//Configuration/Signer/Privileges/User",
426 const char* dup = NULL;
429 "//Configuration/Signer/Privileges/Group",
443 const char* dup = NULL;
446 "//Configuration/Signer/Privileges/Directory",
465 "//Configuration/Common/Logging/Syslog/Facility",
477 int verbosity = ODS_SE_VERBOSITY;
479 "//Configuration/Common/Logging/Verbosity",
482 if (strlen(str) > 0) {
483 verbosity = atoi(str);
494 int numwt = ODS_SE_WORKERTHREADS;
496 "//Configuration/Signer/WorkerThreads",
499 if (strlen(str) > 0) {
511 int numwt = ODS_SE_WORKERTHREADS;
513 "//Configuration/Signer/SignerThreads",
516 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)