]> granicus.if.org Git - shadow/commitdiff
If the shadow group file is not present, do not try to locate the group
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 20 Nov 2007 20:59:42 +0000 (20:59 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 20 Nov 2007 20:59:42 +0000 (20:59 +0000)
entry from /etc/gshadow, and set the password in /etc/group.

ChangeLog
src/chgpasswd.c

index 0b9f1636afe8b7e9a874d7a0514d44f41706e6c0..1449de152a86aaa35ad96351a8f7de6bf5da948a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-20  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * src/chgpasswd.c: If the shadow group file is not present, do not
+       try to locate the group entry from /etc/gshadow, and set the
+       password in /etc/group.
+
 2007-11-20  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/obscure.c, libmisc/salt.c, src/passwd.c: Match DES, MD5,
index 2eabb2b7e3da2d36ac6a07a6cb8f4f4dc80255ed..8de443fc334a7acb5058397af226100fb58df6f1 100644 (file)
@@ -116,6 +116,9 @@ int main (int argc, char **argv)
 #endif
 
        const struct group *gr;
+#ifndef SHADOWGRP
+       struct group newgr;
+#endif
        int errors = 0;
        int line = 0;
        int ok;
@@ -124,9 +127,6 @@ int main (int argc, char **argv)
        pam_handle_t *pamh = NULL;
        int retval;
 #endif
-#ifndef SHADOWGRP
-       struct group newgr;
-#endif
 
        Prog = Basename (argv[0]);
 
@@ -336,7 +336,10 @@ int main (int argc, char **argv)
                        continue;
                }
 #ifdef SHADOWGRP
-               sg = sgr_locate (name);
+               if (is_shadow_grp)
+                       sg = sgr_locate (name);
+               else
+                       sg = NULL;
 #endif
 
                /*
@@ -345,12 +348,15 @@ int main (int argc, char **argv)
                 * date is set to the current date.
                 */
 #ifdef SHADOWGRP
-               newsg = *sg;
-               newsg.sg_passwd = cp;
-#else
-               newgr = *gr;
-               newgr.gr_passwd = cp;
+               if (sg) {
+                       newsg = *sg;
+                       newsg.sg_passwd = cp;
+               } else
 #endif
+               {
+                       newgr = *gr;
+                       newgr.gr_passwd = cp;
+               }
 
                /* 
                 * The updated password file entry is then put back and will
@@ -358,10 +364,11 @@ int main (int argc, char **argv)
                 * other entries have been updated as well.
                 */
 #ifdef SHADOWGRP
-               ok = sgr_update (&newsg);
-#else
-               ok = gr_update (&newgr);
+               if (sg)
+                       ok = sgr_update (&newsg);
+               else
 #endif
+                       ok = gr_update (&newgr);
 
                if (!ok) {
                        fprintf (stderr,