Lines Matching refs: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 setup_listen_sslctx(void** ctx, int is_dot, int is_doh, struct config_file* cfg)
472 cfg->ssl_service_key, cfg->ssl_service_pem, NULL,
473 cfg->tls_ciphers, cfg->tls_ciphersuites,
474 (cfg->tls_session_ticket_keys.first &&
475 cfg->tls_session_ticket_keys.first->str[0] != 0),
480 (void)ctx;(void)is_dot;(void)is_doh;(void)cfg;
486 setup_sslctxs(struct daemon* daemon, struct config_file* cfg)
489 if(!(daemon->rc = daemon_remote_create(cfg)))
491 if(cfg->ssl_service_key && cfg->ssl_service_key[0]) {
494 if(cfg->tls_session_ticket_keys.first &&
495 cfg->tls_session_ticket_keys.first->str[0] != 0) {
497 cfg->tls_session_ticket_keys.first)) {
501 (void)setup_listen_sslctx(&daemon->listen_dot_sslctx, 1, 0, cfg);
503 if(cfg_has_https(cfg)) {
504 (void)setup_listen_sslctx(&daemon->listen_doh_sslctx, 0, 1, cfg);
508 if(cfg_has_quic(cfg)) {
510 cfg->ssl_service_key, cfg->ssl_service_pem, NULL))) {
517 cfg->tls_cert_bundle, cfg->tls_win_cert)))
520 (void)daemon;(void)cfg;
526 perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
539 if(cfg->username && cfg->username[0]) {
540 if((pwd = getpwnam(cfg->username)) == NULL)
541 fatal_exit("user '%s' does not exist.", cfg->username);
546 w_config_adjust_directory(cfg);
550 (void)setup_sslctxs(daemon, cfg);
554 if(cfg->use_syslog) {
555 log_init(cfg->logfile, cfg->use_syslog, cfg->chrootdir);
565 pidinchroot = need_pidfile && (!(cfg->chrootdir && cfg->chrootdir[0]) ||
566 (cfg->chrootdir && cfg->chrootdir[0] &&
567 strncmp(cfg->pidfile, cfg->chrootdir,
568 strlen(cfg->chrootdir))==0));
571 if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) {
573 if(cfg->pidfile[0] == '/')
574 daemon->pidfile = strdup(cfg->pidfile);
575 else daemon->pidfile = fname_after_chroot(cfg->pidfile,
576 cfg, 1);
586 if(!(cfg->username && cfg->username[0]))
592 if(!debug_mode && cfg->do_daemonize) {
598 if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) {
608 if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
616 cfg->username, strerror(errno));
625 if(cfg->chrootdir && cfg->chrootdir[0]) {
626 if(chdir(cfg->chrootdir)) {
628 cfg->chrootdir, strerror(errno));
630 verbose(VERB_QUERY, "chdir to %s", cfg->chrootdir);
631 if(chroot(cfg->chrootdir))
633 cfg->chrootdir, strerror(errno));
636 cfg->chrootdir, strerror(errno));
637 verbose(VERB_QUERY, "chroot to %s", cfg->chrootdir);
638 if(strncmp(*cfgfile, cfg->chrootdir,
639 strlen(cfg->chrootdir)) == 0)
640 (*cfgfile) += strlen(cfg->chrootdir);
644 strncmp(daemon->pidfile, cfg->chrootdir,
645 strlen(cfg->chrootdir))==0) {
647 daemon->pidfile = strdup(old+strlen(cfg->chrootdir));
652 daemon->chroot = strdup(cfg->chrootdir);
660 if(cfg->directory && cfg->directory[0]) {
661 char* dir = cfg->directory;
662 if(cfg->chrootdir && cfg->chrootdir[0] &&
663 strncmp(dir, cfg->chrootdir,
664 strlen(cfg->chrootdir)) == 0)
665 dir += strlen(cfg->chrootdir);
677 if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
679 if(initgroups(cfg->username, cfg_gid) != 0)
681 cfg->username, strerror(errno));
695 cfg->username, strerror(errno));
704 cfg->username, strerror(errno));
706 cfg->username);
711 if(!cfg->use_syslog)
712 log_init(cfg->logfile, cfg->use_syslog, cfg->chrootdir);
729 struct config_file* cfg = NULL;
741 if(!(cfg = config_create()))
743 if(!config_read(cfg, cfgfile, daemon->chroot)) {
751 apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
753 config_lookup_uid(cfg);
759 perform_setup(daemon, cfg, debug_mode, &cfgfile, need_pidfile);
763 if(!cfg->use_syslog)
764 log_init(cfg->logfile, 0, cfg->chrootdir);
772 config_delete(cfg);