summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2011-02-04 19:49:02 +0000
committerjkim <jkim@FreeBSD.org>2011-02-04 19:49:02 +0000
commitbb6fc35ada09f439d635af3a6e0e2f3bfaa35923 (patch)
tree942deacdb1c7c438176cc4d5d05d23c8cd708506 /usr.sbin
parent96bbcd53881415ab37e98125d25d776cc379b857 (diff)
downloadFreeBSD-src-bb6fc35ada09f439d635af3a6e0e2f3bfaa35923.zip
FreeBSD-src-bb6fc35ada09f439d635af3a6e0e2f3bfaa35923.tar.gz
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). MFC after: 1 month
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pw/pw_user.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index c8364ca..dd92c43 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -151,14 +151,14 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
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;
}
/*
@@ -186,7 +186,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
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:
@@ -202,7 +202,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
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))
@@ -211,7 +211,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
}
}
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);
OpenPOWER on IntegriCloud