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);
208 cfg->outgoing_num_ports = (int)((1024
212 cfg->outgoing_num_ports);
222 cfg->outgoing_num_ports = (int)((64
226 cfg->outgoing_num_ports);
228 (size_t)cfg->outgoing_num_ports)+misc;
250 cfg->outgoing_num_ports = (int)((avail
254 cfg->outgoing_num_ports);
265 (void)cfg;
272 apply_settings(struct daemon* daemon, struct config_file* cfg,
276 verbosity = cmdline_verbose + cfg->verbosity;
278 cfg->use_syslog = 0;
279 free(cfg->logfile);
280 cfg->logfile = NULL;
282 daemon_apply_cfg(daemon, cfg);
283 checkrlimits(cfg);
285 if (cfg->use_systemd && cfg->do_daemonize) {
289 log_ident_set_or_default(cfg->log_identity);
441 perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
450 if(cfg->username && cfg->username[0]) {
451 if((pwd = getpwnam(cfg->username)) == NULL)
452 fatal_exit("user '%s' does not exist.", cfg->username);
457 w_config_adjust_directory(cfg);
462 if(!(daemon->rc = daemon_remote_create(cfg)))
464 if(cfg->ssl_service_key && cfg->ssl_service_key[0]) {
466 cfg->ssl_service_key, cfg->ssl_service_pem, NULL)))
468 if(cfg->tls_ciphers && cfg->tls_ciphers[0]) {
469 if (!SSL_CTX_set_cipher_list(daemon->listen_sslctx, cfg->tls_ciphers)) {
470 fatal_exit("failed to set tls-cipher %s", cfg->tls_ciphers);
474 if(cfg->tls_ciphersuites && cfg->tls_ciphersuites[0]) {
475 if (!SSL_CTX_set_ciphersuites(daemon->listen_sslctx, cfg->tls_ciphersuites)) {
476 fatal_exit("failed to set tls-ciphersuites %s", cfg->tls_ciphersuites);
480 if(cfg->tls_session_ticket_keys.first &&
481 cfg->tls_session_ticket_keys.first->str[0] != 0) {
482 if(!listen_sslctx_setup_ticket_keys(daemon->listen_sslctx, cfg->tls_session_ticket_keys.first)) {
488 cfg->tls_cert_bundle, cfg->tls_win_cert)))
494 if(cfg->use_syslog) {
495 log_init(cfg->logfile, cfg->use_syslog, cfg->chrootdir);
505 pidinchroot = need_pidfile && (!(cfg->chrootdir && cfg->chrootdir[0]) ||
506 (cfg->chrootdir && cfg->chrootdir[0] &&
507 strncmp(cfg->pidfile, cfg->chrootdir,
508 strlen(cfg->chrootdir))==0));
511 if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) {
513 if(cfg->pidfile[0] == '/')
514 daemon->pidfile = strdup(cfg->pidfile);
515 else daemon->pidfile = fname_after_chroot(cfg->pidfile,
516 cfg, 1);
524 if(!debug_mode && cfg->do_daemonize) {
530 if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) {
532 if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1 &&
551 if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
559 cfg->username, strerror(errno));
568 if(cfg->chrootdir && cfg->chrootdir[0]) {
569 if(chdir(cfg->chrootdir)) {
571 cfg->chrootdir, strerror(errno));
573 verbose(VERB_QUERY, "chdir to %s", cfg->chrootdir);
574 if(chroot(cfg->chrootdir))
576 cfg->chrootdir, strerror(errno));
579 cfg->chrootdir, strerror(errno));
580 verbose(VERB_QUERY, "chroot to %s", cfg->chrootdir);
581 if(strncmp(*cfgfile, cfg->chrootdir,
582 strlen(cfg->chrootdir)) == 0)
583 (*cfgfile) += strlen(cfg->chrootdir);
587 strncmp(daemon->pidfile, cfg->chrootdir,
588 strlen(cfg->chrootdir))==0) {
590 daemon->pidfile = strdup(old+strlen(cfg->chrootdir));
595 daemon->chroot = strdup(cfg->chrootdir);
603 if(cfg->directory && cfg->directory[0]) {
604 char* dir = cfg->directory;
605 if(cfg->chrootdir && cfg->chrootdir[0] &&
606 strncmp(dir, cfg->chrootdir,
607 strlen(cfg->chrootdir)) == 0)
608 dir += strlen(cfg->chrootdir);
620 if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
622 if(initgroups(cfg->username, cfg_gid) != 0)
624 cfg->username, strerror(errno));
638 cfg->username, strerror(errno));
647 cfg->username, strerror(errno));
649 cfg->username);
654 if(!cfg->use_syslog)
655 log_init(cfg->logfile, cfg->use_syslog, cfg->chrootdir);
669 struct config_file* cfg = NULL;
681 if(!(cfg = config_create()))
683 if(!config_read(cfg, cfgfile, daemon->chroot)) {
691 apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
693 config_lookup_uid(cfg);
699 perform_setup(daemon, cfg, debug_mode, &cfgfile, need_pidfile);
703 if(!cfg->use_syslog)
704 log_init(cfg->logfile, 0, cfg->chrootdir);
712 config_delete(cfg);