Submitted By: Jim Gifford (patches at jg555 dot com) Date: 2007-09-04 Initial Package Version: 4.0.18.1 Origin: Mailing List Upstream Status: Submitted Description: Fixes Various Issues From Upstream Adds compability for Samba Machine Names Corrects Grammer in Man Files Corrects Useradd issue Fixes useradd -G and -g Fix chpasswd and chgpasswd stack overflow diff -Naur shadow-4.0.18.1.orig/contrib/adduser.c shadow-4.0.18.1/contrib/adduser.c --- shadow-4.0.18.1.orig/contrib/adduser.c 1997-09-29 15:00:49.000000000 -0700 +++ shadow-4.0.18.1/contrib/adduser.c 2007-09-03 17:40:36.000000000 -0700 @@ -169,7 +169,7 @@ if (geteuid () != 0) { printf ("It seems you don't have access to add a new user. Try\n"); - printf ("logging in as root or su root to gain super-user access.\n"); + printf ("logging in as root or su root to gain superuser access.\n"); exit (1); } diff -Naur shadow-4.0.18.1.orig/contrib/groupmems.shar shadow-4.0.18.1/contrib/groupmems.shar --- shadow-4.0.18.1.orig/contrib/groupmems.shar 2000-08-26 11:37:32.000000000 -0700 +++ shadow-4.0.18.1/contrib/groupmems.shar 2007-09-03 17:40:36.000000000 -0700 @@ -211,8 +211,8 @@ #define EXIT_SUCCESS 0 /* success */ #define EXIT_USAGE 1 /* invalid command syntax */ #define EXIT_GROUP_FILE 2 /* group file access problems */ -#define EXIT_NOT_ROOT 3 /* not super user */ -#define EXIT_NOT_EROOT 4 /* not effective super user */ +#define EXIT_NOT_ROOT 3 /* not superuser */ +#define EXIT_NOT_EROOT 4 /* not effective superuser */ #define EXIT_NOT_PRIMARY 5 /* not primary owner of group */ #define EXIT_NOT_MEMBER 6 /* member of group does not exist */ #define EXIT_MEMBER_EXISTS 7 /* member of group already exists */ @@ -481,11 +481,11 @@ [\fB-g\fI group_name \fR] X.SH DESCRIPTION The \fBgroupmems\fR utility allows a user to administer his/her own -group membership list without the requirement of super user privileges. +group membership list without the requirement of superuser privileges. The \fBgroupmems\fR utility is for systems that configure its users to be in their own name sake primary group (i.e., guest / guest). X.P -Only the super user, as administrator, can use \fBgroupmems\fR to alter +Only the superuser, as administrator, can use \fBgroupmems\fR to alter the memberships of other groups. X.IP "\fB-a \fIuser_name\fR" Add a new user to the group membership list. @@ -496,7 +496,7 @@ X.IP "\fB-D\fR" Delete all users from the group membership list. X.IP "\fB-g \fIgroup_name\fR" -The super user can specify which group membership list to modify. +The superuser can specify which group membership list to modify. X.SH SETUP The \fBgroupmems\fR executable should be in mode \fB2770\fR as user \fBroot\fR and in group \fBgroups\fR. The system administrator can add users to diff -Naur shadow-4.0.18.1.orig/libmisc/chkname.c shadow-4.0.18.1/libmisc/chkname.c --- shadow-4.0.18.1.orig/libmisc/chkname.c 2005-08-31 10:24:57.000000000 -0700 +++ shadow-4.0.18.1/libmisc/chkname.c 2007-09-03 17:30:39.000000000 -0700 @@ -18,16 +18,24 @@ static int good_name (const char *name) { /* - * User/group names must match [a-z_][a-z0-9_-]*[$] - */ - if (!*name || !((*name >= 'a' && *name <= 'z') || *name == '_')) + * User/group names must match gnu e-regex: + * [a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]? + * + * as a non-POSIX, extension, allow "$" as the last char for + * sake of Samba 3.x "add machine script" + */ + if (!*name || !((*name >= 'a' && *name <= 'z') + || (*name >= 'A' && *name <= 'Z') + || (*name >= '0' && *name <= '9') + || *name == '_' || *name == '.')) return 0; while (*++name) { - if (!((*name >= 'a' && *name <= 'z') || - (*name >= '0' && *name <= '9') || - *name == '_' || *name == '-' || - (*name == '$' && *(name + 1) == '\0'))) + if (!( (*name >= 'a' && *name <= 'z') + || (*name >= 'A' && *name <= 'Z') + || (*name >= '0' && *name <= '9') + || *name == '_' || *name == '.' || *name == '-' + || (*name == '$' && *(name + 1) == '\0'))) return 0; } @@ -43,10 +51,9 @@ #endif /* - * User names are limited by whatever utmp can - * handle (usually max 8 characters). + * User names are limited by whatever utmp can handle. */ - if (strlen (name) > sizeof (ut.ut_user)) + if (strlen(name) + 1 > sizeof(ut.ut_user)) return 0; return good_name (name); @@ -54,11 +61,13 @@ int check_group_name (const char *name) { - /* - * Arbitrary limit for group names - max 16 - * characters (same as on HP-UX 10). - */ - if (strlen (name) > 16) +#if HAVE_UTMPX_H + struct utmpx ut; +#else + struct utmp ut; +#endif + + if (strlen(name) + 1 > sizeof(ut.ut_user)) return 0; return good_name (name); diff -Naur shadow-4.0.18.1.orig/man/chfn.1.xml shadow-4.0.18.1/man/chfn.1.xml --- shadow-4.0.18.1.orig/man/chfn.1.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/chfn.1.xml 2007-09-03 17:40:36.000000000 -0700 @@ -32,8 +32,8 @@ and similar programs. A normal user may only change the fields for her own account, subject to the restrictions in /etc/login.defs. (The default configuration is to - prevent users from changing their fullname.) The super user may change - any field for any account. Additionally, only the super user may use + prevent users from changing their fullname.) The superuser may change + any field for any account. Additionally, only the superuser may use the option to change the undefined portions of the GECOS field. diff -Naur shadow-4.0.18.1.orig/man/chsh.1.xml shadow-4.0.18.1/man/chsh.1.xml --- shadow-4.0.18.1.orig/man/chsh.1.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/chsh.1.xml 2007-09-03 17:41:09.000000000 -0700 @@ -28,7 +28,7 @@ chsh changes the user login shell. This determines the name of the user's initial login command. A normal user may only - change the login shell for her own account, the super user may change + change the login shell for her own account, the superuser may change the login shell for any account. @@ -72,7 +72,7 @@ The only restriction placed on the login shell is that the command name must be listed in /etc/shells, unless the - invoker is the super-user, and then any value may be added. An + invoker is the superuser, and then any value may be added. An account with a restricted login shell may not change her login shell. For this reason, placing /bin/rsh in /etc/shells is discouraged since accidentally diff -Naur shadow-4.0.18.1.orig/man/groupadd.8 shadow-4.0.18.1/man/groupadd.8 --- shadow-4.0.18.1.orig/man/groupadd.8 2006-07-30 13:53:48.000000000 -0700 +++ shadow-4.0.18.1/man/groupadd.8 2007-09-03 17:30:39.000000000 -0700 @@ -70,15 +70,11 @@ Shadow password suite configuration. .SH "CAVEATS" .PP -Groupnames must begin with a lower case letter or an underscore, and only lower case letters, underscores, dashes, and dollar signs may follow. In regular expression terms: [a\-z_][a\-z0\-9_\-]*[$] -.PP -Groupnames may only be up to 16 characters long. +Groupnames may only be up to 32 characters long. .PP If the groupname already exists in an external group database such as NIS, \fBgroupadd\fR will deny the group creation request. -.PP -Groupnames may only be up to 16 characters long. .SH "EXIT VALUES" .PP The diff -Naur shadow-4.0.18.1.orig/man/groupadd.8.xml shadow-4.0.18.1/man/groupadd.8.xml --- shadow-4.0.18.1.orig/man/groupadd.8.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/groupadd.8.xml 2007-09-03 17:37:35.000000000 -0700 @@ -29,7 +29,7 @@ DESCRIPTION The groupadd command creates a new group - account using the values specified on the command line and the default + account using the values specified on the command line plus the default values from the system. The new group will be entered into the system files as needed. @@ -47,9 +47,11 @@ - This option causes to just exit with success status if the - specified group already exists. With , if - specified GID already exists, other (unique) GID is chosen (i.e. + This option causes the command to simply exit with success + status if the + specified group already exists. When used with + , and the + specified GID already exists, another (unique) GID is chosen (i.e. is turned off). @@ -101,7 +103,7 @@ - This option permits to add group with non-unique GID. + This option permits to add a group with a non-unique GID. @@ -138,16 +140,12 @@ only lower case letters, underscores, dashes, and dollar signs may follow. In regular expression terms: [a-z_][a-z0-9_-]*[$] - Groupnames may only be up to 16 characters long. - If the groupname already exists in an external group database such as NIS, groupadd will deny the group creation request. - Groupnames may only be up to 16 characters long. - diff -Naur shadow-4.0.18.1.orig/man/groupmems.8.xml shadow-4.0.18.1/man/groupmems.8.xml --- shadow-4.0.18.1.orig/man/groupmems.8.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/groupmems.8.xml 2007-09-03 17:41:54.000000000 -0700 @@ -27,13 +27,13 @@ DESCRIPTION The groupmems utility allows a user to administer - his/her own group membership list without the requirement of super - user privileges. The groupmems utility is for + his/her own group membership list without the requirement of + superuser privileges. The groupmems utility is for systems that configure its users to be in their own name sake primary group (i.e., guest / guest). - Only the super user, as administrator, can use + Only the superuser, as administrator, can use groupmems to alter the memberships of other groups. @@ -66,7 +66,7 @@ group_name - The super user can specify which group membership + The superuser can specify which group membership list to modify. diff -Naur shadow-4.0.18.1.orig/man/groupmod.8.xml shadow-4.0.18.1/man/groupmod.8.xml --- shadow-4.0.18.1.orig/man/groupmod.8.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/groupmod.8.xml 2007-09-03 17:37:35.000000000 -0700 @@ -43,12 +43,14 @@ - Specify the new group ID for the GROUP. - The numerical value of the GID must be + The group ID of the given GROUP will be + changed to GID. + The value of GID must be a non-negative decimal integer. This value must be unique, unless the option is used. Values between 0 and 999 - are typically reserved for system groups. Any files which the old - group ID is the file group ID must have the file group ID changed + are typically reserved for system groups. Any files that have + the old group ID and must continue to belong to + GROUP, must have their group ID changed manually. @@ -77,8 +79,8 @@ - When used with the option allow to change the - group GID to non-unique value. + When used with the option, allow to change the + group GID to a non-unique value. diff -Naur shadow-4.0.18.1.orig/man/login.1.xml shadow-4.0.18.1/man/login.1.xml --- shadow-4.0.18.1.orig/man/login.1.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/login.1.xml 2007-09-03 17:37:35.000000000 -0700 @@ -184,11 +184,11 @@ - As any program, login appearance could be faked. - If non-trusted users have a physical access to the machine, an + As with any program, login's appearance can be faked. + If non-trusted users have physical access to a machine, an attacker could use this to obtain the password of the next person - sitting in front of the machine. Under Linux, the SAK mecanism can be - used by users to initiate of a trusted path and prevent this kind of + coming to sit in front of the machine. Under Linux, the SAK mechanism can be + used by users to initiate a trusted path and prevent this kind of attack. diff -Naur shadow-4.0.18.1.orig/man/newusers.8.xml shadow-4.0.18.1/man/newusers.8.xml --- shadow-4.0.18.1.orig/man/newusers.8.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/newusers.8.xml 2007-09-03 17:39:26.000000000 -0700 @@ -60,10 +60,11 @@ - This field may be the name of an existing group, in which case - the named user will be added as a member. If a non-existent - numerical group is given, a new group will be created having - this number. + This field must contain the name (or number) of a group. The user + will be added as a member to this group. When a non-existent + group name or number is specified, a new group will be created. + In the case of a non-existent group number, both the name and the + number of the new group will be this number. @@ -73,8 +74,8 @@ - This field will be checked for existence as a directory and a - new directory with the same name will be created if it does not + This field will be checked for existence as a directory, and a + new directory with this name will be created if it does not already exist. The ownership of the directory will be set to be that of the user being created or updated. diff -Naur shadow-4.0.18.1.orig/man/passwd.1.xml shadow-4.0.18.1/man/passwd.1.xml --- shadow-4.0.18.1.orig/man/passwd.1.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/passwd.1.xml 2007-09-03 17:42:21.000000000 -0700 @@ -28,7 +28,7 @@ passwd changes passwords for user accounts. A normal user may only change the password for his/her own account, while - the super user may change the password for any account. + the superuser may change the password for any account. passwd also changes account information, such as the full name of the user, the user's login shell, or his/her password expiry date and interval. @@ -40,7 +40,7 @@ The user is first prompted for his/her old password, if one is present. This password is then encrypted and compared against the stored password. The user has only one chance to enter the correct - password. The super user is permitted to bypass this step so that + password. The superuser is permitted to bypass this step so that forgotten passwords may be changed. diff -Naur shadow-4.0.18.1.orig/man/shadow.3.xml shadow-4.0.18.1/man/shadow.3.xml --- shadow-4.0.18.1.orig/man/shadow.3.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/shadow.3.xml 2007-09-03 17:40:36.000000000 -0700 @@ -163,7 +163,7 @@ CAVEATS - These routines may only be used by the super user as access to the + These routines may only be used by the superuser as access to the shadow password file is restricted. diff -Naur shadow-4.0.18.1.orig/man/su.1.xml shadow-4.0.18.1/man/su.1.xml --- shadow-4.0.18.1.orig/man/su.1.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/su.1.xml 2007-09-03 17:40:36.000000000 -0700 @@ -8,7 +8,7 @@ su - change user ID or become super-user + change user ID or become superuser @@ -30,7 +30,7 @@ su is used to become another user during a login session. Invoked without a , su defaults to - becoming the super user. The optional argument may + becoming the superuser. The optional argument may be used to provide an environment similar to what the user would expect had the user logged in directly. @@ -58,7 +58,7 @@ The current environment is passed to the new shell. The value of $PATH is reset to /bin:/usr/bin for normal users, or /sbin:/bin:/usr/sbin:/usr/bin - for the super user. This may be changed with the + for the superuser. This may be changed with the ENV_PATH and ENV_SUPATH definitions in /etc/login.defs. @@ -78,7 +78,7 @@ , - SHELL + COMMAND @@ -112,10 +112,10 @@ The shell that will be invoked. - The invoked shell is choosen among (higest priority first): + The invoked shell is chosen from (highest priority first): - The shell specified with --shell + The shell specified with --shell. @@ -141,10 +141,10 @@ If the target user has a restricted shell (i.e. the shell field of this user's entry in /etc/passwd is not - specified in /etc/shell), then the + listed in /etc/shell), then the option or the $SHELL - environment variable won't be taken into account unless - su is called by the root. + environment variable won't be taken into account, unless + su is called by root. diff -Naur shadow-4.0.18.1.orig/man/useradd.8 shadow-4.0.18.1/man/useradd.8 --- shadow-4.0.18.1.orig/man/useradd.8 2006-07-30 13:54:26.000000000 -0700 +++ shadow-4.0.18.1/man/useradd.8 2007-09-03 17:30:39.000000000 -0700 @@ -168,8 +168,6 @@ Similarly, if the username already exists in an external user database such as NIS, \fBuseradd\fR will deny the user account creation request. -.PP -Usernames must begin with a lower case letter or an underscore, and only lower case letters, underscores, dashes, and dollar signs may follow. In regular expression terms: [a\-z_][a\-z0\-9_\-]*[$] .SH "FILES" .TP 3n \fI/etc/passwd\fR diff -Naur shadow-4.0.18.1.orig/man/useradd.8.xml shadow-4.0.18.1/man/useradd.8.xml --- shadow-4.0.18.1.orig/man/useradd.8.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/useradd.8.xml 2007-09-03 17:37:35.000000000 -0700 @@ -36,8 +36,9 @@ When invoked without the option, the useradd command creates a new user account using - the values specified on the command line and the default values from - the system. Depending on command line options, the useradd command + the values specified on the command line plus the default values from + the system. Depending on command line options, the + useradd command will update system files and may also create the new user's home directory and copy initial files. @@ -78,6 +79,16 @@ + + + + + See below, the subsection "Changing the default values". + + + + + , HOME_DIR @@ -256,10 +267,11 @@ Changing the default values - When invoked with the option, - useradd will either display the current default - values, or update the default values from the command line. The - valid options are + When invoked with only the option, + useradd will display the current default values. + When invoked with plus other options, + useradd will update the default values for the + specified options. Valid default-changing options are: @@ -269,10 +281,10 @@ - The initial path prefix for a new user's home directory. The + The path prefix for a new user's home directory. The user's name will be affixed to the end of - HOME_DIR to create the new - directory name if the option is not used + BASE_DIR to form the new user's + home directory name, if the option is not used when creating a new account. @@ -318,17 +330,12 @@ - The name of the new user's login shell. The named program will - be used for all future new user accounts. + The name of a new user's login shell. - - If no options are specified, useradd displays the - current default values. - diff -Naur shadow-4.0.18.1.orig/man/userdel.8.xml shadow-4.0.18.1/man/userdel.8.xml --- shadow-4.0.18.1.orig/man/userdel.8.xml 2006-07-23 22:48:36.000000000 -0700 +++ shadow-4.0.18.1/man/userdel.8.xml 2007-09-03 17:37:35.000000000 -0700 @@ -24,8 +24,8 @@ DESCRIPTION The userdel command modifies the system account - files, deleting all entries that refer to login_name. The named user must exist. + files, deleting all entries that refer to the user name LOGIN. The named user must exist. @@ -41,9 +41,10 @@ - This option forces the removal of the user, even if she is still + This option forces the removal of the user account, even if the + user is still logged in. It also forces userdel to remove - the user's home directory or her mail spool, even if another + the user's home directory and mail spool, even if another user uses the same home directory or if the mail spool is not owned by the specified user. If USERGROUPS_ENAB is defined to -g option. If the user is currently a member of a group which is not listed, the user will be removed from the group. This - behaviour can be changed via option, which - appends user to the current supplementary group list. + behaviour can be changed via the option, which + appends the user to the current supplementary group list. @@ -143,7 +143,7 @@ remap='I'>LOGIN to NEW_LOGIN. Nothing else is changed. In particular, the user's home directory name should probably be - changed to reflect the new login name. + changed manually to reflect the new login name. diff -Naur shadow-4.0.18.1.orig/src/chgpasswd.c shadow-4.0.18.1/src/chgpasswd.c --- shadow-4.0.18.1.orig/src/chgpasswd.c 2006-06-20 13:00:04.000000000 -0700 +++ shadow-4.0.18.1/src/chgpasswd.c 2007-09-03 18:04:15.000000000 -0700 @@ -243,9 +243,13 @@ newpwd = cp; if (!eflg) { if (md5flg) { - char salt[12] = "$1$"; + char tmp[12]; + char salt[15] = "\0"; - strcat (salt, crypt_make_salt ()); + strcpy( tmp, crypt_make_salt ()); + if( !strncmp( tmp, "$1$", 3) ) + strcat( salt, "$1$"); + strcat( salt, tmp); cp = pw_encrypt (newpwd, salt); } else cp = pw_encrypt (newpwd, crypt_make_salt ()); diff -Naur shadow-4.0.18.1.orig/src/chpasswd.c shadow-4.0.18.1/src/chpasswd.c --- shadow-4.0.18.1.orig/src/chpasswd.c 2006-06-24 03:18:55.000000000 -0700 +++ shadow-4.0.18.1/src/chpasswd.c 2007-09-03 18:04:15.000000000 -0700 @@ -239,9 +239,13 @@ newpwd = cp; if (!eflg) { if (md5flg) { - char salt[12] = "$1$"; + char tmp[12]; + char salt[15] = "\0"; - strcat (salt, crypt_make_salt ()); + strcpy( tmp, crypt_make_salt ()); + if( !strncmp( tmp, "$1$", 3) ) + strcat( salt, "$1$"); + strcat( salt, tmp); cp = pw_encrypt (newpwd, salt); } else cp = pw_encrypt (newpwd, crypt_make_salt ()); diff -Naur shadow-4.0.18.1.orig/src/groupmems.c shadow-4.0.18.1/src/groupmems.c --- shadow-4.0.18.1.orig/src/groupmems.c 2006-08-03 02:50:01.000000000 -0700 +++ shadow-4.0.18.1/src/groupmems.c 2007-09-03 17:40:36.000000000 -0700 @@ -47,8 +47,8 @@ #define EXIT_SUCCESS 0 /* success */ #define EXIT_USAGE 1 /* invalid command syntax */ #define EXIT_GROUP_FILE 2 /* group file access problems */ -#define EXIT_NOT_ROOT 3 /* not super user */ -#define EXIT_NOT_EROOT 4 /* not effective super user */ +#define EXIT_NOT_ROOT 3 /* not superuser */ +#define EXIT_NOT_EROOT 4 /* not effective superuser */ #define EXIT_NOT_PRIMARY 5 /* not primary owner of group */ #define EXIT_NOT_MEMBER 6 /* member of group does not exist */ #define EXIT_MEMBER_EXISTS 7 /* member of group already exists */ diff -Naur shadow-4.0.18.1.orig/src/useradd.c shadow-4.0.18.1/src/useradd.c --- shadow-4.0.18.1.orig/src/useradd.c 2006-07-28 10:42:48.000000000 -0700 +++ shadow-4.0.18.1/src/useradd.c 2007-09-03 18:06:19.000000000 -0700 @@ -203,13 +203,14 @@ long gid; char *errptr; + struct group* grp = getgrnam (grname); + if (grp) + return grp; + gid = strtol (grname, &errptr, 10); - if (*errptr || errno == ERANGE || gid < 0) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), Prog, grname); - exit (E_BAD_ARG); - } - return getgrnam (grname); + if (*grname != '\0' && *errptr == '\0' && errno != ERANGE && gid >= 0) + return getgrgid (gid); + return getgrgid (gid); } static long get_number (const char *numstr) diff -Naur shadow-4.0.18.1.orig/src/usermod.c shadow-4.0.18.1/src/usermod.c --- shadow-4.0.18.1.orig/src/usermod.c 2006-07-28 10:42:48.000000000 -0700 +++ shadow-4.0.18.1/src/usermod.c 2007-09-03 18:07:00.000000000 -0700 @@ -165,13 +165,14 @@ long val; char *errptr; + struct group* grp = getgrnam (grname); + if (grp) + return grp; + val = strtol (grname, &errptr, 10); - if (*errptr || errno == ERANGE || val < 0) { - fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, - grname); - exit (E_BAD_ARG); - } - return getgrnam (grname); + if (*grname != '\0' && *errptr == '\0' && errno != ERANGE && val >= 0) + return getgrgid (val); + return getgrgid (val); } /* @@ -908,7 +909,7 @@ */ int c; static struct option long_options[] = { - {"append", required_argument, NULL, 'a'}, + {"append", no_argument, NULL, 'a'}, {"comment", required_argument, NULL, 'c'}, {"home", required_argument, NULL, 'd'}, {"expiredate", required_argument, NULL, 'e'},