From owner-svn-src-all@FreeBSD.ORG Mon Oct 29 17:19:44 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F8FD56C; Mon, 29 Oct 2012 17:19:44 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 470DA8FC15; Mon, 29 Oct 2012 17:19:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9THJiwM006465; Mon, 29 Oct 2012 17:19:44 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9THJiP0006462; Mon, 29 Oct 2012 17:19:44 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201210291719.q9THJiP0006462@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 29 Oct 2012 17:19:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r242319 - head/lib/libutil X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Oct 2012 17:19:44 -0000 Author: bapt Date: Mon Oct 29 17:19:43 2012 New Revision: 242319 URL: http://svn.freebsd.org/changeset/base/242319 Log: make pw_init and gr_init fail if the specified master password or group file is a directory. MFC after: 1 month Modified: head/lib/libutil/gr_util.c head/lib/libutil/pw_util.c Modified: head/lib/libutil/gr_util.c ============================================================================== --- head/lib/libutil/gr_util.c Mon Oct 29 16:58:45 2012 (r242318) +++ head/lib/libutil/gr_util.c Mon Oct 29 17:19:43 2012 (r242319) @@ -63,6 +63,8 @@ static const char group_line_format[] = int gr_init(const char *dir, const char *group) { + struct stat st; + if (dir == NULL) { strcpy(group_dir, _PATH_ETC); } else { @@ -88,6 +90,15 @@ gr_init(const char *dir, const char *gro } strcpy(group_file, group); } + + if (stat(group_file, &st) == -1) + return (-1); + + if (S_ISDIR(st.st_mode)) { + errno = EISDIR; + return (-1); + } + initialized = 1; return (0); } Modified: head/lib/libutil/pw_util.c ============================================================================== --- head/lib/libutil/pw_util.c Mon Oct 29 16:58:45 2012 (r242318) +++ head/lib/libutil/pw_util.c Mon Oct 29 17:19:43 2012 (r242319) @@ -96,6 +96,7 @@ pw_init(const char *dir, const char *mas #if 0 struct rlimit rlim; #endif + struct stat st; if (dir == NULL) { strcpy(passwd_dir, _PATH_ETC); @@ -123,6 +124,14 @@ pw_init(const char *dir, const char *mas strcpy(masterpasswd, master); } + if (stat(masterpasswd, &st) == -1) + return (-1); + + if (S_ISDIR(st.st_mode)) { + errno = EISDIR; + return (-1); + } + /* * The code that follows is extremely disruptive to the calling * process, and is therefore disabled until someone can conceive