OpenDNSSEC-enforcer  2.1.7
kc_helper.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Nominet UK. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef KC_HELPER_H
27 #define KC_HELPER_H
28 
29 #ifdef LOG_DAEMON
30 #define DEFAULT_LOG_FACILITY LOG_DAEMON
31 #define DEFAULT_LOG_FACILITY_STRING "LOG_DAEMON"
32 #else
33 #define DEFAULT_LOG_FACILITY LOG_USER
34 #define DEFAULT_LOG_FACILITY_STRING "LOG_USER"
35 #endif /* LOG_DAEMON */
36 
37 #include "config.h"
38 #include <libxml/xpath.h>
39 
40 #define KC_NAME_LENGTH 256
41 
42 typedef struct {
43  char *name;
44  char *module;
45  char *TokenLabel;
46 } KC_REPO;
47 
48 extern int check_conf(const char *conf, char **kasp, char **zonelist,
49  char ***repo_listout, int *repo_countout, int verbose);
50 extern int check_kasp(const char *kasp, char **repo_list, int repo_count, int verbose,
51  char ***policy_names_out, int *policy_count_out);
52 extern int check_zonelist(const char *zonelist, int verbose, char **policy_names,
53  int policy_count);
54 
55 extern void log_init(int facility, const char *program_name);
56 extern void log_switch(int facility, const char *program_name);
57 extern void dual_log(const char *format, ...)
58 #ifdef HAVE___ATTRIBUTE__
59  __attribute__ ((format (printf, 1, 2)))
60 #endif
61  ;
62 
63 
64 extern int check_rng(const char *filename, const char *rngfilename, int verbose);
65 
66 extern int check_file(const char *filename, const char *log_string);
67 extern int check_file_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *file_xexpr);
68 
69 extern int check_path(const char *pathname, const char *log_string);
70 extern int check_path_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *path_xexpr);
71 
72 extern int check_user_group(xmlXPathContextPtr xpath_ctx, const xmlChar *user_xexpr, const xmlChar *group_xexpr);
73 
74 extern int check_time_def(const char *time_expr, const char *location, const char *field, const char *filename, int* interval);
75 extern int check_time_def_from_xpath(xmlXPathContextPtr xpath_ctx, const xmlChar *time_xexpr, const char *location, const char *field, const char *filename);
76 
77 /* if repo_list NULL, will skip the check to see all repositories in kasp are available in conf */
78 extern int check_policy(xmlNode *curNode, const char *policy_name, char **repo_list, int repo_count, const char *kasp);
79 
80 extern int DtXMLIntervalSeconds(const char* text, int* interval);
81 extern int StrStrtoi(const char* string, int* value);
82 extern int StrStrtol(const char* string, long* value);
83 extern char* StrStrdup(const char* string);
84 extern void StrTrimR(char *text);
85 extern char* StrTrimL(char* text);
86 extern void* MemCalloc(size_t nmemb, size_t size);
87 
88 #endif /* KC_HELPER_H */
KC_REPO
Definition: kc_helper.h:42
KC_REPO::module
char * module
Definition: kc_helper.h:44
policy_name
const char * policy_name(const policy_t *policy)
Definition: policy.c:813
check_policy
int check_policy(xmlNode *curNode, const char *policy_name, char **repo_list, int repo_count, const char *kasp)
Definition: kc_helper.c:408
MemCalloc
void * MemCalloc(size_t nmemb, size_t size)
Definition: kc_helper.c:1364
dual_log
void dual_log(const char *format,...)
Definition: kc_helper.c:59
check_rng
int check_rng(const char *filename, const char *rngfilename, int verbose)
Definition: kc_helper.c:88
check_file_from_xpath
int check_file_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *file_xexpr)
Definition: kc_helper.c:216
check_time_def_from_xpath
int check_time_def_from_xpath(xmlXPathContextPtr xpath_ctx, const xmlChar *time_xexpr, const char *location, const char *field, const char *filename)
Definition: kc_helper.c:385
DtXMLIntervalSeconds
int DtXMLIntervalSeconds(const char *text, int *interval)
Definition: kc_helper.c:1023
StrStrdup
char * StrStrdup(const char *string)
Definition: kc_helper.c:1257
check_kasp
int check_kasp(const char *kasp, char **repo_list, int repo_count, int verbose, char ***policy_names_out, int *policy_count_out)
Definition: kc_helper.c:1740
check_path
int check_path(const char *pathname, const char *log_string)
Definition: kc_helper.c:249
log_switch
void log_switch(int facility, const char *program_name)
check_conf
int check_conf(const char *conf, char **kasp, char **zonelist, char ***repo_listout, int *repo_countout, int verbose)
Definition: kc_helper.c:1386
StrStrtol
int StrStrtol(const char *string, long *value)
Definition: kc_helper.c:1203
check_time_def
int check_time_def(const char *time_expr, const char *location, const char *field, const char *filename, int *interval)
Definition: kc_helper.c:348
KC_REPO::TokenLabel
char * TokenLabel
Definition: kc_helper.h:45
log_init
void log_init(int facility, const char *program_name)
Definition: kc_helper.c:51
check_zonelist
int check_zonelist(const char *zonelist, int verbose, char **policy_names, int policy_count)
Definition: kc_helper.c:1664
StrTrimR
void StrTrimR(char *text)
Definition: kc_helper.c:1315
check_path_from_xpath
int check_path_from_xpath(xmlXPathContextPtr xpath_ctx, const char *log_string, const xmlChar *path_xexpr)
Definition: kc_helper.c:272
check_file
int check_file(const char *filename, const char *log_string)
Definition: kc_helper.c:192
StrStrtoi
int StrStrtoi(const char *string, int *value)
Definition: kc_helper.c:1159
KC_REPO::name
char * name
Definition: kc_helper.h:43
check_user_group
int check_user_group(xmlXPathContextPtr xpath_ctx, const xmlChar *user_xexpr, const xmlChar *group_xexpr)
Definition: kc_helper.c:298
StrTrimL
char * StrTrimL(char *text)
Definition: kc_helper.c:1353