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