Lines Matching full:cfg
174 checkrlimits(struct config_file* cfg)
179 int list = ((cfg->do_udp?1:0) + (cfg->do_tcp?1 +
180 (int)cfg->incoming_num_tcp:0));
181 size_t listen_ifs = (size_t)(cfg->num_ifs==0?
182 ((cfg->do_ip4 && !cfg->if_automatic?1:0) +
183 (cfg->do_ip6?1:0)):cfg->num_ifs);
185 size_t outudpnum = (size_t)cfg->outgoing_num_ports;
186 size_t outtcpnum = cfg->outgoing_num_tcp;
195 int numthread = (cfg->num_threads?cfg->num_threads:1);
200 size_t memsize_expect = cfg->msg_cache_size + cfg->rrset_cache_size
201 + (cfg->do_tcp?cfg->stream_wait_size:0)
202 + (cfg->ip_ratelimit?cfg->ip_ratelimit_size:0)
203 + (cfg->ratelimit?cfg->ratelimit_size:0)
204 + (cfg->dnscrypt?cfg->dnscrypt_shared_secret_cache_size + cfg->dnscrypt_nonce_cache_size:0)
205 + cfg->infra_cache_numhosts * (sizeof(struct infra_key)+sizeof(struct infra_data));
206 if(strstr(cfg->module_conf, "validator") && (cfg->trust_anchor_file_list || cfg->trust_anchor_list || cfg->auto_trust_anchor_file_list || cfg->trusted_keys_file_list)) {
207 memsize_expect += cfg->key_cache_size + cfg->neg_cache_size;
210 if(cfg_has_https(cfg)) {
211 memsize_expect += cfg->http_query_buffer_size + cfg->http_response_buffer_size;
237 cfg->outgoing_num_ports = (int)((1024
241 cfg->outgoing_num_ports);
251 cfg->outgoing_num_ports = (int)((64
255 cfg->outgoing_num_ports);
257 (size_t)cfg->outgoing_num_ports)+misc;
279 cfg->outgoing_num_ports = (int)((avail
283 cfg->outgoing_num_ports);
294 (void)cfg;
301 apply_settings(struct daemon* daemon, struct config_file* cfg,
305 verbosity = cmdline_verbose + cfg->verbosity;
307 cfg->use_syslog = 0;
308 free(cfg->logfile);
309 cfg->logfile = NULL;
311 daemon_apply_cfg(daemon, cfg);
312 checkrlimits(cfg);
314 if (cfg->use_systemd && cfg->do_daemonize) {
318 log_ident_set_or_default(cfg->log_identity);
468 perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
481 if(cfg->username && cfg->username[0]) {
482 if((pwd = getpwnam(cfg->username)) == NULL)
483 fatal_exit("user '%s' does not exist.", cfg->username);
488 w_config_adjust_directory(cfg);
493 if(!(daemon->rc = daemon_remote_create(cfg)))
495 if(cfg->ssl_service_key && cfg->ssl_service_key[0]) {
497 cfg->ssl_service_key, cfg->ssl_service_pem, NULL)))
499 if(cfg->tls_ciphers && cfg->tls_ciphers[0]) {
500 if (!SSL_CTX_set_cipher_list(daemon->listen_sslctx, cfg->tls_ciphers)) {
501 fatal_exit("failed to set tls-cipher %s", cfg->tls_ciphers);
505 if(cfg->tls_ciphersuites && cfg->tls_ciphersuites[0]) {
506 if (!SSL_CTX_set_ciphersuites(daemon->listen_sslctx, cfg->tls_ciphersuites)) {
507 fatal_exit("failed to set tls-ciphersuites %s", cfg->tls_ciphersuites);
511 if(cfg->tls_session_ticket_keys.first &&
512 cfg->tls_session_ticket_keys.first->str[0] != 0) {
513 if(!listen_sslctx_setup_ticket_keys(daemon->listen_sslctx, cfg->tls_session_ticket_keys.first)) {
519 cfg->tls_cert_bundle, cfg->tls_win_cert)))
525 if(cfg->use_syslog) {
526 log_init(cfg->logfile, cfg->use_syslog, cfg->chrootdir);
536 pidinchroot = need_pidfile && (!(cfg->chrootdir && cfg->chrootdir[0]) ||
537 (cfg->chrootdir && cfg->chrootdir[0] &&
538 strncmp(cfg->pidfile, cfg->chrootdir,
539 strlen(cfg->chrootdir))==0));
542 if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) {
544 if(cfg->pidfile[0] == '/')
545 daemon->pidfile = strdup(cfg->pidfile);
546 else daemon->pidfile = fname_after_chroot(cfg->pidfile,
547 cfg, 1);
557 if(!(cfg->username && cfg->username[0]))
563 if(!debug_mode && cfg->do_daemonize) {
569 if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) {
579 if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
587 cfg->username, strerror(errno));
596 if(cfg->chrootdir && cfg->chrootdir[0]) {
597 if(chdir(cfg->chrootdir)) {
599 cfg->chrootdir, strerror(errno));
601 verbose(VERB_QUERY, "chdir to %s", cfg->chrootdir);
602 if(chroot(cfg->chrootdir))
604 cfg->chrootdir, strerror(errno));
607 cfg->chrootdir, strerror(errno));
608 verbose(VERB_QUERY, "chroot to %s", cfg->chrootdir);
609 if(strncmp(*cfgfile, cfg->chrootdir,
610 strlen(cfg->chrootdir)) == 0)
611 (*cfgfile) += strlen(cfg->chrootdir);
615 strncmp(daemon->pidfile, cfg->chrootdir,
616 strlen(cfg->chrootdir))==0) {
618 daemon->pidfile = strdup(old+strlen(cfg->chrootdir));
623 daemon->chroot = strdup(cfg->chrootdir);
631 if(cfg->directory && cfg->directory[0]) {
632 char* dir = cfg->directory;
633 if(cfg->chrootdir && cfg->chrootdir[0] &&
634 strncmp(dir, cfg->chrootdir,
635 strlen(cfg->chrootdir)) == 0)
636 dir += strlen(cfg->chrootdir);
648 if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
650 if(initgroups(cfg->username, cfg_gid) != 0)
652 cfg->username, strerror(errno));
666 cfg->username, strerror(errno));
675 cfg->username, strerror(errno));
677 cfg->username);
682 if(!cfg->use_syslog)
683 log_init(cfg->logfile, cfg->use_syslog, cfg->chrootdir);
697 struct config_file* cfg = NULL;
709 if(!(cfg = config_create()))
711 if(!config_read(cfg, cfgfile, daemon->chroot)) {
719 apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
721 config_lookup_uid(cfg);
727 perform_setup(daemon, cfg, debug_mode, &cfgfile, need_pidfile);
731 if(!cfg->use_syslog)
732 log_init(cfg->logfile, 0, cfg->chrootdir);
740 config_delete(cfg);