diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pw/cpdir.c | 3 | ||||
-rw-r--r-- | usr.sbin/pw/pw.h | 1 | ||||
-rw-r--r-- | usr.sbin/pw/pw_conf.c | 4 | ||||
-rw-r--r-- | usr.sbin/pw/pw_user.c | 10 |
4 files changed, 9 insertions, 9 deletions
diff --git a/usr.sbin/pw/cpdir.c b/usr.sbin/pw/cpdir.c index f370421..017c200 100644 --- a/usr.sbin/pw/cpdir.c +++ b/usr.sbin/pw/cpdir.c @@ -41,6 +41,7 @@ static const char rcsid[] = #include <sys/param.h> #include <dirent.h> +#include "pw.h" #include "pwupd.h" void @@ -81,7 +82,7 @@ copymkdir(char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid else { if (S_ISDIR(st.st_mode)) { /* Recurse for this */ if (strcmp(e->d_name, ".") != 0 && strcmp(e->d_name, "..") != 0) - copymkdir(dst, src, (st.st_mode & 0777), uid, gid); + copymkdir(dst, src, st.st_mode & _DEF_DIRMODE, uid, gid); chflags(dst, st.st_flags); /* propogate flags */ } else if (S_ISLNK(st.st_mode) && (len = readlink(src, lnk, sizeof(lnk))) != -1) { lnk[len] = '\0'; diff --git a/usr.sbin/pw/pw.h b/usr.sbin/pw/pw.h index 7568c22..6e521d1 100644 --- a/usr.sbin/pw/pw.h +++ b/usr.sbin/pw/pw.h @@ -95,6 +95,7 @@ struct userconf int numgroups; /* (internal) size of default_group array */ }; +#define _DEF_DIRMODE (S_IRWXU | S_IRWXG | S_IRWXO) #define _PATH_PW_CONF "/etc/pw.conf" #define _UC_MAXLINE 1024 #define _UC_MAXSHELLS 32 diff --git a/usr.sbin/pw/pw_conf.c b/usr.sbin/pw/pw_conf.c index 51672b9..edeb015 100644 --- a/usr.sbin/pw/pw_conf.c +++ b/usr.sbin/pw/pw_conf.c @@ -91,7 +91,7 @@ static struct userconf config = NULL, /* Mail to send to new accounts */ "/var/log/userlog", /* Where to log changes */ "/home", /* Where to create home directory */ - 0777, /* Home directory perms, modified by umask */ + _DEF_DIRMODE, /* Home directory perms, modified by umask */ "/bin", /* Where shells are located */ system_shells, /* List of shells (first is default) */ bourne_shell, /* Default shell */ @@ -302,7 +302,7 @@ read_userconfig(char const * file) case _UC_HOMEMODE: modeset = setmode(q); config.homemode = (q == NULL || !boolean_val(q, 1)) - ? 0777 : getmode(modeset, 0777); + ? _DEF_DIRMODE : getmode(modeset, _DEF_DIRMODE); free(modeset); break; case _UC_SHELLPATH: diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c index dd92c43..db33746 100644 --- a/usr.sbin/pw/pw_user.c +++ b/usr.sbin/pw/pw_user.c @@ -107,7 +107,6 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) struct stat st; char line[_PASSWORD_LEN+1]; FILE *fp; - mode_t dmode; char *dmode_c; void *set = NULL; @@ -151,13 +150,12 @@ 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); - cnf->homemode = getmode(set, dmode); + cnf->homemode = getmode(set, _DEF_DIRMODE); free(set); } @@ -186,7 +184,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, dmode) != -1 || errno == EEXIST) { + if (mkdir(dbuf, _DEF_DIRMODE) != -1 || errno == EEXIST) { chown(dbuf, 0, 0); /* * Skip first "/" and create symlink: @@ -202,7 +200,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, dmode) == -1) + if (mkdir(dbuf, _DEF_DIRMODE) == -1) goto direrr; chown(dbuf, 0, 0); } else if (!S_ISDIR(st.st_mode)) @@ -211,7 +209,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) } } if (stat(dbuf, &st) == -1) { - if (mkdir(dbuf, dmode) == -1) { + if (mkdir(dbuf, _DEF_DIRMODE) == -1) { direrr: err(EX_OSFILE, "mkdir '%s'", dbuf); } chown(dbuf, 0, 0); |