aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2015-04-26 11:33:01 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2015-04-26 11:33:01 +0000
commit0ea28240053521a309698413a426b4d730a3d60c (patch)
tree8e7ba203010162f7fe341b7dfd3f0410718c32c2
parent9145bbd450b41b3d36e63a815d45bf740a3e0230 (diff)
downloadsrc-0ea28240053521a309698413a426b4d730a3d60c.tar.gz
src-0ea28240053521a309698413a426b4d730a3d60c.zip
Notes
-rw-r--r--daemon/remote.c3
-rw-r--r--daemon/unbound.c6
-rw-r--r--doc/Changelog3
-rw-r--r--util/config_file.c8
4 files changed, 12 insertions, 8 deletions
diff --git a/daemon/remote.c b/daemon/remote.c
index 65749568fddf..3ce55ee7ea1a 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -328,7 +328,8 @@ add_open(const char* ip, int nr, struct listen_port** list, int noproto_is_err,
*/
if(fd != -1) {
#ifdef HAVE_CHOWN
- if (cfg->username && cfg->username[0])
+ if (cfg->username && cfg->username[0] &&
+ cfg_uid != (uid_t)-1)
chown(ip, cfg_uid, cfg_gid);
chmod(ip, (mode_t)(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP));
#else
diff --git a/daemon/unbound.c b/daemon/unbound.c
index b70e39686d4c..8e07c3895650 100644
--- a/daemon/unbound.c
+++ b/daemon/unbound.c
@@ -503,7 +503,7 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
#ifdef HAVE_KILL
if(cfg->pidfile && cfg->pidfile[0]) {
writepid(daemon->pidfile, getpid());
- if(cfg->username && cfg->username[0]) {
+ if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
# ifdef HAVE_CHOWN
if(chown(daemon->pidfile, cfg_uid, cfg_gid) == -1) {
log_err("cannot chown %u.%u %s: %s",
@@ -519,7 +519,7 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
/* Set user context */
#ifdef HAVE_GETPWNAM
- if(cfg->username && cfg->username[0]) {
+ if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
#ifdef HAVE_SETUSERCONTEXT
/* setusercontext does initgroups, setuid, setgid, and
* also resource limits from login config, but we
@@ -586,7 +586,7 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
/* drop permissions after chroot, getpwnam, pidfile, syslog done*/
#ifdef HAVE_GETPWNAM
- if(cfg->username && cfg->username[0]) {
+ if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
# ifdef HAVE_INITGROUPS
if(initgroups(cfg->username, cfg_gid) != 0)
log_warn("unable to initgroups %s: %s",
diff --git a/doc/Changelog b/doc/Changelog
index 5c3447cbe673..a1c2f76cd21d 100644
--- a/doc/Changelog
+++ b/doc/Changelog
@@ -1,3 +1,6 @@
+23 March 2015: Wouter
+ - Fix segfault on user not found at startup (from Maciej Soltysiak).
+
2 March 2015: Wouter
- iana portlist update.
diff --git a/util/config_file.c b/util/config_file.c
index 5c4e897da373..9c427ed0d4f5 100644
--- a/util/config_file.c
+++ b/util/config_file.c
@@ -1211,10 +1211,10 @@ void config_lookup_uid(struct config_file* cfg)
/* translate username into uid and gid */
if(cfg->username && cfg->username[0]) {
struct passwd *pwd;
- if((pwd = getpwnam(cfg->username)) == NULL)
- log_err("user '%s' does not exist.", cfg->username);
- cfg_uid = pwd->pw_uid;
- cfg_gid = pwd->pw_gid;
+ if((pwd = getpwnam(cfg->username)) != NULL) {
+ cfg_uid = pwd->pw_uid;
+ cfg_gid = pwd->pw_gid;
+ }
}
#else
(void)cfg;