|
Electroneum
|
Go to the source code of this file.
Classes | |
| struct | config_strlist_head |
| struct | config_file |
| struct | config_stub |
| struct | config_auth |
| struct | config_view |
| struct | config_strlist |
| struct | config_str2list |
| struct | config_str3list |
| struct | config_strbytelist |
| struct | config_parser_state |
Functions | |
| struct config_file * | config_create (void) |
| struct config_file * | config_create_forlib (void) |
| int | config_read (struct config_file *config, const char *filename, const char *chroot) |
| void | config_delete (struct config_file *config) |
| void | config_apply (struct config_file *config) |
| void | config_lookup_uid (struct config_file *config) |
| int | config_set_option (struct config_file *config, const char *option, const char *value) |
| int | config_get_option (struct config_file *cfg, const char *opt, void(*func)(char *, void *), void *arg) |
| int | config_get_option_list (struct config_file *cfg, const char *opt, struct config_strlist **list) |
| int | config_get_option_collate (struct config_file *cfg, const char *opt, char **str) |
| void | config_print_func (char *line, void *arg) |
| void | config_collate_func (char *line, void *arg) |
| char * | config_collate_cat (struct config_strlist *list) |
| int | cfg_strlist_append (struct config_strlist_head *list, char *item) |
| struct config_strlist * | cfg_strlist_find (struct config_strlist *head, const char *item) |
| int | cfg_strlist_insert (struct config_strlist **head, char *item) |
| int | cfg_region_strlist_insert (struct regional *region, struct config_strlist **head, char *item) |
| int | cfg_str2list_insert (struct config_str2list **head, char *item, char *i2) |
| int | cfg_str3list_insert (struct config_str3list **head, char *item, char *i2, char *i3) |
| int | cfg_strbytelist_insert (struct config_strbytelist **head, char *item, uint8_t *i2, size_t i2len) |
| struct config_stub * | cfg_stub_find (struct config_stub ***pp, const char *nm) |
| void | config_delstrlist (struct config_strlist *list) |
| void | config_deldblstrlist (struct config_str2list *list) |
| void | config_deltrplstrlist (struct config_str3list *list) |
| void | config_del_strbytelist (struct config_strbytelist *list) |
| void | config_delstub (struct config_stub *p) |
| void | config_delstubs (struct config_stub *list) |
| void | config_delauth (struct config_auth *p) |
| void | config_delauths (struct config_auth *list) |
| void | config_delview (struct config_view *p) |
| void | config_delviews (struct config_view *list) |
| int | options_remote_is_address (struct config_file *cfg) |
| time_t | cfg_convert_timeval (const char *str) |
| int | cfg_count_numbers (const char *str) |
| int | cfg_parse_memsize (const char *str, size_t *res) |
| int | config_add_tag (struct config_file *cfg, const char *tag) |
| int | find_tag_id (struct config_file *cfg, const char *tag) |
| uint8_t * | config_parse_taglist (struct config_file *cfg, char *str, size_t *listlen) |
| char * | config_taglist2str (struct config_file *cfg, uint8_t *taglist, size_t len) |
| int | taglist_intersect (uint8_t *list1, size_t list1len, uint8_t *list2, size_t list2len) |
| int | cfg_parse_local_zone (struct config_file *cfg, const char *val) |
| int | cfg_mark_ports (const char *str, int allow, int *avail, int num) |
| int | cfg_condense_ports (struct config_file *cfg, int **avail) |
| int | cfg_scan_ports (int *avail, int num) |
| char * | fname_after_chroot (const char *fname, struct config_file *cfg, int use_chdir) |
| char * | cfg_ptr_reverse (char *str) |
| void | errinf (struct module_qstate *qstate, const char *str) |
| void | errinf_origin (struct module_qstate *qstate, struct sock_list *origin) |
| void | errinf_rrset (struct module_qstate *qstate, struct ub_packed_rrset_key *rr) |
| void | errinf_dname (struct module_qstate *qstate, const char *str, uint8_t *dname) |
| char * | errinf_to_str (struct module_qstate *qstate) |
| void | init_cfg_parse (void) |
| int | ub_c_parse (void) |
| int | ub_c_lex (void) |
| int | ub_c_wrap (void) |
| void | ub_c_error (const char *msg) |
| void | ub_c_error_msg (const char *fmt,...) ATTR_FORMAT(printf |
Variables | |
| uid_t | cfg_uid |
| gid_t | cfg_gid |
| int | autr_permit_small_holddown |
| struct config_parser_state * | cfg_parser |
| FILE * | ub_c_in |
| FILE * | ub_c_out |
| void int | fake_dsa |
| void int | fake_sha1 |
This file contains functions for the config file.
Definition in file config_file.h.
| int cfg_condense_ports | ( | struct config_file * | cfg, |
| int ** | avail | ||
| ) |
Get a condensed list of ports returned. allocated.
| cfg | config file. |
| avail | the available ports array is returned here. |
| time_t cfg_convert_timeval | ( | const char * | str | ) |
Convert 14digit to time value
| str | string of 14 digits |
| int cfg_count_numbers | ( | const char * | str | ) |
Count number of values in the string. format ::= (sp num)+ sp num ::= [-](0-9)+ sp ::= (space|tab)*
| str | string |
| int cfg_mark_ports | ( | const char * | str, |
| int | allow, | ||
| int * | avail, | ||
| int | num | ||
| ) |
Mark "number" or "low-high" as available or not in ports array.
| str | string in input |
| allow | give true if this range is permitted. |
| avail | the array from cfg. |
| num | size of the array (65536). |
| int cfg_parse_local_zone | ( | struct config_file * | cfg, |
| const char * | val | ||
| ) |
Parse local-zone directive into two strings and register it in the config.
| cfg | to put it in. |
| val | argument strings to local-zone, "example.com nodefault". |
| int cfg_parse_memsize | ( | const char * | str, |
| size_t * | res | ||
| ) |
Convert a 'nice' memory or file size into a bytecount From '100k' to 102400. and so on. Understands kKmMgG. k=1024, m=1024*1024, g=1024*1024*1024.
| str | string |
| res | result is stored here, size in bytes. |
| char* cfg_ptr_reverse | ( | char * | str | ) |
Convert a ptr shorthand into a full reverse-notation PTR record.
| str | input string, "IP name" |
| int cfg_region_strlist_insert | ( | struct regional * | region, |
| struct config_strlist ** | head, | ||
| char * | item | ||
| ) |
insert with region for allocation.
| int cfg_scan_ports | ( | int * | avail, |
| int | num | ||
| ) |
Scan ports available
| avail | the array from cfg. |
| num | size of the array (65536). |
| int cfg_str2list_insert | ( | struct config_str2list ** | head, |
| char * | item, | ||
| char * | i2 | ||
| ) |
Insert string into str2list.
| head | pointer to str2list head variable. |
| item | new item. malloced by caller. If NULL the insertion fails. |
| i2 | 2nd string, malloced by caller. If NULL the insertion fails. |
| int cfg_str3list_insert | ( | struct config_str3list ** | head, |
| char * | item, | ||
| char * | i2, | ||
| char * | i3 | ||
| ) |
Insert string into str3list.
| head | pointer to str3list head variable. |
| item | new item. malloced by caller. If NULL the insertion fails. |
| i2 | 2nd string, malloced by caller. If NULL the insertion fails. |
| i3 | 3rd string, malloced by caller. If NULL the insertion fails. |
| int cfg_strbytelist_insert | ( | struct config_strbytelist ** | head, |
| char * | item, | ||
| uint8_t * | i2, | ||
| size_t | i2len | ||
| ) |
Insert string into strbytelist.
| head | pointer to strbytelist head variable. |
| item | new item. malloced by caller. If NULL the insertion fails. |
| i2 | 2nd string, malloced by caller. If NULL the insertion fails. |
| i2len | length of the i2 bytestring. |
| int cfg_strlist_append | ( | struct config_strlist_head * | list, |
| char * | item | ||
| ) |
Append text at end of list.
| list | list head. zeroed at start. |
| item | new item. malloced by caller. if NULL the insertion fails. |
| struct config_strlist* cfg_strlist_find | ( | struct config_strlist * | head, |
| const char * | item | ||
| ) |
Find string in strlist.
| head | pointer to strlist head variable. |
| item | the item to search for. |
| int cfg_strlist_insert | ( | struct config_strlist ** | head, |
| char * | item | ||
| ) |
Insert string into strlist.
| head | pointer to strlist head variable. |
| item | new item. malloced by caller. If NULL the insertion fails. |
| struct config_stub* cfg_stub_find | ( | struct config_stub *** | pp, |
| const char * | nm | ||
| ) |
Find stub in config list, also returns prevptr (for deletion).
| pp | call routine with pointer to a pointer to the start of the list, if the stub is found, on exit, the value contains a pointer to the next pointer that points to the found element (or to the list start pointer if it is the first element). |
| nm | name of stub to find. |
| int config_add_tag | ( | struct config_file * | cfg, |
| const char * | tag | ||
| ) |
Add a tag name to the config. It is added at the end with a new ID value.
| cfg | the config structure. |
| tag | string (which is copied) with the name. |
| void config_apply | ( | struct config_file * | config | ) |
Apply config to global constants; this routine is called in single thread.
| config | to apply. Side effect: global constants change. |
| char* config_collate_cat | ( | struct config_strlist * | list | ) |
take a strlist_head list and return a malloc string. separated with newline.
| list | strlist first to collate. zeroes return "". |
| void config_collate_func | ( | char * | line, |
| void * | arg | ||
| ) |
function to collate the text strings into a strlist_head.
| line | text to append. |
| arg | pass a strlist_head structure. zeroed on start. |
| struct config_file* config_create | ( | void | ) |
Create config file structure. Filled with default values.
| struct config_file* config_create_forlib | ( | void | ) |
Create config file structure for library use. Filled with default values.
| void config_del_strbytelist | ( | struct config_strbytelist * | list | ) |
delete stringbytelist
| void config_delauth | ( | struct config_auth * | p | ) |
Delete an auth item
| p | auth item |
| void config_delauths | ( | struct config_auth * | list | ) |
Delete items in config auth list.
| list | list. |
| void config_deldblstrlist | ( | struct config_str2list * | list | ) |
Delete items in config double string list.
| list | list. |
| void config_delete | ( | struct config_file * | config | ) |
Destroy the config file structure.
| config | to delete. |
| void config_delstrlist | ( | struct config_strlist * | list | ) |
Delete items in config string list.
| list | list. |
| void config_delstub | ( | struct config_stub * | p | ) |
Delete a stub item
| p | stub item |
| void config_delstubs | ( | struct config_stub * | list | ) |
Delete items in config stub list.
| list | list. |
| void config_deltrplstrlist | ( | struct config_str3list * | list | ) |
Delete items in config triple string list.
| list | list. |
| void config_delview | ( | struct config_view * | p | ) |
Delete a view item
| p | view item |
| void config_delviews | ( | struct config_view * | list | ) |
Delete items in config view list.
| list | list. |
| int config_get_option | ( | struct config_file * | cfg, |
| const char * | opt, | ||
| void(*)(char *, void *) | func, | ||
| void * | arg | ||
| ) |
Call print routine for the given option.
| cfg | config. |
| opt | option name without trailing :. This is different from config_set_option. |
| func | print func, called as (str, arg) for every data element. |
| arg | user argument for print func. |
| int config_get_option_collate | ( | struct config_file * | cfg, |
| const char * | opt, | ||
| char ** | str | ||
| ) |
Get an option and collate results into string
| cfg | config file |
| opt | option name. |
| str | string. malloced, caller must free it. |
| int config_get_option_list | ( | struct config_file * | cfg, |
| const char * | opt, | ||
| struct config_strlist ** | list | ||
| ) |
Get an option and return strlist
| cfg | config file |
| opt | option name. |
| list | list is returned here. malloced, caller must free it. |
| void config_lookup_uid | ( | struct config_file * | config | ) |
Find username, sets cfg_uid and cfg_gid.
| config | the config structure. |
| uint8_t* config_parse_taglist | ( | struct config_file * | cfg, |
| char * | str, | ||
| size_t * | listlen | ||
| ) |
parse taglist from string into bytestring with bitlist.
| cfg | the config structure (with tagnames) |
| str | the string to parse. Parse puts 0 bytes in string. |
| listlen | returns length of in bytes. |
| void config_print_func | ( | char * | line, |
| void * | arg | ||
| ) |
function to print to a file, use as func with config_get_option.
| line | text to print. appended. |
| arg | pass a FILE*, like stdout. |
| int config_read | ( | struct config_file * | config, |
| const char * | filename, | ||
| const char * | chroot | ||
| ) |
Read the config file from the specified filename.
| config | where options are stored into, must be freshly created. |
| filename | name of configfile. If NULL nothing is done. |
| chroot | if not NULL, the chroot dir currently in use (for include). |
| int config_set_option | ( | struct config_file * | config, |
| const char * | option, | ||
| const char * | value | ||
| ) |
Set the given keyword to the given value.
| config | where to store config |
| option | option name, including the ':' character. |
| value | value, this string is copied if needed, or parsed. The caller owns the value string. |
| char* config_taglist2str | ( | struct config_file * | cfg, |
| uint8_t * | taglist, | ||
| size_t | len | ||
| ) |
convert tag bitlist to a malloced string with tag names. For debug output.
| cfg | the config structure (with tagnames) |
| taglist | the tag bitlist. |
| len | length of the tag bitlist. |
| void errinf | ( | struct module_qstate * | qstate, |
| const char * | str | ||
| ) |
Append text to the error info for validation.
| qstate | query state. |
| str | copied into query region and appended. Failures to allocate are logged. |
| void errinf_dname | ( | struct module_qstate * | qstate, |
| const char * | str, | ||
| uint8_t * | dname | ||
| ) |
Append text to error info: str dname
| qstate | query state. |
| str | explanation string |
| dname | the dname. |
| void errinf_origin | ( | struct module_qstate * | qstate, |
| struct sock_list * | origin | ||
| ) |
Append text to error info: from 1.2.3.4
| qstate | query state. |
| origin | sock list with origin of trouble. Every element added. If NULL: nothing is added. if 0len element: 'from cache' is added. |
| void errinf_rrset | ( | struct module_qstate * | qstate, |
| struct ub_packed_rrset_key * | rr | ||
| ) |
Append text to error info: for RRset name type class
| qstate | query state. |
| rr | rrset_key. |
| char* errinf_to_str | ( | struct module_qstate * | qstate | ) |
Create error info in string
| qstate | query state. |
| int find_tag_id | ( | struct config_file * | cfg, |
| const char * | tag | ||
| ) |
Find tag ID in the tag list.
| cfg | the config structure. |
| tag | string with tag name to search for. |
| char* fname_after_chroot | ( | const char * | fname, |
| struct config_file * | cfg, | ||
| int | use_chdir | ||
| ) |
Convert a filename to full pathname in original filesys
| fname | the path name to convert. Must not be null or empty. |
| cfg | config struct for chroot and chdir (if set). |
| use_chdir | if false, only chroot is applied. |
| void init_cfg_parse | ( | void | ) |
init lex state
| int options_remote_is_address | ( | struct config_file * | cfg | ) |
check if config for remote control turns on IP-address interface with certificates or a named pipe without certificates.
see if two taglists intersect (have tags in common).
| list1 | first tag bitlist. |
| list1len | length in bytes of first list. |
| list2 | second tag bitlist. |
| list2len | length in bytes of second list. |
| void ub_c_error | ( | const char * | msg | ) |
parsing helpers: print error with file and line numbers
| void ub_c_error_msg | ( | const char * | fmt, |
| ... | |||
| ) |
parsing helpers: print error with file and line numbers
| int ub_c_lex | ( | void | ) |
the lexer function
| int ub_c_parse | ( | void | ) |
the yacc lex generated parse function
| int ub_c_wrap | ( | void | ) |
wrap function
| int autr_permit_small_holddown |
debug and enable small timeouts
| gid_t cfg_gid |
from cfg username, after daemonize setup performed
| struct config_parser_state* cfg_parser |
global config parser object used during config parsing
| uid_t cfg_uid |
from cfg username, after daemonize setup performed
| void int fake_dsa |
debug option for unit tests.
| void int fake_sha1 |
| FILE* ub_c_in |
lex in file
| FILE* ub_c_out |
lex out file