diff --git a/daemon/remote.c b/daemon/remote.c index 675ef439..76eb6118 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -294,7 +294,7 @@ add_open(const char* ip, int nr, struct listen_port** list, int noproto_is_err, /* This looks like a local socket */ fd = create_local_accept_sock(ip, &noproto, cfg->use_systemd); /* - * Change socket ownership and permissions so users other + * Change socket group ownership and permissions so users other * than root can access it provided they are in the same * group as the user we run as. */ @@ -302,11 +302,10 @@ add_open(const char* ip, int nr, struct listen_port** list, int noproto_is_err, #ifdef HAVE_CHOWN chmod(ip, (mode_t)(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)); if (cfg->username && cfg->username[0] && - cfg_uid != (uid_t)-1) { - if(chown(ip, cfg_uid, cfg_gid) == -1) - verbose(VERB_QUERY, "cannot chown %u.%u %s: %s", - (unsigned)cfg_uid, (unsigned)cfg_gid, - ip, strerror(errno)); + cfg_gid != (gid_t)-1) { + if(chown(ip, -1, cfg_gid) == -1) + verbose(VERB_QUERY, "cannot chgrp %u %s: %s", + (unsigned)cfg_gid, ip, strerror(errno)); } #else (void)cfg; diff --git a/daemon/unbound.c b/daemon/unbound.c index 457a0803..200d631a 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -557,18 +557,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] && need_pidfile) { - if(writepid(daemon->pidfile, getpid())) { - if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1 && - pidinchroot) { -# ifdef HAVE_CHOWN - if(chown(daemon->pidfile, cfg_uid, cfg_gid) == -1) { - verbose(VERB_QUERY, "cannot chown %u.%u %s: %s", - (unsigned)cfg_uid, (unsigned)cfg_gid, - daemon->pidfile, strerror(errno)); - } -# endif /* HAVE_CHOWN */ - } - } + writepid(daemon->pidfile, getpid()); } #else (void)daemon;