From 54fd4a00a17d1387fbcffa8f8f30ad1224ba30ee Mon Sep 17 00:00:00 2001 From: Peter Vrabec Date: Nov 29 2007 15:10:29 +0000 Subject: do not create mail spool entries for system accounts (#402351) --- diff --git a/shadow-4.0.17-redhat.patch b/shadow-4.0.17-redhat.patch index 84280c6..455af08 100644 --- a/shadow-4.0.17-redhat.patch +++ b/shadow-4.0.17-redhat.patch @@ -1,32 +1,17 @@ ---- shadow-4.0.18.1/man/groupadd.8.redhat 2006-07-30 22:53:48.000000000 +0200 -+++ shadow-4.0.18.1/man/groupadd.8 2006-12-06 16:29:01.000000000 +0100 -@@ -14,7 +14,7 @@ - groupadd \- create a new group - .SH "SYNOPSIS" - .HP 9 --\fBgroupadd\fR [\-g\ \fIGID\fR\ [\-o]] [\-f] [\-K\ \fIKEY\fR=\fIVALUE\fR] \fIgroup\fR -+\fBgroupadd\fR [\-g\ \fIgid\fR\ [\-o]] [\-r] [\-f] [\-K\ \fIKEY\fR=\fIVALUE\fR] \fIgroup\fR - .SH "DESCRIPTION" +--- shadow-4.0.18.1/man/newusers.8.redhat 2006-07-30 22:54:08.000000000 +0200 ++++ shadow-4.0.18.1/man/newusers.8 2007-11-29 15:08:49.000000000 +0100 +@@ -35,6 +35,8 @@ This field may be the name of an existin + 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 already exist. The ownership of the directory will be set to be that of the user being created or updated. .PP - The -@@ -32,10 +32,13 @@ - \fB\-g\fR - is turned off). - .TP 3n -+\fB-r\fR -+This flag instructs \fBgroupadd\fR to add a system account. The first available \fIgid\fR lower than 499 will be automatically selected unless the \fB-g\fR option is also given on the command line. This is an option added by Red Hat. -+.TP 3n - \fB\-g\fR \fIGID\fR - The numerical value of the group's ID. This value must be unique, unless the - \fB\-o\fR --option is used. The value must be non\-negative. The default is to use the smallest ID value greater than 999 and greater than every other group. Values between 0 and 999 are typically reserved for system accounts. -+option is used. The value must be non\-negative. The default is to use the smallest ID value greater than 500 and greater than every other group. Values between 0 and 499 are typically reserved for system accounts. - .TP 3n - \fB\-h\fR, \fB\-\-help\fR - Display help message and exit. + This command is intended to be used in a large system environment where many accounts are updated at a single time. ++.PP ++Default encryption algorithm is DES, but this setting can be changed in \fI/etc/login.defs\fR. Red Hat uses MD5 to encrypt passwords by default. + .SH "CAVEATS" + .PP + The input file must be protected since it contains unencrypted passwords. --- shadow-4.0.18.1/man/useradd.8.redhat 2006-07-30 22:54:26.000000000 +0200 -+++ shadow-4.0.18.1/man/useradd.8 2006-12-06 16:29:01.000000000 +0100 -@@ -25,7 +25,7 @@ ++++ shadow-4.0.18.1/man/useradd.8 2007-11-29 15:08:49.000000000 +0100 +@@ -25,7 +25,7 @@ When invoked without the \fB\-D\fR option, the \fBuseradd\fR @@ -35,7 +20,7 @@ .SH "OPTIONS" .PP The options which apply to the -@@ -65,7 +65,7 @@ +@@ -65,7 +65,7 @@ The date on which the user account will The number of days after a password expires until the account is permanently disabled. A value of 0 disables the account as soon as the password has expired, and a value of \-1 disables the feature. The default value is \-1. .TP 3n \fB\-g\fR, \fB\-\-gid\fR \fIGROUP\fR @@ -44,7 +29,7 @@ \fI/etc/default/useradd\fR. .TP 3n \fB\-G\fR, \fB\-\-groups\fR \fIGROUP1\fR[\fI,GROUP2,...\fR[\fI,GROUPN\fR]]] -@@ -76,6 +76,9 @@ +@@ -76,6 +76,9 @@ option. The default is for the user to b \fB\-h\fR, \fB\-\-help\fR Display help message and exit. .TP 3n @@ -54,7 +39,7 @@ \fB\-m\fR, \fB\-\-create\-home\fR The user's home directory will be created if it does not exist. The files contained in \fISKEL_DIR\fR -@@ -93,6 +96,9 @@ +@@ -93,6 +96,9 @@ option is only valid in conjunction with \fB\-m\fR option. The default is to not create the directory and to not copy any files. .TP 3n @@ -64,7 +49,7 @@ \fB\-K\fR, \fB\-\-key\fR \fIKEY\fR=\fIVALUE\fR Overrides /etc/login.defs defaults (UID_MIN, UID_MAX, UMASK, PASS_MAX_DAYS and others). -@@ -118,6 +124,9 @@ +@@ -118,6 +124,9 @@ Allow the creation of a user account wit The encrypted password, as returned by \fBcrypt\fR(3). The default is to disable the account. .TP 3n @@ -74,7 +59,7 @@ \fB\-s\fR, \fB\-\-shell\fR \fISHELL\fR The name of the user's login shell. The default is to leave this field blank, which causes the system to select the default login shell. .TP 3n -@@ -161,6 +170,8 @@ +@@ -161,6 +170,8 @@ displays the current default values. The system administrator is responsible for placing the default user files in the \fI/etc/skel/\fR directory. @@ -83,7 +68,7 @@ .SH "CAVEATS" .PP You may not add a user to a NIS group. This must be performed on the NIS server. -@@ -181,6 +192,9 @@ +@@ -181,6 +192,9 @@ Secure user account information. \fI/etc/group\fR Group account information. .TP 3n @@ -93,9 +78,35 @@ \fI/etc/default/useradd\fR Default values for account creation. .TP 3n +--- shadow-4.0.18.1/man/groupadd.8.redhat 2006-07-30 22:53:48.000000000 +0200 ++++ shadow-4.0.18.1/man/groupadd.8 2007-11-29 15:08:49.000000000 +0100 +@@ -14,7 +14,7 @@ + groupadd \- create a new group + .SH "SYNOPSIS" + .HP 9 +-\fBgroupadd\fR [\-g\ \fIGID\fR\ [\-o]] [\-f] [\-K\ \fIKEY\fR=\fIVALUE\fR] \fIgroup\fR ++\fBgroupadd\fR [\-g\ \fIgid\fR\ [\-o]] [\-r] [\-f] [\-K\ \fIKEY\fR=\fIVALUE\fR] \fIgroup\fR + .SH "DESCRIPTION" + .PP + The +@@ -32,10 +32,13 @@ This option causes to just exit with suc + \fB\-g\fR + is turned off). + .TP 3n ++\fB-r\fR ++This flag instructs \fBgroupadd\fR to add a system account. The first available \fIgid\fR lower than 499 will be automatically selected unless the \fB-g\fR option is also given on the command line. This is an option added by Red Hat. ++.TP 3n + \fB\-g\fR \fIGID\fR + The numerical value of the group's ID. This value must be unique, unless the + \fB\-o\fR +-option is used. The value must be non\-negative. The default is to use the smallest ID value greater than 999 and greater than every other group. Values between 0 and 999 are typically reserved for system accounts. ++option is used. The value must be non\-negative. The default is to use the smallest ID value greater than 500 and greater than every other group. Values between 0 and 499 are typically reserved for system accounts. + .TP 3n + \fB\-h\fR, \fB\-\-help\fR + Display help message and exit. --- shadow-4.0.18.1/man/chpasswd.8.redhat 2006-07-30 22:53:40.000000000 +0200 -+++ shadow-4.0.18.1/man/chpasswd.8 2006-12-06 16:24:59.000000000 +0100 -@@ -24,7 +24,7 @@ ++++ shadow-4.0.18.1/man/chpasswd.8 2007-11-29 15:08:49.000000000 +0100 +@@ -24,7 +24,7 @@ reads a list of user name and password p \fIuser_name\fR:\fIpassword\fR .PP @@ -104,19 +115,64 @@ .PP This command is intended to be used in a large system environment where many accounts are created at a single time. .SH "OPTIONS" ---- shadow-4.0.18.1/man/newusers.8.redhat 2006-07-30 22:54:08.000000000 +0200 -+++ shadow-4.0.18.1/man/newusers.8 2006-12-06 16:24:59.000000000 +0100 -@@ -35,6 +35,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 already exist. The ownership of the directory will be set to be that of the user being created or updated. - .PP - This command is intended to be used in a large system environment where many accounts are updated at a single time. -+.PP -+Default encryption algorithm is DES, but this setting can be changed in \fI/etc/login.defs\fR. Red Hat uses MD5 to encrypt passwords by default. - .SH "CAVEATS" - .PP - The input file must be protected since it contains unencrypted passwords. +--- shadow-4.0.18.1/src/groupadd.c.redhat 2006-07-28 19:38:52.000000000 +0200 ++++ shadow-4.0.18.1/src/groupadd.c 2007-11-29 15:08:49.000000000 +0100 +@@ -74,6 +74,7 @@ static char *Prog; + static int oflg = 0; /* permit non-unique group ID to be specified with -g */ + static int gflg = 0; /* ID value for the new group */ + static int fflg = 0; /* if group already exists, do nothing and exit(0) */ ++static int rflg = 0; /* for adding system accounts (Red Hat) */ + + /* local function prototypes */ + static void usage (void); +@@ -100,6 +101,7 @@ static void usage (void) + "Options:\n" + " -f, --force force exit with success status if the specified\n" + " group already exists\n" ++ " -r, create system account\n" + " -g, --gid GID use GID for the new group\n" + " -h, --help display this help message and exit\n" + " -K, --key KEY=VALUE overrides /etc/login.defs defaults\n" +@@ -198,8 +200,13 @@ static void find_new_gid (void) + const struct group *grp; + gid_t gid_min, gid_max; + +- gid_min = getdef_unum ("GID_MIN", 1000); +- gid_max = getdef_unum ("GID_MAX", 60000); ++ if (!rflg) { ++ gid_min = getdef_unum ("GID_MIN", 500); ++ gid_max = getdef_unum ("GID_MAX", 60000); ++ } else { ++ gid_min = 1; ++ gid_max = getdef_unum ("GID_MIN", 500) - 1; ++ } + + /* + * Start with some GID value if the user didn't provide us with +@@ -430,7 +437,7 @@ int main (int argc, char **argv) + }; + + while ((c = +- getopt_long (argc, argv, "fg:hK:o", long_options, ++ getopt_long (argc, argv, "frg:hK:o", long_options, + &option_index)) != -1) { + switch (c) { + case 'f': +@@ -443,6 +450,12 @@ int main (int argc, char **argv) + */ + fflg++; + break; ++ case 'r': ++ /* ++ * create a system group ++ */ ++ rflg++; ++ break; + case 'g': + gflg++; + group_id = get_gid (optarg); --- shadow-4.0.18.1/src/useradd.c.redhat 2006-07-28 19:42:48.000000000 +0200 -+++ shadow-4.0.18.1/src/useradd.c 2006-12-06 16:29:01.000000000 +0100 ++++ shadow-4.0.18.1/src/useradd.c 2007-11-29 15:44:39.000000000 +0100 @@ -81,7 +81,7 @@ static gid_t def_group = 100; static const char *def_gname = "other"; @@ -126,7 +182,7 @@ static const char *def_template = SKEL_DIR; static const char *def_create_mail_spool = "no"; -@@ -93,7 +93,7 @@ +@@ -93,7 +93,7 @@ static char def_file[] = USER_DEFAULTS_F #define VALID(s) (strcspn (s, ":\n") == strlen (s)) static const char *user_name = ""; @@ -135,7 +191,7 @@ static uid_t user_id; static gid_t user_gid; static const char *user_comment = ""; -@@ -124,8 +124,10 @@ +@@ -124,8 +124,10 @@ static int Gflg = 0, /* secondary group set for new account */ kflg = 0, /* specify a directory to fill new user directory */ mflg = 0, /* create user's home directory if it doesn't exist */ @@ -147,7 +203,7 @@ sflg = 0, /* shell program for new account */ uflg = 0; /* specify user ID for new account */ -@@ -633,6 +635,8 @@ +@@ -633,6 +635,8 @@ static void usage (void) " -K, --key KEY=VALUE overrides /etc/login.defs defaults\n" " -m, --create-home create home directory for the new user\n" " account\n" @@ -156,7 +212,7 @@ " -o, --non-unique allow create user with duplicate\n" " (non-unique) UID\n" " -p, --password PASSWORD use encrypted password for the new user\n" -@@ -685,11 +689,20 @@ +@@ -685,11 +689,20 @@ static void new_spent (struct spwd *spen spent->sp_namp = (char *) user_name; spent->sp_pwdp = (char *) user_pass; spent->sp_lstchg = time ((time_t *) 0) / SCALE; @@ -182,7 +238,7 @@ spent->sp_flag = -1; } -@@ -837,8 +850,14 @@ +@@ -837,8 +850,14 @@ static void find_new_uid (void) const struct passwd *pwd; uid_t uid_min, uid_max; @@ -199,7 +255,7 @@ /* * Start with some UID value if the user didn't provide us with -@@ -868,7 +887,7 @@ +@@ -868,7 +887,7 @@ static void find_new_uid (void) #endif exit (E_NAME_IN_USE); } @@ -208,7 +264,7 @@ fprintf (stderr, _("%s: UID %u is not unique\n"), Prog, (unsigned int) user_id); #ifdef WITH_AUDIT -@@ -923,8 +942,13 @@ +@@ -923,8 +942,13 @@ static void find_new_gid () const struct group *grp; gid_t gid_min, gid_max; @@ -224,7 +280,7 @@ /* * Start with some GID value if the user didn't provide us with -@@ -1022,7 +1046,7 @@ +@@ -1022,7 +1046,7 @@ static void process_flags (int argc, cha {NULL, 0, NULL, '\0'} }; while ((c = @@ -233,7 +289,7 @@ long_options, NULL)) != -1) { switch (c) { case 'b': -@@ -1194,6 +1218,15 @@ +@@ -1194,6 +1218,15 @@ static void process_flags (int argc, cha user_id = get_uid (optarg); uflg++; break; @@ -249,7 +305,7 @@ default: usage (); } -@@ -1201,6 +1234,9 @@ +@@ -1201,6 +1234,9 @@ static void process_flags (int argc, cha } } @@ -259,7 +315,7 @@ /* * Certain options are only valid in combination with others. * Check it here so that they can be specified in any order. -@@ -1706,6 +1742,14 @@ +@@ -1706,6 +1742,14 @@ int main (int argc, char **argv) } #endif /* USE_PAM */ @@ -274,7 +330,7 @@ /* * See if we are messing with the defaults file, or creating * a new user. -@@ -1736,7 +1780,7 @@ +@@ -1736,7 +1780,7 @@ int main (int argc, char **argv) * to that group, use useradd -g username username. * --bero */ @@ -283,7 +339,7 @@ if (getgrnam (user_name)) { fprintf (stderr, _ -@@ -1787,25 +1831,18 @@ +@@ -1787,27 +1831,22 @@ int main (int argc, char **argv) ("%s: warning: the home directory already exists.\n" "Not copying any file from skel directory into it.\n"), Prog); @@ -306,6 +362,8 @@ - ("%s: warning: CREATE_HOME not supported, please use -m instead.\n"), - Prog); } +- +- create_mail (); + /* Warning removed to protect the innocent. */ + /* + * The whole idea about breaking some stupid scripts by creating a new @@ -317,62 +375,10 @@ + * behavior and they will break, but they were broken anyway to begin + * with --gafton + */ ++ ++ /* Do not create mail directory for system accounts */ ++ if( !rflg ) ++ create_mail (); - create_mail (); - ---- shadow-4.0.18.1/src/groupadd.c.redhat 2006-07-28 19:38:52.000000000 +0200 -+++ shadow-4.0.18.1/src/groupadd.c 2006-12-06 16:29:01.000000000 +0100 -@@ -74,6 +74,7 @@ - static int oflg = 0; /* permit non-unique group ID to be specified with -g */ - static int gflg = 0; /* ID value for the new group */ - static int fflg = 0; /* if group already exists, do nothing and exit(0) */ -+static int rflg = 0; /* for adding system accounts (Red Hat) */ - - /* local function prototypes */ - static void usage (void); -@@ -100,6 +101,7 @@ - "Options:\n" - " -f, --force force exit with success status if the specified\n" - " group already exists\n" -+ " -r, create system account\n" - " -g, --gid GID use GID for the new group\n" - " -h, --help display this help message and exit\n" - " -K, --key KEY=VALUE overrides /etc/login.defs defaults\n" -@@ -198,8 +200,13 @@ - const struct group *grp; - gid_t gid_min, gid_max; - -- gid_min = getdef_unum ("GID_MIN", 1000); -- gid_max = getdef_unum ("GID_MAX", 60000); -+ if (!rflg) { -+ gid_min = getdef_unum ("GID_MIN", 500); -+ gid_max = getdef_unum ("GID_MAX", 60000); -+ } else { -+ gid_min = 1; -+ gid_max = getdef_unum ("GID_MIN", 500) - 1; -+ } - - /* - * Start with some GID value if the user didn't provide us with -@@ -430,7 +437,7 @@ - }; - - while ((c = -- getopt_long (argc, argv, "fg:hK:o", long_options, -+ getopt_long (argc, argv, "frg:hK:o", long_options, - &option_index)) != -1) { - switch (c) { - case 'f': -@@ -443,6 +450,12 @@ - */ - fflg++; - break; -+ case 'r': -+ /* -+ * create a system group -+ */ -+ rflg++; -+ break; - case 'g': - gflg++; - group_id = get_gid (optarg); + nscd_flush_cache ("passwd"); + nscd_flush_cache ("group"); diff --git a/shadow-4.0.17-useradd.patch b/shadow-4.0.17-useradd.patch index a800bea..2e61faa 100644 --- a/shadow-4.0.17-useradd.patch +++ b/shadow-4.0.17-useradd.patch @@ -1,5 +1,15 @@ ---- /dev/null 2007-01-16 10:10:52.644263000 +0100 -+++ shadow-4.0.17/libmisc/system.c 2007-01-16 18:24:34.000000000 +0100 +--- shadow-4.0.18.1/libmisc/Makefile.am.useradd 2005-09-05 18:21:37.000000000 +0200 ++++ shadow-4.0.18.1/libmisc/Makefile.am 2007-11-29 15:47:39.000000000 +0100 +@@ -41,6 +41,7 @@ libmisc_a_SOURCES = \ + setugid.c \ + setupenv.c \ + shell.c \ ++ system.c \ + strtoday.c \ + sub.c \ + sulog.c \ +--- shadow-4.0.18.1/libmisc/system.c.useradd 2007-11-29 15:47:39.000000000 +0100 ++++ shadow-4.0.18.1/libmisc/system.c 2007-11-29 15:47:39.000000000 +0100 @@ -0,0 +1,37 @@ +#include + @@ -38,19 +48,9 @@ + exit (-1); +} + ---- shadow-4.0.17/libmisc/Makefile.am.useradd 2005-09-05 18:21:37.000000000 +0200 -+++ shadow-4.0.17/libmisc/Makefile.am 2007-01-16 18:24:34.000000000 +0100 -@@ -41,6 +41,7 @@ - setugid.c \ - setupenv.c \ - shell.c \ -+ system.c \ - strtoday.c \ - sub.c \ - sulog.c \ ---- shadow-4.0.17/libmisc/copydir.c.useradd 2006-07-10 06:35:56.000000000 +0200 -+++ shadow-4.0.17/libmisc/copydir.c 2007-01-16 18:24:34.000000000 +0100 -@@ -54,7 +54,7 @@ +--- shadow-4.0.18.1/libmisc/copydir.c.useradd 2006-07-10 06:35:56.000000000 +0200 ++++ shadow-4.0.18.1/libmisc/copydir.c 2007-11-29 15:47:39.000000000 +0100 +@@ -54,7 +54,7 @@ struct link_name { static struct link_name *links; #ifdef WITH_SELINUX @@ -59,8 +59,8 @@ { security_context_t scontext = NULL; ---- shadow-4.0.17/man/usermod.8.xml.useradd 2006-06-16 18:11:04.000000000 +0200 -+++ shadow-4.0.17/man/usermod.8.xml 2007-01-16 18:24:34.000000000 +0100 +--- shadow-4.0.18.1/man/usermod.8.xml.useradd 2006-07-24 07:48:36.000000000 +0200 ++++ shadow-4.0.18.1/man/usermod.8.xml 2007-11-29 15:47:39.000000000 +0100 @@ -226,6 +226,19 @@ @@ -81,8 +81,33 @@ ---- shadow-4.0.17/man/useradd.8.xml.useradd 2006-06-16 18:11:04.000000000 +0200 -+++ shadow-4.0.17/man/useradd.8.xml 2007-01-16 18:24:34.000000000 +0100 +--- shadow-4.0.18.1/man/usermod.8.useradd 2006-07-30 22:54:28.000000000 +0200 ++++ shadow-4.0.18.1/man/usermod.8 2007-11-29 15:47:39.000000000 +0100 +@@ -92,6 +92,10 @@ Unlock a user's password. This removes t + \fB\-p\fR + or + \fB\-L\fR. ++.TP 3n ++\fB\-Z\fR, \fB\-\-selinux-user\fR \fISEUSER\fR ++The SELinux user for the user's login. The default is to leave this field blank, which causes the system to select the default SELinux user. ++ + .SH "CAVEATS" + .PP + +--- shadow-4.0.18.1/man/useradd.8.useradd 2007-11-29 15:46:24.000000000 +0100 ++++ shadow-4.0.18.1/man/useradd.8 2007-11-29 15:47:39.000000000 +0100 +@@ -137,6 +137,9 @@ The name of the user's login shell. The + The numerical value of the user's ID. This value must be unique, unless the + \fB\-o\fR + option is used. The value must be non\-negative. The default is to use the smallest ID value greater than 999 and greater than every other user. Values between 0 and 999 are typically reserved for system accounts. ++.TP 3n ++\fB\-Z\fR, \fB\-\-selinux-user\fR \fISEUSER\fR ++The SELinux user for the user's login. The default is to leave this field blank, which causes the system to select the default SELinux user. + .SS "Changing the default values" + .PP + When invoked with the +--- shadow-4.0.18.1/man/useradd.8.xml.useradd 2006-07-24 07:48:36.000000000 +0200 ++++ shadow-4.0.18.1/man/useradd.8.xml 2007-11-29 15:47:39.000000000 +0100 @@ -251,6 +251,19 @@ @@ -103,66 +128,167 @@ ---- shadow-4.0.17/man/useradd.8.useradd 2007-01-16 18:24:34.000000000 +0100 -+++ shadow-4.0.17/man/useradd.8 2007-01-16 18:24:34.000000000 +0100 -@@ -137,6 +137,9 @@ - The numerical value of the user's ID. This value must be unique, unless the - \fB\-o\fR - option is used. The value must be non\-negative. The default is to use the smallest ID value greater than 999 and greater than every other user. Values between 0 and 999 are typically reserved for system accounts. -+.TP 3n -+\fB\-Z\fR, \fB\-\-selinux-user\fR \fISEUSER\fR -+The SELinux user for the user's login. The default is to leave this field blank, which causes the system to select the default SELinux user. - .SS "Changing the default values" - .PP - When invoked with the ---- shadow-4.0.17/man/usermod.8.useradd 2007-01-16 18:24:34.000000000 +0100 -+++ shadow-4.0.17/man/usermod.8 2007-01-16 18:24:34.000000000 +0100 -@@ -90,6 +90,10 @@ - \fB\-p\fR - or - \fB\-L\fR. -+.TP 3n -+\fB\-Z\fR, \fB\-\-selinux-user\fR \fISEUSER\fR -+The SELinux user for the user's login. The default is to leave this field blank, which causes the system to select the default SELinux user. -+ - .SH "CAVEATS" - .PP +--- shadow-4.0.18.1/src/userdel.c.useradd 2007-11-29 15:46:24.000000000 +0100 ++++ shadow-4.0.18.1/src/userdel.c 2007-11-29 15:47:39.000000000 +0100 +@@ -792,6 +792,17 @@ int main (int argc, char **argv) + #endif + } ---- shadow-4.0.17/lib/prototypes.h.useradd 2006-02-07 17:36:30.000000000 +0100 -+++ shadow-4.0.17/lib/prototypes.h 2007-01-16 18:24:34.000000000 +0100 -@@ -52,6 +52,9 @@ - /* copydir.c */ - extern int copy_tree (const char *, const char *, uid_t, gid_t); - extern int remove_tree (const char *); +#ifdef WITH_SELINUX -+extern int selinux_file_context (const char *dst_name); ++ if (is_selinux_enabled() > 0) { ++ const char *argv[5]; ++ argv[0] = "/usr/sbin/semanage"; ++ argv[1] = "login"; ++ argv[2] = "-d"; ++ argv[3] = user_name; ++ argv[4] = NULL; ++ safe_system(argv[0], argv, NULL, 1); ++ } ++#endif + /* + * Cancel any crontabs or at jobs. Have to do this before we remove + * the entry from /etc/passwd. +--- shadow-4.0.18.1/src/usermod.c.useradd 2007-11-29 15:46:24.000000000 +0100 ++++ shadow-4.0.18.1/src/usermod.c 2007-11-29 15:47:39.000000000 +0100 +@@ -90,6 +90,7 @@ static char *user_comment; + static char *user_home; + static char *user_newhome; + static char *user_shell; ++static const char *user_selinux = ""; + static long user_expire; + static long user_inactive; + static long sys_ngroups; +@@ -132,6 +133,7 @@ static int is_shadow_grp; + static int get_groups (char *); + static void usage (void); + static void new_pwent (struct passwd *); ++static void selinux_update_mapping (void); + + static void new_spent (struct spwd *); + static void fail_exit (int); +@@ -294,6 +296,9 @@ static void usage (void) + " -s, --shell SHELL new login shell for the user account\n" + " -u, --uid UID new UID for the user account\n" + " -U, --unlock unlock the user account\n" ++#ifdef WITH_SELINUX ++ " -Z, --selinux-user new selinux user mapping for the user account\n" +#endif + "\n")); + exit (E_USAGE); + } +@@ -918,13 +923,20 @@ static void process_flags (int argc, cha + {"move-home", no_argument, NULL, 'm'}, + {"non-unique", no_argument, NULL, 'o'}, + {"password", required_argument, NULL, 'p'}, ++#ifdef WITH_SELINUX ++ {"selinux-user", required_argument, NULL, 'Z'}, ++#endif + {"shell", required_argument, NULL, 's'}, + {"uid", required_argument, NULL, 'u'}, + {"unlock", no_argument, NULL, 'U'}, + {NULL, 0, NULL, '\0'} + }; + while ((c = ++#ifdef WITH_SELINUX ++ getopt_long (argc, argv, "ac:d:e:f:g:G:hl:Lmop:s:u:UZ:", ++#else + getopt_long (argc, argv, "ac:d:e:f:g:G:hl:Lmop:s:u:U", ++#endif + long_options, NULL)) != -1) { + switch (c) { + case 'a': +@@ -1073,6 +1085,16 @@ static void process_flags (int argc, cha - /* encrypt.c */ - extern char *pw_encrypt (const char *, const char *); -@@ -147,6 +150,9 @@ - /* shell.c */ - extern int shell (const char *, const char *, char *const *); + Uflg++; + break; ++#ifdef WITH_SELINUX ++ case 'Z': ++ if (is_selinux_enabled() > 0) ++ user_selinux = optarg; ++ else { ++ fprintf (stderr, _("%s: -Z requires SELinux enabled kernel\n"), Prog); ++ exit (E_BAD_ARG); ++ } ++ break; ++#endif + default: + usage (); + } +@@ -1542,6 +1564,8 @@ int main (int argc, char **argv) + if (Gflg || lflg) + grp_err = grp_update (); -+/* system.c */ -+extern int safe_system(const char *command, const char *argv[], const char *env[], int ignore_stderr); ++ selinux_update_mapping(); + - /* strtoday.c */ - extern long strtoday (const char *); - ---- shadow-4.0.17/lib/defines.h.useradd 2005-09-05 18:22:03.000000000 +0200 -+++ shadow-4.0.17/lib/defines.h 2007-01-16 18:24:34.000000000 +0100 -@@ -342,4 +342,7 @@ - #include - #endif + if (mflg) + move_home (); +@@ -1573,3 +1597,62 @@ int main (int argc, char **argv) + exit (E_SUCCESS); + /* NOT REACHED */ + } ++ ++static void selinux_update_mapping () { +#ifdef WITH_SELINUX -+#include ++ const char *argv[7]; ++ ++ if (is_selinux_enabled() <= 0) return; ++ ++ if (*user_selinux) { ++ argv[0] = "/usr/sbin/semanage"; ++ argv[1] = "login"; ++ argv[2] = "-m"; ++ argv[3] = "-s"; ++ argv[4] = user_selinux; ++ argv[5] = user_name; ++ argv[6] = NULL; ++ if (safe_system(argv[0], argv, NULL, 1)) { ++ argv[2] = "-a"; ++ if (safe_system(argv[0], argv, NULL, 0)) { ++ fprintf (stderr, ++ _("%s: warning: the user name %s to %s SELinux user mapping failed.\n"), ++ Prog, user_name, user_selinux); ++#ifdef WITH_AUDIT ++ audit_logger (AUDIT_USER_CHAUTHTOK, Prog, ++ "modifying User mapping ", user_name, user_id, 0); ++#endif ++ } ++ } ++ } ++ ++ if (dflg || *user_selinux) { ++ argv[0] = "/usr/sbin/genhomedircon"; ++ argv[1] = NULL; ++ if(safe_system(argv[0], argv, NULL,0)) { ++ fprintf (stderr, ++ _("%s: warning: unable to relabel the homedir %s for %s.\n"), ++ Prog, user_home, user_name); ++#ifdef WITH_AUDIT ++ audit_logger (AUDIT_USER_CHAUTHTOK, Prog, ++ "relabeling home directory", user_name, user_id, 0); +#endif - #endif /* _DEFINES_H_ */ ---- shadow-4.0.17/src/useradd.c.useradd 2007-01-16 18:24:34.000000000 +0100 -+++ shadow-4.0.17/src/useradd.c 2007-01-16 18:24:34.000000000 +0100 -@@ -100,6 +100,7 @@ ++ } ++ ++ argv[0] = "/sbin/restorecon"; ++ argv[1] = "-F"; ++ argv[2] = "-R"; ++ argv[3] = user_home; ++ argv[4] = NULL; ++ if (safe_system(argv[0], argv, NULL, 0)) { ++ fprintf (stderr, ++ _("%s: warning: unable to relabel the homedir %s for %s.\n"), ++ Prog, user_home, user_name); ++#ifdef WITH_AUDIT ++ audit_logger (AUDIT_USER_CHAUTHTOK, Prog, ++ "relabeling home directory", user_name, user_id, 0); ++#endif ++ } ++ } ++#endif ++} +--- shadow-4.0.18.1/src/useradd.c.useradd 2007-11-29 15:46:24.000000000 +0100 ++++ shadow-4.0.18.1/src/useradd.c 2007-11-29 15:52:00.000000000 +0100 +@@ -100,6 +100,7 @@ static const char *user_comment = ""; static const char *user_home = ""; static const char *user_shell = ""; static const char *create_mail_spool = ""; @@ -170,7 +296,7 @@ static long user_expire = -1; static int is_shadow_pwd; -@@ -170,6 +171,7 @@ +@@ -170,6 +171,7 @@ static int set_defaults (void); static int get_groups (char *); static void usage (void); static void new_pwent (struct passwd *); @@ -178,7 +304,7 @@ static long scale_age (long); static void new_spent (struct spwd *); -@@ -361,6 +363,7 @@ +@@ -354,6 +356,7 @@ static void get_defaults (void) def_create_mail_spool = xstrdup (cp); } } @@ -186,7 +312,7 @@ } /* -@@ -648,7 +651,10 @@ +@@ -641,7 +644,10 @@ static void usage (void) " -p, --password PASSWORD use encrypted password for the new user\n" " account\n" " -s, --shell SHELL the login shell for the new user account\n" @@ -198,7 +324,7 @@ "\n")); exit (E_USAGE); } -@@ -1048,11 +1054,18 @@ +@@ -1041,11 +1047,18 @@ static void process_flags (int argc, cha {"non-unique", no_argument, NULL, 'o'}, {"password", required_argument, NULL, 'p'}, {"shell", required_argument, NULL, 's'}, @@ -209,16 +335,15 @@ {NULL, 0, NULL, '\0'} }; while ((c = -- getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mlMnrop:s:u:", +#ifdef WITH_SELINUX + getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mlMnrop:s:u:Z:", +#else -+ getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mlMnrop:s:u:", + getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mlMnrop:s:u:", +#endif long_options, NULL)) != -1) { switch (c) { case 'b': -@@ -1236,6 +1249,17 @@ +@@ -1229,6 +1242,17 @@ static void process_flags (int argc, cha case 'M': Mflg++; break; @@ -236,7 +361,7 @@ default: usage (); } -@@ -1603,6 +1627,33 @@ +@@ -1596,6 +1620,33 @@ static void usr_update (void) grp_update (); } @@ -270,7 +395,7 @@ /* * create_home - create the user's home directory * -@@ -1612,7 +1663,11 @@ +@@ -1605,7 +1656,11 @@ static void usr_update (void) */ static void create_home (void) { @@ -282,11 +407,13 @@ /* XXX - create missing parent directories. --marekm */ if (mkdir (user_home, 0)) { fprintf (stderr, -@@ -1840,6 +1895,15 @@ +@@ -1833,6 +1888,17 @@ int main (int argc, char **argv) usr_update (); -+ create_mail (); ++ /* Do not create mail directory for system accounts */ ++ if( !rflg ) ++ create_mail (); + + nscd_flush_cache ("passwd"); + nscd_flush_cache ("group"); @@ -298,11 +425,13 @@ if (mflg) { create_home (); if (home_added) -@@ -1863,13 +1927,6 @@ +@@ -1856,15 +1922,6 @@ int main (int argc, char **argv) * with --gafton */ -- create_mail (); +- /* Do not create mail directory for system accounts */ +- if( !rflg ) +- create_mail (); - - nscd_flush_cache ("passwd"); - nscd_flush_cache ("group"); @@ -312,162 +441,35 @@ #ifdef USE_PAM if (retval == PAM_SUCCESS) pam_end (pamh, PAM_SUCCESS); ---- shadow-4.0.17/src/userdel.c.useradd 2007-01-16 18:24:34.000000000 +0100 -+++ shadow-4.0.17/src/userdel.c 2007-01-16 18:24:34.000000000 +0100 -@@ -792,6 +792,17 @@ +--- shadow-4.0.18.1/lib/defines.h.useradd 2005-09-05 18:22:03.000000000 +0200 ++++ shadow-4.0.18.1/lib/defines.h 2007-11-29 15:47:39.000000000 +0100 +@@ -342,4 +342,7 @@ extern char *strerror (); + #include #endif - } +#ifdef WITH_SELINUX -+ if (is_selinux_enabled() > 0) { -+ const char *argv[5]; -+ argv[0] = "/usr/sbin/semanage"; -+ argv[1] = "login"; -+ argv[2] = "-d"; -+ argv[3] = user_name; -+ argv[4] = NULL; -+ safe_system(argv[0], argv, NULL, 1); -+ } -+#endif - /* - * Cancel any crontabs or at jobs. Have to do this before we remove - * the entry from /etc/passwd. ---- shadow-4.0.17/src/usermod.c.useradd 2007-01-16 18:24:34.000000000 +0100 -+++ shadow-4.0.17/src/usermod.c 2007-01-16 18:29:45.000000000 +0100 -@@ -90,6 +90,7 @@ - static char *user_home; - static char *user_newhome; - static char *user_shell; -+static const char *user_selinux = ""; - static long user_expire; - static long user_inactive; - static long sys_ngroups; -@@ -132,6 +133,7 @@ - static int get_groups (char *); - static void usage (void); - static void new_pwent (struct passwd *); -+static void selinux_update_mapping (void); - - static void new_spent (struct spwd *); - static void fail_exit (int); -@@ -301,6 +303,9 @@ - " -s, --shell SHELL new login shell for the user account\n" - " -u, --uid UID new UID for the user account\n" - " -U, --unlock unlock the user account\n" -+#ifdef WITH_SELINUX -+ " -Z, --selinux-user new selinux user mapping for the user account\n" -+#endif - "\n")); - exit (E_USAGE); - } -@@ -925,13 +930,20 @@ - {"move-home", no_argument, NULL, 'm'}, - {"non-unique", no_argument, NULL, 'o'}, - {"password", required_argument, NULL, 'p'}, -+#ifdef WITH_SELINUX -+ {"selinux-user", required_argument, NULL, 'Z'}, ++#include +#endif - {"shell", required_argument, NULL, 's'}, - {"uid", required_argument, NULL, 'u'}, - {"unlock", no_argument, NULL, 'U'}, - {NULL, 0, NULL, '\0'} - }; - while ((c = + #endif /* _DEFINES_H_ */ +--- shadow-4.0.18.1/lib/prototypes.h.useradd 2006-02-07 17:36:30.000000000 +0100 ++++ shadow-4.0.18.1/lib/prototypes.h 2007-11-29 15:47:39.000000000 +0100 +@@ -52,6 +52,9 @@ extern int is_listed (const char *, cons + /* copydir.c */ + extern int copy_tree (const char *, const char *, uid_t, gid_t); + extern int remove_tree (const char *); +#ifdef WITH_SELINUX -+ getopt_long (argc, argv, "ac:d:e:f:g:G:hl:Lmop:s:u:UZ:", -+#else - getopt_long (argc, argv, "ac:d:e:f:g:G:hl:Lmop:s:u:U", ++extern int selinux_file_context (const char *dst_name); +#endif - long_options, NULL)) != -1) { - switch (c) { - case 'a': -@@ -1080,6 +1092,16 @@ - Uflg++; - break; -+#ifdef WITH_SELINUX -+ case 'Z': -+ if (is_selinux_enabled() > 0) -+ user_selinux = optarg; -+ else { -+ fprintf (stderr, _("%s: -Z requires SELinux enabled kernel\n"), Prog); -+ exit (E_BAD_ARG); -+ } -+ break; -+#endif - default: - usage (); - } -@@ -1549,6 +1571,8 @@ - if (Gflg || lflg) - grp_err = grp_update (); + /* encrypt.c */ + extern char *pw_encrypt (const char *, const char *); +@@ -147,6 +150,9 @@ extern void setup_env (struct passwd *); + /* shell.c */ + extern int shell (const char *, const char *, char *const *); -+ selinux_update_mapping(); ++/* system.c */ ++extern int safe_system(const char *command, const char *argv[], const char *env[], int ignore_stderr); + - if (mflg) - move_home (); + /* strtoday.c */ + extern long strtoday (const char *); -@@ -1580,3 +1604,62 @@ - exit (E_SUCCESS); - /* NOT REACHED */ - } -+ -+static void selinux_update_mapping () { -+#ifdef WITH_SELINUX -+ const char *argv[7]; -+ -+ if (is_selinux_enabled() <= 0) return; -+ -+ if (*user_selinux) { -+ argv[0] = "/usr/sbin/semanage"; -+ argv[1] = "login"; -+ argv[2] = "-m"; -+ argv[3] = "-s"; -+ argv[4] = user_selinux; -+ argv[5] = user_name; -+ argv[6] = NULL; -+ if (safe_system(argv[0], argv, NULL, 1)) { -+ argv[2] = "-a"; -+ if (safe_system(argv[0], argv, NULL, 0)) { -+ fprintf (stderr, -+ _("%s: warning: the user name %s to %s SELinux user mapping failed.\n"), -+ Prog, user_name, user_selinux); -+#ifdef WITH_AUDIT -+ audit_logger (AUDIT_USER_CHAUTHTOK, Prog, -+ "modifying User mapping ", user_name, user_id, 0); -+#endif -+ } -+ } -+ } -+ -+ if (dflg || *user_selinux) { -+ argv[0] = "/usr/sbin/genhomedircon"; -+ argv[1] = NULL; -+ if(safe_system(argv[0], argv, NULL,0)) { -+ fprintf (stderr, -+ _("%s: warning: unable to relabel the homedir %s for %s.\n"), -+ Prog, user_home, user_name); -+#ifdef WITH_AUDIT -+ audit_logger (AUDIT_USER_CHAUTHTOK, Prog, -+ "relabeling home directory", user_name, user_id, 0); -+#endif -+ } -+ -+ argv[0] = "/sbin/restorecon"; -+ argv[1] = "-F"; -+ argv[2] = "-R"; -+ argv[3] = user_home; -+ argv[4] = NULL; -+ if (safe_system(argv[0], argv, NULL, 0)) { -+ fprintf (stderr, -+ _("%s: warning: unable to relabel the homedir %s for %s.\n"), -+ Prog, user_home, user_name); -+#ifdef WITH_AUDIT -+ audit_logger (AUDIT_USER_CHAUTHTOK, Prog, -+ "relabeling home directory", user_name, user_id, 0); -+#endif -+ } -+ } -+#endif -+} -+ diff --git a/shadow-utils.spec b/shadow-utils.spec index b783e2b..21cace5 100644 --- a/shadow-utils.spec +++ b/shadow-utils.spec @@ -5,7 +5,7 @@ Summary: Utilities for managing accounts and shadow password files Name: shadow-utils Version: 4.0.18.1 -Release: 19%{?dist} +Release: 20%{?dist} Epoch: 2 URL: http://shadow.pld.org.pl/ Source0: ftp://ftp.pld.org.pl/software/shadow/shadow-%{version}.tar.bz2 @@ -215,6 +215,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man8/faillog.8* %changelog +* Thu Nov 29 2007 Peter Vrabec 2:4.0.18.1-20 +- do not create mail spool entries for system accounts (#402351) + * Thu Oct 18 2007 Peter Vrabec 2:4.0.18.1-19 - fix timestamps when moving home dirs to another file system (#278571)