Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Mar 2011 18:01:58 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r219383 - stable/7/usr.sbin/pw
Message-ID:  <201103071801.p27I1w2K042917@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Mon Mar  7 18:01:58 2011
New Revision: 219383
URL: http://svn.freebsd.org/changeset/base/219383

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/7/usr.sbin/pw/pw_user.c
Directory Properties:
  stable/7/usr.sbin/pw/   (props changed)

Modified: stable/7/usr.sbin/pw/pw_user.c
==============================================================================
--- stable/7/usr.sbin/pw/pw_user.c	Mon Mar  7 18:00:58 2011	(r219382)
+++ stable/7/usr.sbin/pw/pw_user.c	Mon Mar  7 18:01:58 2011	(r219383)
@@ -159,14 +159,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;
 	}
 
 	/*
@@ -194,7 +194,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:
@@ -210,7 +210,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))
@@ -219,7 +219,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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103071801.p27I1w2K042917>