diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-05-12 11:55:17 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-05-12 11:55:17 +0000 |
commit | a6c5280ea59f940be13fd6eb0f94ab8360d3d6c9 (patch) | |
tree | cbe088761a83cf2025bbdf36e1574f38c3e988f5 /daemon/unbound.c | |
parent | 8c2647a7dc721c8e5349bd194b8e8e178412057e (diff) | |
download | src-a6c5280ea59f940be13fd6eb0f94ab8360d3d6c9.tar.gz src-a6c5280ea59f940be13fd6eb0f94ab8360d3d6c9.zip |
Vendor import of Unbound 1.6.6.vendor/unbound/1.6.6
Notes
Notes:
svn path=/vendor/unbound/dist/; revision=333541
svn path=/vendor/unbound/1.6.6/; revision=333542; tag=vendor/unbound/1.6.6
Diffstat (limited to 'daemon/unbound.c')
-rw-r--r-- | daemon/unbound.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/daemon/unbound.c b/daemon/unbound.c index ba7337d8907a..070a824d6734 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -128,6 +128,9 @@ static void usage(void) for(m = module_list_avail(); *m; m++) printf(" %s", *m); printf("\n"); +#ifdef USE_DNSCRYPT + printf("DNSCrypt feature available\n"); +#endif printf("BSD licensed, see LICENSE in source package for details.\n"); printf("Report bugs to %s\n", PACKAGE_BUGREPORT); ub_event_base_free(base); @@ -400,7 +403,7 @@ detach(void) /** daemonize, drop user priviliges and chroot if needed */ static void perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, - const char** cfgfile) + const char** cfgfile, int need_pidfile) { #ifdef HAVE_KILL int pidinchroot; @@ -444,13 +447,13 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, #ifdef HAVE_KILL /* true if pidfile is inside chrootdir, or nochroot */ - pidinchroot = !(cfg->chrootdir && cfg->chrootdir[0]) || + pidinchroot = need_pidfile && (!(cfg->chrootdir && cfg->chrootdir[0]) || (cfg->chrootdir && cfg->chrootdir[0] && strncmp(cfg->pidfile, cfg->chrootdir, - strlen(cfg->chrootdir))==0); + strlen(cfg->chrootdir))==0)); /* check old pid file before forking */ - if(cfg->pidfile && cfg->pidfile[0]) { + if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) { /* calculate position of pidfile */ if(cfg->pidfile[0] == '/') daemon->pidfile = strdup(cfg->pidfile); @@ -469,7 +472,7 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, /* write new pidfile (while still root, so can be outside chroot) */ #ifdef HAVE_KILL - if(cfg->pidfile && cfg->pidfile[0]) { + if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) { writepid(daemon->pidfile, getpid()); if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1 && pidinchroot) { @@ -484,6 +487,7 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, } #else (void)daemon; + (void)need_pidfile; #endif /* HAVE_KILL */ /* Set user context */ @@ -600,9 +604,10 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, * These increase verbosity as specified in the config file. * @param debug_mode: if set, do not daemonize. * @param log_default_identity: Default identity to report in logs + * @param need_pidfile: if false, no pidfile is checked or created. */ static void -run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode, const char* log_default_identity) +run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode, const char* log_default_identity, int need_pidfile) { struct config_file* cfg = NULL; struct daemon* daemon = NULL; @@ -632,7 +637,7 @@ run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode, const char* if(!daemon_open_shared_ports(daemon)) fatal_exit("could not open ports"); if(!done_setup) { - perform_setup(daemon, cfg, debug_mode, &cfgfile); + perform_setup(daemon, cfg, debug_mode, &cfgfile, need_pidfile); done_setup = 1; } else { /* reopen log after HUP to facilitate log rotation */ @@ -682,6 +687,8 @@ main(int argc, char* argv[]) const char* log_ident_default; int cmdline_verbose = 0; int debug_mode = 0; + int need_pidfile = 1; + #ifdef UB_ON_WINDOWS int cmdline_cfg = 0; #endif @@ -690,7 +697,7 @@ main(int argc, char* argv[]) log_ident_default = strrchr(argv[0],'/')?strrchr(argv[0],'/')+1:argv[0]; log_ident_set(log_ident_default); /* parse the options */ - while( (c=getopt(argc, argv, "c:dhvw:")) != -1) { + while( (c=getopt(argc, argv, "c:dhpvw:")) != -1) { switch(c) { case 'c': cfgfile = optarg; @@ -702,6 +709,9 @@ main(int argc, char* argv[]) cmdline_verbose++; verbosity++; break; + case 'p': + need_pidfile = 0; + break; case 'd': debug_mode++; break; @@ -732,7 +742,7 @@ main(int argc, char* argv[]) return 1; } - run_daemon(cfgfile, cmdline_verbose, debug_mode, log_ident_default); + run_daemon(cfgfile, cmdline_verbose, debug_mode, log_ident_default, need_pidfile); log_init(NULL, 0, NULL); /* close logfile */ return 0; } |