diff options
Diffstat (limited to 'pw')
-rw-r--r-- | pw/Makefile | 2 | ||||
-rw-r--r-- | pw/cpdir.c | 3 | ||||
-rw-r--r-- | pw/pw.8 | 4 | ||||
-rw-r--r-- | pw/pw.h | 1 | ||||
-rw-r--r-- | pw/pw_conf.c | 4 | ||||
-rw-r--r-- | pw/pw_user.c | 15 |
6 files changed, 11 insertions, 18 deletions
diff --git a/pw/Makefile b/pw/Makefile index 8937124..ae0023c 100644 --- a/pw/Makefile +++ b/pw/Makefile @@ -6,6 +6,8 @@ SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \ grupd.c pwupd.c fileupd.c edgroup.c psdate.c \ bitmap.c cpdir.c rm_r.c +WARNS?= 1 + DPADD= ${LIBCRYPT} ${LIBUTIL} LDADD= -lcrypt -lutil @@ -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'; @@ -245,7 +245,6 @@ id as an alternative to using the options. .Pp The following flags are common to most or all modes of operation: -.Pp .Bl -tag -width "-G grouplist" .It Fl V Ar etcdir This flag sets an alternate location for the password, group and configuration files, @@ -319,7 +318,6 @@ The following options apply to the and .Ar usermod commands: -.Pp .Bl -tag -width "-G grouplist" .It Fl n Ar name Specify the user/account name. @@ -353,7 +351,6 @@ or .Fl u options. .El -.Pp .Bl -tag -width "-G grouplist" .It Fl c Ar comment This field sets the contents of the passwd GECOS field, which normally contains up @@ -802,7 +799,6 @@ There is rarely any need to duplicate a group id. The .Ar groupmod command adds one additional option: -.Pp .Bl -tag -width "-m newmembers" .It Fl l Ar name This option allows changing of an existing group name to @@ -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/pw/pw_conf.c b/pw/pw_conf.c index 51672b9..edeb015 100644 --- a/pw/pw_conf.c +++ b/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/pw/pw_user.c b/pw/pw_user.c index 4c62fe8..db33746 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -41,16 +41,11 @@ static const char rcsid[] = #include <sys/time.h> #include <sys/resource.h> #include <unistd.h> -#include <utmp.h> #include <login_cap.h> #include "pw.h" #include "bitmap.h" -#if (MAXLOGNAME-1) > UT_NAMESIZE -#define LOGNAMESIZE UT_NAMESIZE -#else #define LOGNAMESIZE (MAXLOGNAME-1) -#endif static char locked_str[] = "*LOCKED*"; @@ -112,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; @@ -161,9 +155,8 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) 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, _DEF_DIRMODE); free(set); - cnf->homemode = dmode; } /* @@ -191,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, cnf->homemode) != -1 || errno == EEXIST) { + if (mkdir(dbuf, _DEF_DIRMODE) != -1 || errno == EEXIST) { chown(dbuf, 0, 0); /* * Skip first "/" and create symlink: @@ -207,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, cnf->homemode) == -1) + if (mkdir(dbuf, _DEF_DIRMODE) == -1) goto direrr; chown(dbuf, 0, 0); } else if (!S_ISDIR(st.st_mode)) @@ -216,7 +209,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, _DEF_DIRMODE) == -1) { direrr: err(EX_OSFILE, "mkdir '%s'", dbuf); } chown(dbuf, 0, 0); |