CVS commit: src/usr.sbin/user
Module Name:src Committed By: zafer Date: Sun Jun 10 07:52:05 UTC 2018 Modified Files: src/usr.sbin/user: user.c Log Message: Set default homeperm values before writing usermgmt.conf file and honor values in it instead of ignoring it. Fixes PR bin/40324 by Guy Yur To generate a diff of this commit: cvs rdiff -u -r1.131 -r1.132 src/usr.sbin/user/user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/user.c diff -u src/usr.sbin/user/user.c:1.131 src/usr.sbin/user/user.c:1.132 --- src/usr.sbin/user/user.c:1.131 Wed Nov 28 11:31:27 2012 +++ src/usr.sbin/user/user.c Sun Jun 10 07:52:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.131 2012/11/28 11:31:27 blymn Exp $ */ +/* $NetBSD: user.c,v 1.132 2018/06/10 07:52:05 zafer Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved."); -__RCSID("$NetBSD: user.c,v 1.131 2012/11/28 11:31:27 blymn Exp $"); +__RCSID("$NetBSD: user.c,v 1.132 2018/06/10 07:52:05 zafer Exp $"); #endif #include @@ -819,6 +819,7 @@ read_defaults(def_t *dp) NEWARRAY(range_t, up->u_rv, up->u_rsize, exit(1)); up->u_inactive = DEF_INACTIVE; up->u_expire = DEF_EXPIRE; + up->u_homeperm = DEF_HOMEPERM; gp->g_rsize = 16; gp->g_defrc = 0; NEWARRAY(range_t, gp->g_rv, gp->g_rsize, exit(1)); @@ -903,7 +904,6 @@ read_defaults(def_t *dp) up->u_rc += 1; } up->u_defrc = up->u_rc; - up->u_homeperm = DEF_HOMEPERM; } /* return the next valid unused uid */
CVS commit: src/usr.sbin/user
Module Name:src Committed By: wiz Date: Tue Feb 9 14:14:02 UTC 2016 Modified Files: src/usr.sbin/user: usermgmt.conf.5 Log Message: Document file format better. From Travis Paul and Matthew Bauer. Bump date. Addresses PR 50787. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/user/usermgmt.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/usermgmt.conf.5 diff -u src/usr.sbin/user/usermgmt.conf.5:1.7 src/usr.sbin/user/usermgmt.conf.5:1.8 --- src/usr.sbin/user/usermgmt.conf.5:1.7 Thu Dec 31 20:14:19 2009 +++ src/usr.sbin/user/usermgmt.conf.5 Tue Feb 9 14:14:02 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: usermgmt.conf.5,v 1.7 2009/12/31 20:14:19 wiz Exp $ +.\" $NetBSD: usermgmt.conf.5,v 1.8 2016/02/09 14:14:02 wiz Exp $ .\" .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -29,7 +29,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 31, 2009 +.Dd February 9, 2016 .Dt USERMGMT.CONF 5 .Os .\" turn off hyphenation @@ -135,12 +135,28 @@ sets the default login shell for new use sets the default skeleton directory in which to find files with which to populate the new user's home directory. .El +.Ss SYNTAX +The +.Nm +file uses a simple syntax format. +Each line must contain one option. +That option must be in the front of the line (no spaces). +Any number of white spaces such as ' ' and '\et' may follow. +The line ends with a list of options from each. .Sh FILES .Bl -tag -width /etc/usermgmt.conf -compact .It Pa /etc/usermgmt.conf .It Pa /etc/skel/* .It Pa /etc/login.conf .El +.Sh EXAMPLES +.Bd -unfilled -offset indent -compact +group wheel +base_dir /home/ +skel_dir /etc/skel +shell /bin/sh +inactive 0 +.Ed .Sh SEE ALSO .Xr login.conf 5 , .Xr passwd 5 ,
CVS commit: src/usr.sbin/user
Module Name:src Committed By: wiz Date: Fri Sep 19 16:04:29 UTC 2014 Modified Files: src/usr.sbin/user: usermod.8 Log Message: Fix section name. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/user/usermod.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/usermod.8 diff -u src/usr.sbin/user/usermod.8:1.33 src/usr.sbin/user/usermod.8:1.34 --- src/usr.sbin/user/usermod.8:1.33 Fri Sep 19 16:02:59 2014 +++ src/usr.sbin/user/usermod.8 Fri Sep 19 16:04:29 2014 @@ -1,4 +1,4 @@ -.\ $NetBSD: usermod.8,v 1.33 2014/09/19 16:02:59 wiz Exp $ */ +.\ $NetBSD: usermod.8,v 1.34 2014/09/19 16:04:29 wiz Exp $ */ .\ .\ Copyright (c) 1999 Alistair G. Crooks. All rights reserved. .\ @@ -228,7 +228,7 @@ At very large sites this can take severa Until this update is completed, the password file is unavailable for other updates and the new information is not available to programs. -.Sh EXIT STATUS +.Sh FILES .Bl -tag -width /etc/usermgmt.conf -compact .It Pa /etc/usermgmt.conf .El
CVS commit: src/usr.sbin/user
Module Name:src Committed By: blymn Date: Wed Nov 28 11:20:58 UTC 2012 Modified Files: src/usr.sbin/user: user.c Log Message: Google Code In bug fix by Philip Hayes, fixes bin/41049 To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/usr.sbin/user/user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/user.c diff -u src/usr.sbin/user/user.c:1.129 src/usr.sbin/user/user.c:1.130 --- src/usr.sbin/user/user.c:1.129 Thu Dec 1 00:34:05 2011 +++ src/usr.sbin/user/user.c Wed Nov 28 11:20:58 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.129 2011/12/01 00:34:05 dholland Exp $ */ +/* $NetBSD: user.c,v 1.130 2012/11/28 11:20:58 blymn Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: user.c,v 1.129 2011/12/01 00:34:05 dholland Exp $); +__RCSID($NetBSD: user.c,v 1.130 2012/11/28 11:20:58 blymn Exp $); #endif #include sys/types.h @@ -1579,6 +1579,12 @@ moduser(char *login_name, char *newlogin login_name, up-u_uid); } pwp-pw_gid = pwp-pw_uid; +if (!creategid(newlogin, pwp-pw_uid, )) { + errx(EXIT_FAILURE, + Could not create group %s + with uid %d, newlogin, + up-u_uid); +} } else if ((grp = getgrnam(up-u_primgrp)) != NULL) { pwp-pw_gid = grp-gr_gid; } else if (is_number(up-u_primgrp)
CVS commit: src/usr.sbin/user
Module Name:src Committed By: blymn Date: Wed Nov 28 11:31:27 UTC 2012 Modified Files: src/usr.sbin/user: user.c Log Message: Fix error message when trying to add a group using -g =uid that that already exists, the old version printed the wrong GID. To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/usr.sbin/user/user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/user.c diff -u src/usr.sbin/user/user.c:1.130 src/usr.sbin/user/user.c:1.131 --- src/usr.sbin/user/user.c:1.130 Wed Nov 28 11:20:58 2012 +++ src/usr.sbin/user/user.c Wed Nov 28 11:31:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.130 2012/11/28 11:20:58 blymn Exp $ */ +/* $NetBSD: user.c,v 1.131 2012/11/28 11:31:27 blymn Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: user.c,v 1.130 2012/11/28 11:20:58 blymn Exp $); +__RCSID($NetBSD: user.c,v 1.131 2012/11/28 11:31:27 blymn Exp $); #endif #include sys/types.h @@ -1576,7 +1576,7 @@ moduser(char *login_name, char *newlogin errx(EXIT_FAILURE, Can't modify user `%s': gid %d is already in use, - login_name, up-u_uid); + login_name, pwp-pw_uid); } pwp-pw_gid = pwp-pw_uid; if (!creategid(newlogin, pwp-pw_uid, )) {
CVS commit: src/usr.sbin/user
Module Name:src Committed By: dholland Date: Thu Dec 1 00:15:32 UTC 2011 Modified Files: src/usr.sbin/user: user.c Log Message: attribute format printf - __printflike To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 src/usr.sbin/user/user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/user.c diff -u src/usr.sbin/user/user.c:1.126 src/usr.sbin/user/user.c:1.127 --- src/usr.sbin/user/user.c:1.126 Tue Jan 4 10:30:21 2011 +++ src/usr.sbin/user/user.c Thu Dec 1 00:15:32 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.126 2011/01/04 10:30:21 wiz Exp $ */ +/* $NetBSD: user.c,v 1.127 2011/12/01 00:15:32 dholland Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: user.c,v 1.126 2011/01/04 10:30:21 wiz Exp $); +__RCSID($NetBSD: user.c,v 1.127 2011/12/01 00:15:32 dholland Exp $); #endif #include sys/types.h @@ -219,8 +219,7 @@ enum { #define UNSET_INACTIVE Null (unset) #define UNSET_EXPIRY Null (unset) -static int asystem(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); +static int asystem(const char *fmt, ...) __printflike(1, 2); static int is_number(const char *); static struct group *find_group_info(const char *); static int verbose;
CVS commit: src/usr.sbin/user
Module Name:src Committed By: dholland Date: Thu Dec 1 00:26:45 UTC 2011 Modified Files: src/usr.sbin/user: user.c Log Message: Handle return value from system() properly. PR 45672 from River Tarnell. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/usr.sbin/user/user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/user.c diff -u src/usr.sbin/user/user.c:1.127 src/usr.sbin/user/user.c:1.128 --- src/usr.sbin/user/user.c:1.127 Thu Dec 1 00:15:32 2011 +++ src/usr.sbin/user/user.c Thu Dec 1 00:26:45 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.127 2011/12/01 00:15:32 dholland Exp $ */ +/* $NetBSD: user.c,v 1.128 2011/12/01 00:26:45 dholland Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,12 +33,13 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: user.c,v 1.127 2011/12/01 00:15:32 dholland Exp $); +__RCSID($NetBSD: user.c,v 1.128 2011/12/01 00:26:45 dholland Exp $); #endif #include sys/types.h #include sys/param.h #include sys/stat.h +#include sys/wait.h #include ctype.h #include dirent.h @@ -265,8 +266,13 @@ asystem(const char *fmt, ...) if (verbose) { (void)printf(Command: %s\n, buf); } - if ((ret = system(buf)) != 0) { + ret = system(buf); + if (ret == -1) { warn(Error running `%s', buf); + } else if (WIFSIGNALED(ret)) { + warnx(Error running `%s': Signal %d, buf, WTERMSIG(ret)); + } else if (WIFEXITED(ret) WEXITSTATUS(ret) != 0) { + warnx(Error running `%s': Exit %d, buf, WEXITSTATUS(ret)); } return ret; }
CVS commit: src/usr.sbin/user
Module Name:src Committed By: dholland Date: Thu Dec 1 00:34:05 UTC 2011 Modified Files: src/usr.sbin/user: user.c Added Files: src/usr.sbin/user: pathnames.h Log Message: Move path names to pathnames.h per conventions To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/usr.sbin/user/pathnames.h cvs rdiff -u -r1.128 -r1.129 src/usr.sbin/user/user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/user.c diff -u src/usr.sbin/user/user.c:1.128 src/usr.sbin/user/user.c:1.129 --- src/usr.sbin/user/user.c:1.128 Thu Dec 1 00:26:45 2011 +++ src/usr.sbin/user/user.c Thu Dec 1 00:34:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.128 2011/12/01 00:26:45 dholland Exp $ */ +/* $NetBSD: user.c,v 1.129 2011/12/01 00:34:05 dholland Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: user.c,v 1.128 2011/12/01 00:26:45 dholland Exp $); +__RCSID($NetBSD: user.c,v 1.129 2011/12/01 00:34:05 dholland Exp $); #endif #include sys/types.h @@ -49,7 +49,6 @@ __RCSID($NetBSD: user.c,v 1.128 2011/12 #ifdef EXTENSIONS #include login_cap.h #endif -#include paths.h #include pwd.h #include regex.h #include stdarg.h @@ -62,6 +61,7 @@ __RCSID($NetBSD: user.c,v 1.128 2011/12 #include util.h #include errno.h +#include pathnames.h #include defs.h #include usermgmt.h @@ -142,8 +142,6 @@ enum { #define LOCK 1 #define LOCKED *LOCKED* -#define PATH_LOGINCONF /etc/login.conf - #ifndef DEF_GROUP #define DEF_GROUP users #endif @@ -208,15 +206,6 @@ enum { DES_Len = 13, }; -/* Full paths of programs used here */ -#define CHMOD /bin/chmod -#define CHOWN /usr/sbin/chown -#define MKDIR /bin/mkdir -#define MV /bin/mv -#define NOLOGIN /sbin/nologin -#define PAX /bin/pax -#define RM /bin/rm - #define UNSET_INACTIVE Null (unset) #define UNSET_EXPIRY Null (unset) @@ -308,7 +297,8 @@ removehomedir(struct passwd *pwp) (void)seteuid(pwp-pw_uid); /* we add the || true to keep asystem() quiet if there is a non-zero exit status. */ - (void)asystem(%s -rf %s /dev/null 21 || true, RM, pwp-pw_dir); + (void)asystem(%s -rf %s /dev/null 21 || true, _PATH_RM, + pwp-pw_dir); (void)seteuid(0); if (rmdir(pwp-pw_dir) 0) { warn(Unable to remove all files in `%s', pwp-pw_dir); @@ -365,12 +355,12 @@ copydotfiles(char *skeldir, int uid, int warnx(No \dot\ initialisation files found); } else { (void)asystem(cd %s %s -rw -pe %s . %s, -skeldir, PAX, (verbose) ? -v : , dir); + skeldir, _PATH_PAX, (verbose) ? -v : , dir); } - (void)asystem(%s -R -h %d:%d %s, CHOWN, uid, gid, dir); - (void)asystem(%s -R u+w %s, CHMOD, dir); + (void)asystem(%s -R -h %d:%d %s, _PATH_CHOWN, uid, gid, dir); + (void)asystem(%s -R u+w %s, _PATH_CHMOD, dir); #ifdef EXTENSIONS - (void)asystem(%s 0%o %s, CHMOD, homeperm, dir); + (void)asystem(%s 0%o %s, _PATH_CHMOD, homeperm, dir); #endif return n; } @@ -994,9 +984,9 @@ valid_class(char *class) * user the actual login class does not exist. */ - if (access(PATH_LOGINCONF, R_OK) == -1) { + if (access(_PATH_LOGINCONF, R_OK) == -1) { warn(Access failed for `%s'; will not validate class `%s', - PATH_LOGINCONF, class); + _PATH_LOGINCONF, class); return 1; } @@ -1021,7 +1011,7 @@ valid_shell(const char *shellname) } /* if nologin is used as a shell, consider it a valid shell */ - if (strcmp(shellname, NOLOGIN) == 0) + if (strcmp(shellname, _PATH_SBIN_NOLOGIN) == 0) return 1; while ((shellp = getusershell()) != NULL) @@ -1262,7 +1252,7 @@ adduser(char *login_name, user_t *up) Can't add user `%s': home directory `%s' already exists, login_name, home); } else { - if (asystem(%s -p %s, MKDIR, home) != 0) { + if (asystem(%s -p %s, _PATH_MKDIR, home) != 0) { (void)close(ptmpfd); (void)pw_abort(); errx(EXIT_FAILURE, Can't add user `%s': @@ -1704,7 +1694,7 @@ moduser(char *login_name, char *newlogin } if (up != NULL) { if ((up-u_flags F_MKDIR) - asystem(%s %s %s, MV, homedir, pwp-pw_dir) != 0) { + asystem(%s %s %s, _PATH_MV, homedir, pwp-pw_dir) != 0) { (void)close(ptmpfd); (void)pw_abort(); errx(EXIT_FAILURE, Can't modify user `%s': @@ -2210,7 +2200,8 @@ userdel(int argc, char **argv) } if (up-u_preserve) { up-u_flags |= F_SHELL; - memsave(up-u_shell, NOLOGIN, strlen(NOLOGIN)); + memsave(up-u_shell, _PATH_SBIN_NOLOGIN, + strlen(_PATH_SBIN_NOLOGIN)); (void)memset(password, '*', DES_Len); password[DES_Len] = 0; memsave(up-u_password, password, strlen(password)); Added files: Index: src/usr.sbin/user/pathnames.h diff -u /dev/null src/usr.sbin/user/pathnames.h:1.1 --- /dev/null Thu Dec 1 00:34:05 2011 +++ src/usr.sbin/user/pathnames.h
CVS commit: src/usr.sbin/user
Module Name:src Committed By: wiz Date: Tue Jan 4 10:30:21 UTC 2011 Modified Files: src/usr.sbin/user: user.c Log Message: Close masterfd after reading from it. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/usr.sbin/user/user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/user.c diff -u src/usr.sbin/user/user.c:1.125 src/usr.sbin/user/user.c:1.126 --- src/usr.sbin/user/user.c:1.125 Thu Dec 31 19:59:31 2009 +++ src/usr.sbin/user/user.c Tue Jan 4 10:30:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.125 2009/12/31 19:59:31 mlelstv Exp $ */ +/* $NetBSD: user.c,v 1.126 2011/01/04 10:30:21 wiz Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: user.c,v 1.125 2009/12/31 19:59:31 mlelstv Exp $); +__RCSID($NetBSD: user.c,v 1.126 2011/01/04 10:30:21 wiz Exp $); #endif #include sys/types.h @@ -1115,6 +1115,7 @@ short write to /etc/ptmp, login_name); } } + (void)close(masterfd); /* if no uid was specified, get next one in [low_uid..high_uid] range */ sync_uid_gid = (strcmp(up-u_primgrp, =uid) == 0); if (up-u_uid == -1) {
CVS commit: src/usr.sbin/user
Module Name:src Committed By: mlelstv Date: Thu Dec 31 19:59:31 UTC 2009 Modified Files: src/usr.sbin/user: user.c usermgmt.conf.5 Log Message: Add new keyword gid_range to usermgmt.conf which specifies a default GID range for groupadd(8). To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/usr.sbin/user/user.c cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/user/usermgmt.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/user.c diff -u src/usr.sbin/user/user.c:1.124 src/usr.sbin/user/user.c:1.125 --- src/usr.sbin/user/user.c:1.124 Thu Oct 15 23:03:02 2009 +++ src/usr.sbin/user/user.c Thu Dec 31 19:59:31 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.124 2009/10/15 23:03:02 hubertf Exp $ */ +/* $NetBSD: user.c,v 1.125 2009/12/31 19:59:31 mlelstv Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: user.c,v 1.124 2009/10/15 23:03:02 hubertf Exp $); +__RCSID($NetBSD: user.c,v 1.125 2009/12/31 19:59:31 mlelstv Exp $); #endif #include sys/types.h @@ -71,7 +71,14 @@ int r_to; /* high uid */ } range_t; -/* this struct encapsulates the user information */ +typedef struct rangelist_t { + unsigned rl_rsize; /* size of range array */ + unsigned rl_rc; /* # of ranges */ + range_t *rl_rv; /* the ranges */ + unsigned rl_defrc; /* # of ranges in defaults */ +} rangelist_t; + +/* this struct encapsulates the user and group information */ typedef struct user_t { int u_flags; /* see below */ int u_uid; /* uid of user */ @@ -88,14 +95,30 @@ char *u_inactive; /* when account will expire */ char *u_skeldir; /* directory for startup files */ char *u_class; /* login class */ - unsigned u_rsize; /* size of range array */ - unsigned u_rc; /* # of ranges */ - range_t *u_rv; /* the ranges */ + rangelist_t u_r; /* list of ranges */ unsigned u_defrc; /* # of ranges in defaults */ int u_preserve; /* preserve uids on deletion */ int u_allow_samba; /* allow trailing '$' for samba login names */ int u_locked; /* user account lock */ } user_t; +#define u_rsize u_r.rl_rsize +#define u_rcu_r.rl_rc +#define u_rvu_r.rl_rv +#define u_defrc u_r.rl_defrc + +/* this struct encapsulates the user and group information */ +typedef struct group_t { + rangelist_t g_r; /* list of ranges */ +} group_t; +#define g_rsize g_r.rl_rsize +#define g_rcg_r.rl_rc +#define g_rvg_r.rl_rv +#define g_defrc g_r.rl_defrc + +typedef struct def_t { + user_t user; + group_t group; +} def_t; /* flags for which fields of the user_t replace the passwd entry */ enum { @@ -182,9 +205,6 @@ PasswordLength = 2048, DES_Len = 13, - - LowGid = DEF_LOWUID, - HighGid = DEF_HIGHUID }; /* Full paths of programs used here */ @@ -682,30 +702,30 @@ #ifdef EXTENSIONS /* save a range of uids */ static int -save_range(user_t *up, char *cp) +save_range(rangelist_t *rlp, char *cp) { int from; int to; int i; - if (up-u_rsize == 0) { - up-u_rsize = 32; - NEWARRAY(range_t, up-u_rv, up-u_rsize, return(0)); - } else if (up-u_rc == up-u_rsize) { - up-u_rsize *= 2; - RENEW(range_t, up-u_rv, up-u_rsize, return(0)); - } - if (up-u_rv sscanf(cp, %d..%d, from, to) == 2) { - for (i = up-u_defrc ; i up-u_rc ; i++) { - if (up-u_rv[i].r_from == from - up-u_rv[i].r_to == to) { + if (rlp-rl_rsize == 0) { + rlp-rl_rsize = 32; + NEWARRAY(range_t, rlp-rl_rv, rlp-rl_rsize, return(0)); + } else if (rlp-rl_rc == rlp-rl_rsize) { + rlp-rl_rsize *= 2; + RENEW(range_t, rlp-rl_rv, rlp-rl_rsize, return(0)); + } + if (rlp-rl_rv sscanf(cp, %d..%d, from, to) == 2) { + for (i = rlp-rl_defrc ; i rlp-rl_rc ; i++) { + if (rlp-rl_rv[i].r_from == from + rlp-rl_rv[i].r_to == to) { break; } } - if (i == up-u_rc) { - up-u_rv[up-u_rc].r_from = from; - up-u_rv[up-u_rc].r_to = to; - up-u_rc += 1; + if (i == rlp-rl_rc) { + rlp-rl_rv[rlp-rl_rc].r_from = from; + rlp-rl_rv[rlp-rl_rc].r_to = to; + rlp-rl_rc += 1; } } else { warnx(Bad range `%s', cp); @@ -778,7 +798,7 @@ /* read the defaults file */ static void -read_defaults(user_t *up) +read_defaults(def_t *dp) { struct stat st; size_t lineno; @@ -786,6 +806,10 @@ FILE *fp; char *cp; char *s; + user_t *up = dp-user; + group_t *gp = dp-group; + + (void)memset(dp, 0, sizeof(*dp)); memsave(up-u_primgrp, DEF_GROUP, strlen(DEF_GROUP)); memsave(up-u_basedir, DEF_BASEDIR, strlen(DEF_BASEDIR)); @@ -800,6 +824,9 @@ NEWARRAY(range_t, up-u_rv, up-u_rsize, exit(1)); up-u_inactive = DEF_INACTIVE; up-u_expire = DEF_EXPIRE; + gp-g_rsize = 16; + gp-g_defrc = 0; + NEWARRAY(range_t, gp-g_rv, gp-g_rsize, exit(1)); if ((fp = fopen(_PATH_USERMGMT_CONF, r)) == NULL) {
CVS commit: src/usr.sbin/user
Module Name:src Committed By: wiz Date: Thu Dec 31 20:14:19 UTC 2009 Modified Files: src/usr.sbin/user: usermgmt.conf.5 Log Message: Bump date for gid_range. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/user/usermgmt.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/usermgmt.conf.5 diff -u src/usr.sbin/user/usermgmt.conf.5:1.6 src/usr.sbin/user/usermgmt.conf.5:1.7 --- src/usr.sbin/user/usermgmt.conf.5:1.6 Thu Dec 31 19:59:31 2009 +++ src/usr.sbin/user/usermgmt.conf.5 Thu Dec 31 20:14:19 2009 @@ -1,4 +1,4 @@ -.\ $NetBSD: usermgmt.conf.5,v 1.6 2009/12/31 19:59:31 mlelstv Exp $ +.\ $NetBSD: usermgmt.conf.5,v 1.7 2009/12/31 20:14:19 wiz Exp $ .\ .\ Copyright (c) 2002 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -29,7 +29,7 @@ .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd July 18, 2008 +.Dd December 31, 2009 .Dt USERMGMT.CONF 5 .Os .\ turn off hyphenation
CVS commit: src/usr.sbin/user
Module Name:src Committed By: hubertf Date: Thu Oct 15 23:03:02 UTC 2009 Modified Files: src/usr.sbin/user: user.c Log Message: Fix -p: * rm_eo is the first character *after* the match, so no need for a +1 * Blowfish hashes are only 53 chars long, not 54 To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/usr.sbin/user/user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/user/user.c diff -u src/usr.sbin/user/user.c:1.123 src/usr.sbin/user/user.c:1.124 --- src/usr.sbin/user/user.c:1.123 Fri Mar 20 02:53:47 2009 +++ src/usr.sbin/user/user.c Thu Oct 15 23:03:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.123 2009/03/20 02:53:47 mike Exp $ */ +/* $NetBSD: user.c,v 1.124 2009/10/15 23:03:02 hubertf Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -33,7 +33,7 @@ #ifndef lint __COPYRIGHT(@(#) Copyright (c) 1999\ The NetBSD Foundation, Inc. All rights reserved.); -__RCSID($NetBSD: user.c,v 1.123 2009/03/20 02:53:47 mike Exp $); +__RCSID($NetBSD: user.c,v 1.124 2009/10/15 23:03:02 hubertf Exp $); #endif #include sys/types.h @@ -908,7 +908,7 @@ static passwd_type_t passwd_types[] = { { $sha1, 5, 28, \\$[^$]+\\$[^$]+\\$[^$]+\\$(.*), 1 }, /* SHA1 */ - { $2a, 3, 54, \\$[^$]+\\$[^$]+\\$(.*), 1 }, /* Blowfish */ + { $2a, 3, 53, \\$[^$]+\\$[^$]+\\$(.*), 1 }, /* Blowfish */ { $1, 2, 34, NULL,0 }, /* MD5 */ { , 0, DES_Len,NULL,0 }, /* standard DES */ { NULL, (size_t)~0, (size_t)~0, NULL, 0 } @@ -932,7 +932,7 @@ if (regexec(r, newpasswd, 10, matchv, 0) == 0) { regfree(r); return (int)(matchv[pwtp-re_sub].rm_eo - -matchv[pwtp-re_sub].rm_so + 1) == +matchv[pwtp-re_sub].rm_so) == pwtp-length; } regfree(r);