svn commit: r282014 - in vendor/unbound/dist: daemon doc util

Dag-Erling Smørgrav des at FreeBSD.org
Sun Apr 26 11:33:03 UTC 2015


Author: des
Date: Sun Apr 26 11:33:01 2015
New Revision: 282014
URL: https://svnweb.freebsd.org/changeset/base/282014

Log:
  Merge upstream r3375 and r3376 which fix a segfault on startup when the
  user specified in the configuration file does not exist.
  
  PR:		197534

Modified:
  vendor/unbound/dist/daemon/remote.c
  vendor/unbound/dist/daemon/unbound.c
  vendor/unbound/dist/doc/Changelog
  vendor/unbound/dist/util/config_file.c

Modified: vendor/unbound/dist/daemon/remote.c
==============================================================================
--- vendor/unbound/dist/daemon/remote.c	Sun Apr 26 11:30:27 2015	(r282013)
+++ vendor/unbound/dist/daemon/remote.c	Sun Apr 26 11:33:01 2015	(r282014)
@@ -328,7 +328,8 @@ add_open(const char* ip, int nr, struct 
 		 */
 		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

Modified: vendor/unbound/dist/daemon/unbound.c
==============================================================================
--- vendor/unbound/dist/daemon/unbound.c	Sun Apr 26 11:30:27 2015	(r282013)
+++ vendor/unbound/dist/daemon/unbound.c	Sun Apr 26 11:33:01 2015	(r282014)
@@ -503,7 +503,7 @@ perform_setup(struct daemon* daemon, str
 #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, str
 
 	/* 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, str
 
 	/* 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",

Modified: vendor/unbound/dist/doc/Changelog
==============================================================================
--- vendor/unbound/dist/doc/Changelog	Sun Apr 26 11:30:27 2015	(r282013)
+++ vendor/unbound/dist/doc/Changelog	Sun Apr 26 11:33:01 2015	(r282014)
@@ -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.
 

Modified: vendor/unbound/dist/util/config_file.c
==============================================================================
--- vendor/unbound/dist/util/config_file.c	Sun Apr 26 11:30:27 2015	(r282013)
+++ vendor/unbound/dist/util/config_file.c	Sun Apr 26 11:33:01 2015	(r282014)
@@ -1211,10 +1211,10 @@ void config_lookup_uid(struct config_fil
 	/* 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;


More information about the svn-src-all mailing list