mupdate exits with signal 11

Derrick J Brashear shadow at dementia.org
Tue Apr 26 13:46:17 EDT 2005


On Tue, 26 Apr 2005, João Assad wrote:

>
> sometimes mupdate exits with signal 11 . Im clueless why.
>
> cyrus-2.2.12
> gdb backtrace attached.

http://64.233.161.104/search?q=cache:CAPMOK5A4vwJ:asg.web.cmu.edu/archive/message.php%3Fmailbox%3Darchive.info-cyrus%26msg%3D34797+getgrent+auth_unix+cyrus&hl=en

It's the same problem.

I haven't tested this code yet, it was literally written right now while 
I'm eating my lunch:
Index: auth_unix.c
===================================================================
RCS file: /afs/andrew.cmu.edu/system/cvs/src/cyrus/lib/auth_unix.c,v
retrieving revision 1.37.2.2
diff -u -r1.37.2.2 auth_unix.c
--- auth_unix.c 16 Feb 2005 21:06:50 -0000      1.37.2.2
+++ auth_unix.c 26 Apr 2005 17:43:56 -0000
@@ -221,9 +221,11 @@
  static struct auth_state *mynewstate(const char *identifier)
  {
      struct auth_state *newstate;
-    struct passwd *pwd;
-    struct group *grp;
+    struct passwd pwd, *pwdp;
      char **mem;
+    struct group grp, *grpp;
+    char buf[BUFLEN], buf2[BUFLEN];
+    int i;

      identifier = mycanonifyid(identifier, 0);
      if (!identifier) return 0;
@@ -238,22 +240,25 @@
      if(!libcyrus_config_getswitch(CYRUSOPT_AUTH_UNIX_GROUP_ENABLE))
         return newstate;

-    pwd = getpwnam(identifier);
+    getpwnam_r(identifier, pwd, buf2, BUFLEN, &pwdp);

      setgrent();
-    while ((grp = getgrent())) {
-       for (mem = grp->gr_mem; *mem; mem++) {
-           if (!strcmp(*mem, identifier)) break;
-       }
-
-       if (*mem || (pwd && pwd->pw_gid == grp->gr_gid)) {
-           newstate->ngroups++;
-           newstate->group = (char **)xrealloc((char *)newstate->group,
-                                               newstate->ngroups * sizeof(char *));
-           newstate->group[newstate->ngroups-1] = xstrdup(grp->gr_name);
-       }
+    while (1) {
+      i = getgrent_r(&grp, buf, BUFLEN, &grpp);
+      if (i)
+       break;
+      for (mem = grpp->gr_mem; *mem; mem++) {
+       if (!strcmp(*mem, identifier)) break;
+      }
+      if (*mem || (pwdp && pwdp->pw_gid == grpp->gr_gid)) {
+       newstate->ngroups++;
+       newstate->group = (char **)xrealloc((char *)newstate->group,
+                                           newstate->ngroups * sizeof(char *));
+       newstate->group[newstate->ngroups-1] = xstrdup(grpp->gr_name);
+      }
      }
      endgrent();
+
      return newstate;
  }



More information about the Info-cyrus mailing list