View | Details | Raw Unified | Return to bug 734 | Differences between
and this patch

Collapse All | Expand All

(-)b/daemon/unbound.c (-7 / +9 lines)
 Lines 481-486   perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, Link Here 
481
#endif
481
#endif
482
482
483
#ifdef HAVE_KILL
483
#ifdef HAVE_KILL
484
	/* true if pidfile is inside chrootdir, or nochroot */
485
	const int pidinchroot = !(cfg->chrootdir && cfg->chrootdir[0]) ||
486
				(cfg->chrootdir && cfg->chrootdir[0] &&
487
				strncmp(daemon->pidfile, cfg->chrootdir,
488
				strlen(cfg->chrootdir))==0)
489
484
	/* check old pid file before forking */
490
	/* check old pid file before forking */
485
	if(cfg->pidfile && cfg->pidfile[0]) {
491
	if(cfg->pidfile && cfg->pidfile[0]) {
486
		/* calculate position of pidfile */
492
		/* calculate position of pidfile */
 Lines 490-501   perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, Link Here 
490
				cfg, 1);
496
				cfg, 1);
491
		if(!daemon->pidfile)
497
		if(!daemon->pidfile)
492
			fatal_exit("pidfile alloc: out of memory");
498
			fatal_exit("pidfile alloc: out of memory");
493
		checkoldpid(daemon->pidfile,
499
		checkoldpid(daemon->pidfile, pidinchroot);
494
			/* true if pidfile is inside chrootdir, or nochroot */
495
			!(cfg->chrootdir && cfg->chrootdir[0]) ||
496
			(cfg->chrootdir && cfg->chrootdir[0] &&
497
			strncmp(daemon->pidfile, cfg->chrootdir,
498
				strlen(cfg->chrootdir))==0));
499
	}
500
	}
500
#endif
501
#endif
501
502
 Lines 508-514   perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, Link Here 
508
#ifdef HAVE_KILL
509
#ifdef HAVE_KILL
509
	if(cfg->pidfile && cfg->pidfile[0]) {
510
	if(cfg->pidfile && cfg->pidfile[0]) {
510
		writepid(daemon->pidfile, getpid());
511
		writepid(daemon->pidfile, getpid());
511
		if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
512
		if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1 &&
513
			pidinchroot) {
512
#  ifdef HAVE_CHOWN
514
#  ifdef HAVE_CHOWN
513
			if(chown(daemon->pidfile, cfg_uid, cfg_gid) == -1) {
515
			if(chown(daemon->pidfile, cfg_uid, cfg_gid) == -1) {
514
				verbose(VERB_QUERY, "cannot chown %u.%u %s: %s",
516
				verbose(VERB_QUERY, "cannot chown %u.%u %s: %s",

Return to bug 734