Changeset 574 for trunk/run_email2trac.c


Ignore:
Timestamp:
10/20/11 09:20:17 (13 years ago)
Author:
bas
Message:

added support for initgroup, thanks to Dennis McRitchie?,
closes #274

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/run_email2trac.c

    r318 r574  
    2727#
    2828*/
     29#include "config.h"
     30
     31#include <sys/types.h>
    2932#include <stdlib.h>
    3033#include <unistd.h>
     
    3437#include <stdio.h>
    3538#include <limits.h>
     39#ifdef HAVE_INITGROUPS
     40#include <grp.h>
     41#endif
    3642
    3743#include "run_email2trac.h"
     
    107113  }
    108114 
    109   /* set UID/GID to Trac (or apache) user */
     115  /* set UID/GID and supplementary groups to be Trac (or apache) user */
    110116  check_username(TRAC_USER);
    111117  if ( TRAC = getpwnam(TRAC_USER) ) {
     118#ifdef HAVE_INITGROUPS
     119    if (initgroups(TRAC_USER, TRAC->pw_gid)) {
     120      if ( DEBUG ) printf("initgroups failed\n");
     121      return -7;    /* 249 : Can't set supplementary groups */
     122    }
     123#endif
    112124    if (setgid(TRAC->pw_gid) || setuid(TRAC->pw_uid)) {
    113125      if ( DEBUG ) printf("setgid or setuid failed\n");
    114       return -5;
     126      return -5;   /* 251: Can't set gid or uid */
    115127    }
    116128  } else {
    117129    if ( DEBUG ) printf("Invalid Trac user (%s)\n",TRAC_USER);
    118     return -3;     /* 253 : Trac user not found */
     130    return -6;     /* 250 : Trac user not found */
    119131  }
    120132         
Note: See TracChangeset for help on using the changeset viewer.