From f5bb0f75591f1080efe4c8347b324474ba7add8e Mon Sep 17 00:00:00 2001 From: Johannes Winkelmann Date: Sat, 8 Apr 2006 14:39:04 +0000 Subject: [PATCH] shadow: allow to create per-user group when supplying the -n switch; use defaults otherwise --- shadow/.md5sum | 5 +- shadow/Pkgfile | 17 +++-- shadow/login.defs | 2 +- shadow/shadow-4.0.15-nflg-conflict.diff | 28 ++++++++ shadow/shadow-fix-useradd-usergroups.patch | 74 ++++++++++++++++++++++ shadow/useradd-4.0.15.diff | 17 ----- 6 files changed, 117 insertions(+), 26 deletions(-) create mode 100644 shadow/shadow-4.0.15-nflg-conflict.diff create mode 100644 shadow/shadow-fix-useradd-usergroups.patch delete mode 100644 shadow/useradd-4.0.15.diff diff --git a/shadow/.md5sum b/shadow/.md5sum index 6e73e13e..8c921937 100644 --- a/shadow/.md5sum +++ b/shadow/.md5sum @@ -1,5 +1,6 @@ -d52af1b47b7a382bff9d0be6865f05ea login.defs +2b8c303d972cf6fb2a4545dd17262f27 login.defs be8f69c2701118093af3d7f3bc02af16 pwck +9e2f566e29068dc98e42ea94ac788200 shadow-4.0.15-nflg-conflict.diff 01bab2b152b8f2ae0056a467fa365797 shadow-4.0.15-noshadowgrp.diff a0452fa989f8ba45023cc5a08136568e shadow-4.0.15.tar.bz2 -ed61f849a595731bf795010a4f3cea16 useradd-4.0.15.diff +ca5630fc50fdf84daecde18149f321ec shadow-fix-useradd-usergroups.patch diff --git a/shadow/Pkgfile b/shadow/Pkgfile index e7ba671c..f12d8cc1 100644 --- a/shadow/Pkgfile +++ b/shadow/Pkgfile @@ -1,24 +1,29 @@ # Description: Shadow password file utilities # URL: http://shadow.pld.org.pl/ -# Maintainer: Per Lidén +# Packager: Per Lidén, per at fukt dot bth dot se +# Maintainer: Johannes Winkelmann, jw at crux dot nu name=shadow version=4.0.15 -release=2 +release=3 source=(ftp://ftp.pld.org.pl/software/shadow/$name-$version.tar.bz2 \ - pwck login.defs shadow-4.0.15-noshadowgrp.diff useradd-4.0.15.diff) + pwck login.defs \ + shadow-4.0.15-noshadowgrp.diff \ + shadow-fix-useradd-usergroups.patch\ + shadow-4.0.15-nflg-conflict.diff) build() { cd $name-$version patch -p1 < $SRC/shadow-4.0.15-noshadowgrp.diff - patch -p0 < $SRC/useradd-4.0.15.diff + patch src/useradd.c $SRC/shadow-fix-useradd-usergroups.patch + patch src/useradd.c $SRC/shadow-4.0.15-nflg-conflict.diff ./configure --prefix=/usr \ --mandir=/usr/man \ --disable-shared \ - --disable-shadowgrp \ + --disable-shadowgrp \ --disable-nls \ - --without-selinux + --without-selinux make make DESTDIR=$PKG install mkdir -p $PKG/etc/cron/daily $PKG/var/log diff --git a/shadow/login.defs b/shadow/login.defs index 2eb596e5..d15cb25d 100644 --- a/shadow/login.defs +++ b/shadow/login.defs @@ -45,6 +45,6 @@ CHFN_RESTRICT rwh MD5_CRYPT_ENAB yes PASS_MAX_LEN 8 DEFAULT_HOME yes -USERGROUPS_ENAB yes +USERGROUPS_ENAB no # End of file diff --git a/shadow/shadow-4.0.15-nflg-conflict.diff b/shadow/shadow-4.0.15-nflg-conflict.diff new file mode 100644 index 00000000..f34eaeea --- /dev/null +++ b/shadow/shadow-4.0.15-nflg-conflict.diff @@ -0,0 +1,28 @@ +--- useradd.c.orig 2006-04-08 10:47:03.016040384 +0200 ++++ useradd.c 2006-04-08 11:17:09.218455880 +0200 +@@ -1214,6 +1214,16 @@ + usage (); + + /* ++ * Using -g and -n doesn't make sense ++ */ ++ if (nflg && gflg) { ++ fprintf(stderr, ++ _("%s: options -n and -g conflict and can't be used together\n"), ++ Prog); ++ exit (E_BAD_ARG); ++ } ++ ++ /* + * Either -D or username is required. Defaults can be set with -D + * for the -b, -e, -f, -g, -s options only. + */ +@@ -1778,7 +1788,7 @@ + + /* do we have to add a group for that user? This is why we need to + * open the group files in the open_files() function --gafton */ +- if (nflg && !gflg) { ++ if (nflg) { + find_new_gid (); + grp_add (); + } diff --git a/shadow/shadow-fix-useradd-usergroups.patch b/shadow/shadow-fix-useradd-usergroups.patch new file mode 100644 index 00000000..ba7d7446 --- /dev/null +++ b/shadow/shadow-fix-useradd-usergroups.patch @@ -0,0 +1,74 @@ +2006-04-07 Mike Frysinger + + * src/useradd.c: Actually utilize the nflg by adding an -n option for the + user and by setting to USERGROUPS_ENAB from login.defs. Also fix the logic + for when the user group actually needs to be added. + +--- src/useradd.c ++++ src/useradd.c +@@ -114,7 +114,7 @@ static int do_grp_update = 0; /* group f + static char *Prog; + + static int +- bflg = 0, /* new default root of home directory */ ++ bflg = 0, /* new default root of home directory */ + cflg = 0, /* comment (GECOS) field for new account */ + dflg = 0, /* home directory for new account */ + Dflg = 0, /* set/show new user default values */ +@@ -253,6 +253,11 @@ static void get_defaults (void) + const struct group *grp; + + /* ++ * Pull relevant settings from login.defs first. ++ */ ++ nflg = getdef_bool ("USERGROUPS_ENAB"); ++ printf("nflg: %d\n", nflg); ++ /* + * Open the defaults file for reading. + */ + +@@ -628,6 +633,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" ++ " -n, --user-group create a new group with the same name as the\n" ++ " new user\n" + " -o, --non-unique allow create user with duplicate\n" + " (non-unique) UID\n" + " -p, --password PASSWORD use encrypted password for the new user\n" +@@ -1009,6 +1016,7 @@ static void process_flags (int argc, cha + {"skel", required_argument, NULL, 'k'}, + {"key", required_argument, NULL, 'K'}, + {"create-home", no_argument, NULL, 'm'}, ++ {"user-group", no_argument, NULL, 'n'}, + {"non-unique", no_argument, NULL, 'o'}, + {"password", required_argument, NULL, 'p'}, + {"shell", required_argument, NULL, 's'}, +@@ -1016,7 +1024,7 @@ static void process_flags (int argc, cha + {NULL, 0, NULL, '\0'} + }; + while ((c = +- getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mMop:s:u:", ++ getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mMnop:s:u:", + long_options, NULL)) != -1) { + switch (c) { + case 'b': +@@ -1156,6 +1164,9 @@ static void process_flags (int argc, cha + case 'm': + mflg++; + break; ++ case 'n': ++ nflg++; ++ break; + case 'o': + oflg++; + break; +@@ -1767,7 +1778,7 @@ int main (int argc, char **argv) + + /* do we have to add a group for that user? This is why we need to + * open the group files in the open_files() function --gafton */ +- if (!(nflg || gflg)) { ++ if (nflg && !gflg) { + find_new_gid (); + grp_add (); + } diff --git a/shadow/useradd-4.0.15.diff b/shadow/useradd-4.0.15.diff deleted file mode 100644 index 700ee238..00000000 --- a/shadow/useradd-4.0.15.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- src/useradd.c.orig 2006-03-29 20:45:56.981071520 +0200 -+++ src/useradd.c 2006-03-29 22:39:13.312872040 +0200 -@@ -1765,12 +1765,14 @@ - find_new_uid (); - } - -+#if 0 /* jw */ - /* do we have to add a group for that user? This is why we need to - * open the group files in the open_files() function --gafton */ - if (!(nflg || gflg)) { - find_new_gid (); - grp_add (); - } -+#endif - - usr_update (); -