Changeset 451a0e07f83d6599e8716c96d353c9737726a91b

Show
Ignore:
Timestamp:
09/09/08 17:08:23 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1220980103 +0000
git-parent:

[6e87939280730807a0a6d7da385a756a72fbde13]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1220980103 +0000
Message:

better detection and correct use of POSIX.1c getpwnam_r

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • aclocal.m4

    r1ba4732 r451a0e0  
    1010 
    1111AC_MSG_CHECKING(for POSIX.1c getpwnam_r) 
    12 AC_TRY_COMPILE([ 
     12AC_TRY_LINK([ 
    1313#include <pwd.h> 
    1414#include <stdlib.h>], 
    15   getpwnam_r(NULL,NULL,NULL,0);, 
     15  getpwnam_r(NULL,NULL,NULL,0,NULL);, 
    1616  AC_DEFINE(HAVE_GETPWNAM_R_POSIX,1,POSIX.1c getpwnam_r) 
    1717  AC_MSG_RESULT(yes), 
     
    2828 
    2929AC_MSG_CHECKING(for POSIX.1c getgrnam_r) 
    30 AC_TRY_COMPILE([ 
     30AC_TRY_LINK([ 
    3131#include <grp.h> 
    3232#include <stdlib.h>], 
    33   getgrnam_r(NULL,NULL,NULL,0);, 
     33  getgrnam_r(NULL,NULL,NULL,0,NULL);, 
    3434  AC_DEFINE(HAVE_GETGRNAM_R_POSIX,1,POSIX.1c getgrnam_r) 
    3535  AC_MSG_RESULT(yes), 
  • configure.in

    r66c613e r451a0e0  
    280280                 stropts.h sys/stream.h alloca.h sys/wait.h) 
    281281 
     282AC_CHECK_FUNCS(getpwnam_r) 
    282283GETPWNAM_R_POSIX 
     284AC_CHECK_FUNCS(getgrnam_r) 
    283285GETGRNAM_R_POSIX 
    284286 
  • src/noit_config.h.in

    r4bd337d r451a0e0  
    8181#undef WORKING_SEM_INIT 
    8282 
     83#undef HAVE_GETPWNAM_R 
     84#undef HAVE_GETPWNAM_R_POSIX 
     85#undef HAVE_GETGRNAM_R 
     86#undef HAVE_GETGRNAM_R_POSIX 
     87 
    8388#ifdef HAVE_STRING_H 
    8489#include <string.h> 
  • src/utils/noit_security.c

    r1ba4732 r451a0e0  
    4444             char *buf, size_t len) { 
    4545#ifdef HAVE_GETPWNAM_R_POSIX 
    46   return getpwnam_r(user, pw, buf, len); 
    47 #else 
    4846  struct passwd *r; 
    4947  if(0 == getpwnam_r(user, pw, buf, len, &r)) return r; 
    5048  return NULL; 
     49#else 
     50#if HAVE_GETPWNAM_R 
     51  return getpwnam_r(user, pw, buf, len); 
     52#else 
     53  return getpwnam(user); 
     54#endif 
    5155#endif 
    5256} 
     
    5559             char *buf, size_t len) { 
    5660#ifdef HAVE_GETGRNAM_R_POSIX 
    57   return getgrnam_r(group, gr, buf, len); 
    58 #else 
    5961  struct group *r; 
    6062  if(0 == getgrnam_r(group, gr, buf, len, &r)) return r; 
    6163  return NULL; 
     64#else 
     65#ifdef HAVE_GETGRNAM_R 
     66  return getgrnam_r(group, gr, buf, len); 
     67#else 
     68  return getgrnam(group); 
     69#endif 
    6270#endif 
    6371} 
     
    6775  static long pwnam_buflen = 0; 
    6876  static long grnam_buflen = 0; 
    69   uid_t uid
    70   gid_t gid
     77  uid_t uid = 0
     78  gid_t gid = 0
    7179 
    72   if(pwnam_buflen == 0) pwnam_buflen = sysconf(_SC_GETPW_R_SIZE_MAX); 
    73   if(grnam_buflen == 0) grnam_buflen = sysconf(_SC_GETGR_R_SIZE_MAX); 
     80  if(pwnam_buflen == 0) 
     81#ifdef _SC_GETPW_R_SIZE_MAX 
     82    pwnam_buflen = sysconf(_SC_GETPW_R_SIZE_MAX); 
     83#else 
     84    pwnam_buflen = 100; /* This shouldn't be used, so size is not important. */ 
     85#endif 
     86  if(grnam_buflen == 0) 
     87#ifdef _SC_GETGR_R_SIZE_MAX 
     88    grnam_buflen = sysconf(_SC_GETGR_R_SIZE_MAX); 
     89#else 
     90    grnam_buflen = 100; 
     91#endif 
    7492 
    7593  if(user) {