From owner-svn-src-stable-8@FreeBSD.ORG Mon Mar 7 18:00:59 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C8F4106566C; Mon, 7 Mar 2011 18:00:59 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 115F58FC0A; Mon, 7 Mar 2011 18:00:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p27I0w55042836; Mon, 7 Mar 2011 18:00:58 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p27I0w6e042834; Mon, 7 Mar 2011 18:00:58 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201103071800.p27I0w6e042834@svn.freebsd.org> From: Jung-uk Kim Date: Mon, 7 Mar 2011 18:00:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r219382 - stable/8/usr.sbin/pw X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Mar 2011 18:00:59 -0000 Author: jkim Date: Mon Mar 7 18:00:58 2011 New Revision: 219382 URL: http://svn.freebsd.org/changeset/base/219382 Log: MFC: r218293 Do not let pw.conf(5) or -M option affect creation of basehome, e.g., /home. When the basehome does not exist, it creates all intermediate directories as required, which is logically equivalent to mkdir(1) with -m and -p options. However, it modifies all intermediate directories, not just the final home directory unlike mkdir. This problem was introduced in two revisions, i.e., r1.59 (SVN r167919) and r1.60 (SVN r168044). Modified: stable/8/usr.sbin/pw/pw_user.c Directory Properties: stable/8/usr.sbin/pw/ (props changed) Modified: stable/8/usr.sbin/pw/pw_user.c ============================================================================== --- stable/8/usr.sbin/pw/pw_user.c Mon Mar 7 17:15:10 2011 (r219381) +++ stable/8/usr.sbin/pw/pw_user.c Mon Mar 7 18:00:58 2011 (r219382) @@ -156,14 +156,14 @@ pw_user(struct userconf * cnf, int mode, cnf->home = arg->val; } + dmode = S_IRWXU | S_IRWXG | S_IRWXO; if ((arg = getarg(args, 'M')) != NULL) { dmode_c = arg->val; if ((set = setmode(dmode_c)) == NULL) errx(EX_DATAERR, "invalid directory creation mode '%s'", dmode_c); - dmode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO); + cnf->homemode = getmode(set, dmode); free(set); - cnf->homemode = dmode; } /* @@ -191,7 +191,7 @@ pw_user(struct userconf * cnf, int mode, if (strchr(cnf->home+1, '/') == NULL) { strcpy(dbuf, "/usr"); strncat(dbuf, cnf->home, MAXPATHLEN-5); - if (mkdir(dbuf, cnf->homemode) != -1 || errno == EEXIST) { + if (mkdir(dbuf, dmode) != -1 || errno == EEXIST) { chown(dbuf, 0, 0); /* * Skip first "/" and create symlink: @@ -207,7 +207,7 @@ pw_user(struct userconf * cnf, int mode, while ((p = strchr(++p, '/')) != NULL) { *p = '\0'; if (stat(dbuf, &st) == -1) { - if (mkdir(dbuf, cnf->homemode) == -1) + if (mkdir(dbuf, dmode) == -1) goto direrr; chown(dbuf, 0, 0); } else if (!S_ISDIR(st.st_mode)) @@ -216,7 +216,7 @@ pw_user(struct userconf * cnf, int mode, } } if (stat(dbuf, &st) == -1) { - if (mkdir(dbuf, cnf->homemode) == -1) { + if (mkdir(dbuf, dmode) == -1) { direrr: err(EX_OSFILE, "mkdir '%s'", dbuf); } chown(dbuf, 0, 0);