]> granicus.if.org Git - shadow/commitdiff
2008-07-26 Nicolas François <nicolas.francois@centraliens.net>
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 26 Jul 2008 16:11:49 +0000 (16:11 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 26 Jul 2008 16:11:49 +0000 (16:11 +0000)
* src/groupmems.c: Added Prog global variable to indicate the name
of the program in error messages.

2008-07-22  Lukáš Kuklínek  <lkukline@redhat.com>

* NEWS, src/groupmems.c: Check if the user added to group actually
exist. RedHat bug #455603
* NEWS, src/groupmems.c: Check if the group exists in the group
local database (/etc/group). RedHat bug #456088

ChangeLog
NEWS
src/groupmems.c

index 28648ed1affc91bfb8e3a89326bce9bbd91edd1a..c9c45c88dcafb151a7115beaea49620f73134b21 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-07-26  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * src/groupmems.c: Added Prog global variable to indicate the name
+       of the program in error messages.
+
+2008-07-22  Lukáš Kuklínek  <lkukline@redhat.com>
+
+       * NEWS, src/groupmems.c: Check if the user added to group actually
+       exist. RedHat bug #455603
+       * NEWS, src/groupmems.c: Check if the group exists in the group
+       local database (/etc/group). RedHat bug #456088
+
 2008-07-22  Nicolas François  <nicolas.francois@centraliens.net>
 
        * lib/prototypes.h: Fix getrange prototype.
diff --git a/NEWS b/NEWS
index a4de84965ea4ba2d39d7c3da4efd6b55d50ef7da..a5d061829caf09b40e06c2235b3c1c78785a2d73 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,9 @@ shadow-4.1.2.1 -> shadow-4.1.3                                                UNRELEASED
 - usermod
   * Allow adding LDAP users (or any user not present in the local passwd
     file) to local groups
+- groupmems
+  * Check if user exist before they are added to groups.
+  * Avoid segfault in case the specified group does not exist in /etc/group.
 
 shadow-4.1.2 -> shadow-4.1.2.1                                         26-06-2008
 
index 5cfb6d006574cd126c2efaca04640c6e6e25b36d..a04f6a3acdaef5944cab31a87ce3468c5687a38a 100644 (file)
@@ -54,6 +54,8 @@
 #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 */
+#define EXIT_INVALID_USER      8       /* specified user does not exist */
+#define EXIT_INVALID_GROUP     9       /* specified group does not exist */
 
 #define TRUE 1
 #define FALSE 0
@@ -67,6 +69,7 @@ static char *thisgroup = NULL;
 static int purge = FALSE;
 static int list = FALSE;
 static int exclusive = 0;
+static char *Prog;
 
 static int isroot (void)
 {
@@ -187,6 +190,11 @@ int main (int argc, char **argv)
                {NULL, 0, NULL, '\0'}
        };
 
+       /*
+        * Get my name so that I can use it to report errors.
+        */
+       Prog = Basename (argv[0]);
+
        (void) setlocale (LC_ALL, "");
        (void) bindtextdomain (PACKAGE, LOCALEDIR);
        (void) textdomain (PACKAGE);
@@ -223,6 +231,12 @@ int main (int argc, char **argv)
                usage ();
        }
 
+       if (getpwnam(adduser) == NULL) {
+               fprintf (stderr, _("%s: user `%s' does not exist\n")
+                        Prog, adduser);
+               exit (EXIT_INVALID_USERNAME);
+       }
+
        if (!isroot () && NULL != thisgroup) {
                fputs (_("Only root can add members to different groups\n"),
                       stderr);
@@ -284,6 +298,12 @@ int main (int argc, char **argv)
 
        grp = (struct group *) gr_locate (name);
 
+       if (grp == NULL) {
+               fprintf (stderr, _("%s: `%s' not found in /etc/group\n"),
+                        Prog, name);
+               exit (EXIT_READ_GROUP);
+       }
+
        if (NULL != adduser) {
                addtogroup (adduser, grp->gr_mem);
                gr_update (grp);