]> granicus.if.org Git - sudo/commitdiff
kill perror("malloc") since we already have a good error messages
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 4 Nov 1998 01:39:40 +0000 (01:39 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 4 Nov 1998 01:39:40 +0000 (01:39 +0000)
pw_ent -> pw for brevity
when checking if %group matches, look up user in password file so
that %groups works in a RunAs spec.

parse.c

diff --git a/parse.c b/parse.c
index 15e053bd60e0f9876bb779ac7f99475fb9c95fea..d4f780fde8da55bf672588ba50e899a07f8c9457 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -355,23 +355,27 @@ int usergr_matches(group, user)
     char *group;
     char *user;
 {
-    struct group *grpent;
+    struct group *grp;
+    struct passwd *pw;
     char **cur;
 
     /* make sure we have a valid usergroup, sudo style */
     if (*group++ != '%')
        return(FALSE);
 
-    if ((grpent = getgrnam(group)) == NULL) 
+    if ((grp = getgrnam(group)) == NULL) 
        return(FALSE);
 
     /*
      * Check against user's real gid as well as group's user list
      */
-    if (grpent->gr_gid == user_gid)
+    if ((pw = getpwnam(user)) == NULL)
+       return(FALSE);
+
+    if (grp->gr_gid == pw->pw_gid)
        return(TRUE);
 
-    for (cur=grpent->gr_mem; *cur; cur++) {
+    for (cur=grp->gr_mem; *cur; cur++) {
        if (strcmp(*cur, user) == 0)
            return(TRUE);
     }
@@ -405,7 +409,6 @@ int netgr_matches(netgr, host, user)
     /* get the domain name (if any) */
     if (domain == (char *) -1) {
        if ((domain = (char *) malloc(MAXHOSTNAMELEN)) == NULL) {
-           perror("malloc");
            (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
            exit(1);
        }