From owner-svn-src-vendor@FreeBSD.ORG Sun Apr 26 11:33:03 2015 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 38C99F9C; Sun, 26 Apr 2015 11:33:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2750A19C8; Sun, 26 Apr 2015 11:33:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3QBX30A074327; Sun, 26 Apr 2015 11:33:03 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3QBX2sT074323; Sun, 26 Apr 2015 11:33:02 GMT (envelope-from des@FreeBSD.org) Message-Id: <201504261133.t3QBX2sT074323@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: des set sender to des@FreeBSD.org using -f From: Dag-Erling Smørgrav Date: Sun, 26 Apr 2015 11:33:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r282014 - in vendor/unbound/dist: daemon doc util X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Apr 2015 11:33:03 -0000 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;