make pam_csc not explode when the syscom group does not exist
authorJeremy Roman <jbroman@csclub.uwaterloo.ca>
Sat, 7 Sep 2013 18:07:46 +0000 (14:07 -0400)
committerJeremy Roman <jbroman@csclub.uwaterloo.ca>
Sat, 7 Sep 2013 18:07:46 +0000 (14:07 -0400)
pam_csc.c

index 3cf16c7..5199235 100644 (file)
--- a/pam_csc.c
+++ b/pam_csc.c
@@ -199,14 +199,12 @@ PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t* pamh, int flags, int argc, const c
     }
 
     /* check to see if user is in group syscom, if yes, still print message but allow login even if user expired */
-    i = 0;
     grp = getgrnam("syscom");
-    while(grp->gr_mem[i] != NULL) {
+    for(i = 0; grp && grp->gr_mem[i]; i++) {
         if(!strcmp(grp->gr_mem[i], username)) {
             syscom = 1;
             break;
         }
-        i++;
     }
 
     /* check username */