components/proftpd/patches/mod_auth_unix_getgrp.patch
author William.Johnston <William.Johnston@Sun.Com>
Fri, 13 Jul 2012 15:21:02 -0700
branchs11-sru
changeset 2309 e2f60f60237d
permissions -rw-r--r--
7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2309
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
     1
--- old/modules/mod_auth_unix.c	Fri May 25 08:31:35 2012
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
     2
+++ new/modules/mod_auth_unix.c	Fri May 25 08:31:35 2012
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
     3
@@ -896,6 +896,13 @@
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
     4
 
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
     5
   return gr ? mod_create_data(cmd, (void *) &gr->gr_gid) : PR_DECLINED(cmd);
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
     6
 }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
     7
+#ifdef HAVE__GETGRPSBYMEMBER
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
     8
+  extern int _getgroupsbymember
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
     9
+  (
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    10
+	const char* username, gid_t gid_array[],
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    11
+	int maxgids, int numgids
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    12
+  ); 
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    13
+#endif /* HAVE__GETGRPSBYMEMBER */
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    14
 
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    15
 /* cmd->argv[0] = name
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    16
  * cmd->argv[1] = (array_header **) group_ids
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    17
@@ -1065,7 +1072,40 @@
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    18
     }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    19
 
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    20
     free(ptr);
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    21
-#else
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    22
+#else /* !HAVE_GETGRSET */
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    23
+#ifdef HAVE__GETGRPSBYMEMBER
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    24
+    gid_t group_ids[NGROUPS_MAX];
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    25
+    int ngroups = NGROUPS_MAX;
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    26
+    register unsigned int i;
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    27
+
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    28
+    pr_trace_msg("auth", 4,
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    29
+      "using _getgroupsbymember() to look up group membership");
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    30
+
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    31
+    memset(group_ids, 0, sizeof(group_ids));
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    32
+
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    33
+    group_ids[0]=pw->pw_gid;
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    34
+    ngroups=
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    35
+      _getgroupsbymember(pw->pw_name, group_ids, NGROUPS_MAX, 1);
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    36
+
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    37
+    if (ngroups < 0) {
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    38
+	pr_log_pri(PR_LOG_ERR,
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    39
+	    "_getgroupsbymember error: %s", strerror(errno));
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    40
+	return PR_DECLINED(cmd);
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    41
+    }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    42
+
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    43
+    for (i = 0; i < ngroups; i++) {
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    44
+      gr = my_getgrgid(group_ids[i]);
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    45
+      if (gr) {
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    46
+        if (gids && pw->pw_gid != gr->gr_gid)
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    47
+          *((gid_t *) push_array(gids)) = gr->gr_gid;
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    48
+
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    49
+        if (groups && pw->pw_gid != gr->gr_gid) {
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    50
+          *((char **) push_array(groups)) = pstrdup(session.pool,
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    51
+            gr->gr_name);
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    52
+        }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    53
+      }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    54
+    }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    55
+#else /* !HAVE__GETGRPSBYMEMBER */
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    56
     char **gr_member = NULL;
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    57
 
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    58
     /* This is where things get slow, expensive, and ugly.  Loop through
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    59
@@ -1091,6 +1131,7 @@
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    60
         }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    61
       }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    62
     }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    63
+#endif /* !HAVE__GETGROUPSBYMEMBER */
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    64
 #endif /* !HAVE_GETGRSET */
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    65
   }
e2f60f60237d 7150536 ftp (proftpd) service times out and goes to maintenance on T5220 and DEBUG kernel
William.Johnston <William.Johnston@Sun.Com>
parents:
diff changeset
    66