diff -Nru shadow-4.8.1/debian/changelog shadow-4.8.1/debian/changelog --- shadow-4.8.1/debian/changelog 2021-11-15 23:13:44.000000000 +0100 +++ shadow-4.8.1/debian/changelog 2022-01-28 10:03:42.000000000 +0100 @@ -1,3 +1,10 @@ +shadow (1:4.8.1-2ubuntu2~ppa1) jammy; urgency=medium + + * Add automatic detection of "extrausers" for usermod -G + (LP: 1959375) + + -- Michael Vogt Fri, 28 Jan 2022 10:03:42 +0100 + shadow (1:4.8.1-2ubuntu1) jammy; urgency=low * Merge from Debian unstable (LP: #1951161). Remaining changes: diff -Nru shadow-4.8.1/debian/patches/1010_extrausers.patch shadow-4.8.1/debian/patches/1010_extrausers.patch --- shadow-4.8.1/debian/patches/1010_extrausers.patch 2020-02-07 16:32:06.000000000 +0100 +++ shadow-4.8.1/debian/patches/1010_extrausers.patch 2022-01-28 10:03:42.000000000 +0100 @@ -9,11 +9,11 @@ src/usermod.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 1 deletion(-) -diff --git a/lib/commonio.c b/lib/commonio.c -index 9f6ceca..008691f 100644 ---- a/lib/commonio.c -+++ b/lib/commonio.c -@@ -419,6 +419,7 @@ int commonio_lock (struct commonio_db *db) +Index: shadow-4.8.1/lib/commonio.c +=================================================================== +--- shadow-4.8.1.orig/lib/commonio.c ++++ shadow-4.8.1/lib/commonio.c +@@ -419,6 +419,7 @@ int commonio_lock (struct commonio_db *d int i; #ifdef HAVE_LCKPWDF @@ -21,7 +21,7 @@ /* * Only if the system libc has a real lckpwdf() - the one from * lockpw.c calls us and would cause infinite recursion! -@@ -448,6 +449,7 @@ int commonio_lock (struct commonio_db *db) +@@ -448,6 +449,7 @@ int commonio_lock (struct commonio_db *d ulckpwdf (); return 0; /* failure */ } @@ -29,11 +29,11 @@ #endif /* !HAVE_LCKPWDF */ /* -diff --git a/lib/defines.h b/lib/defines.h -index 2fb1b56..ffa8b6a 100644 ---- a/lib/defines.h -+++ b/lib/defines.h -@@ -316,6 +316,14 @@ char *strchr (), *strrchr (), *strtok (); +Index: shadow-4.8.1/lib/defines.h +=================================================================== +--- shadow-4.8.1.orig/lib/defines.h ++++ shadow-4.8.1/lib/defines.h +@@ -316,6 +316,14 @@ char *strchr (), *strrchr (), *strtok () #endif #endif @@ -48,10 +48,10 @@ #ifndef NULL #define NULL ((void *) 0) #endif -diff --git a/src/passwd.c b/src/passwd.c -index 13619b1..bfe0aea 100644 ---- a/src/passwd.c -+++ b/src/passwd.c +Index: shadow-4.8.1/src/passwd.c +=================================================================== +--- shadow-4.8.1.orig/src/passwd.c ++++ shadow-4.8.1/src/passwd.c @@ -559,8 +559,15 @@ static void update_noshadow (void) { const struct passwd *pw; @@ -170,10 +170,10 @@ return; } nsp = __spw_dup (sp); -diff --git a/src/usermod.c b/src/usermod.c -index 05b9871..fb833e1 100644 ---- a/src/usermod.c -+++ b/src/usermod.c +Index: shadow-4.8.1/src/usermod.c +=================================================================== +--- shadow-4.8.1.orig/src/usermod.c ++++ shadow-4.8.1/src/usermod.c @@ -1566,7 +1566,16 @@ static void close_files (void) */ static void open_files (void) @@ -239,7 +239,50 @@ fprintf (stderr, _("%s: cannot open %s\n"), Prog, spw_dbname ()); -@@ -1675,11 +1712,22 @@ static void usr_update (void) +@@ -1599,6 +1636,12 @@ static void open_files (void) + * group entries. + */ + if (gr_lock () == 0) { ++ if (try_extrausers) { ++ gr_setdbname (EXTRAUSERS_GROUP_FILE); ++ sgr_setdbname (EXTRAUSERS_SHADOWGROUP_FILE); ++ open_files (); ++ return; ++ } + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); +@@ -1606,6 +1649,14 @@ static void open_files (void) + } + gr_locked = true; + if (gr_open (O_CREAT | O_RDWR) == 0) { ++ if (try_extrausers) { ++ gr_unlock (); ++ gr_locked = false; ++ gr_setdbname (EXTRAUSERS_GROUP_FILE); ++ sgr_setdbname (EXTRAUSERS_SHADOWGROUP_FILE); ++ open_files (); ++ return; ++ } + fprintf (stderr, + _("%s: cannot open %s\n"), + Prog, gr_dbname ()); +@@ -1613,6 +1664,14 @@ static void open_files (void) + } + #ifdef SHADOWGRP + if (is_shadow_grp && (sgr_lock () == 0)) { ++ if (try_extrausers) { ++ gr_unlock (); ++ gr_locked = false; ++ gr_setdbname (EXTRAUSERS_GROUP_FILE); ++ sgr_setdbname (EXTRAUSERS_SHADOWGROUP_FILE); ++ open_files (); ++ return; ++ } + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, sgr_dbname ()); +@@ -1675,11 +1734,22 @@ static void usr_update (void) struct spwd spent; const struct spwd *spwd = NULL;