Ticket #274: email2trac-2.4.2.patch

File email2trac-2.4.2.patch, 1.3 KB (added by Dennis McRitchie <dmcr@…>, 13 years ago)

Patch to support supplementary groups in run_email2trac

  • run_email2trac.c

    old new  
    2626# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
    2727#
    2828*/
     29#include <sys/types.h>
    2930#include <stdlib.h>
    3031#include <unistd.h>
    3132#include <pwd.h>
     
    3334#include <string.h>
    3435#include <stdio.h>
    3536#include <limits.h>
     37#include <grp.h>
    3638
    3739#include "run_email2trac.h"
    3840
     
    106108    return -2;     /* 254 : Invalid caller */
    107109  }
    108110 
    109   /* set UID/GID to Trac (or apache) user */
     111  /* set UID/GID and supplementary groups to be Trac (or apache) user */
    110112  check_username(TRAC_USER);
    111113  if ( TRAC = getpwnam(TRAC_USER) ) {
     114    if (initgroups(TRAC_USER, TRAC->pw_gid)) {
     115      if ( DEBUG ) printf("initgroups failed\n");
     116      return -7;    /* 249 : Can't set supplementary groups */
     117    }
    112118    if (setgid(TRAC->pw_gid) || setuid(TRAC->pw_uid)) {
    113119      if ( DEBUG ) printf("setgid or setuid failed\n");
    114       return -5;
     120      return -5;   /* 251: Can't set gid or uid */
    115121    }
    116122  } else {
    117123    if ( DEBUG ) printf("Invalid Trac user (%s)\n",TRAC_USER);
    118     return -3;     /* 253 : Trac user not found */
     124    return -6;     /* 250 : Trac user not found */
    119125  }
    120126         
    121127  /* Check that script exists */