зеркало из https://github.com/github/ruby.git
* process.c (obj2gid): use getgrnum_r() only if getgrnam_r() and
_SC_GETGR_R_SIZE_MAX is available. MirOS BSD (MirBSD 10 GENERIC#1382 i386) have getgrnam_r() but no _SC_GETGR_R_SIZE_MAX. (obj2uid): use getpwnam_r() only if getpwnam_r() and _SC_GETPW_R_SIZE_MAX is available. This is consistency for obj2gid. MirOS BSD have neither getpwnam_r() nor _SC_GETPW_R_SIZE_MAX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
8f5f89452d
Коммит
9b0a7f493e
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Fri Feb 8 00:02:48 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* process.c (obj2gid): use getgrnum_r() only if getgrnam_r() and
|
||||||
|
_SC_GETGR_R_SIZE_MAX is available.
|
||||||
|
MirOS BSD (MirBSD 10 GENERIC#1382 i386) have getgrnam_r() but
|
||||||
|
no _SC_GETGR_R_SIZE_MAX.
|
||||||
|
(obj2uid): use getpwnam_r() only if getpwnam_r() and
|
||||||
|
_SC_GETPW_R_SIZE_MAX is available.
|
||||||
|
This is consistency for obj2gid.
|
||||||
|
MirOS BSD have neither getpwnam_r() nor _SC_GETPW_R_SIZE_MAX.
|
||||||
|
|
||||||
Thu Feb 7 22:01:18 2013 Tanaka Akira <akr@fsij.org>
|
Thu Feb 7 22:01:18 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* configure.in: define linker for shared library on MirOS BSD.
|
* configure.in: define linker for shared library on MirOS BSD.
|
||||||
|
|
26
process.c
26
process.c
|
@ -145,7 +145,10 @@ static void check_gid_switch(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_PWD_H)
|
#if defined(HAVE_PWD_H)
|
||||||
# ifdef HAVE_GETPWNAM_R
|
# if defined(HAVE_GETPWNAM_R) && defined(HAVE_GETPWNAM_R)
|
||||||
|
# define USE_GETPWNAM_R 1
|
||||||
|
# endif
|
||||||
|
# ifdef USE_GETPWNAM_R
|
||||||
# define PREPARE_GETPWNAM \
|
# define PREPARE_GETPWNAM \
|
||||||
long getpw_buf_len = sysconf(_SC_GETPW_R_SIZE_MAX); \
|
long getpw_buf_len = sysconf(_SC_GETPW_R_SIZE_MAX); \
|
||||||
char *getpw_buf = ALLOCA_N(char, (getpw_buf_len < 0 ? (getpw_buf_len = 4096) : getpw_buf_len));
|
char *getpw_buf = ALLOCA_N(char, (getpw_buf_len < 0 ? (getpw_buf_len = 4096) : getpw_buf_len));
|
||||||
|
@ -166,7 +169,10 @@ static rb_uid_t obj2uid(VALUE id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_GRP_H)
|
#if defined(HAVE_GRP_H)
|
||||||
# ifdef HAVE_GETGRNAM_R
|
# if defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
|
||||||
|
# define USE_GETGRNAM_R
|
||||||
|
# endif
|
||||||
|
# ifdef USE_GETGRNAM_R
|
||||||
# define PREPARE_GETGRNAM \
|
# define PREPARE_GETGRNAM \
|
||||||
long getgr_buf_len = sysconf(_SC_GETGR_R_SIZE_MAX); \
|
long getgr_buf_len = sysconf(_SC_GETGR_R_SIZE_MAX); \
|
||||||
char *getgr_buf = ALLOCA_N(char, (getgr_buf_len < 0 ? (getgr_buf_len = 4096) : getgr_buf_len));
|
char *getgr_buf = ALLOCA_N(char, (getgr_buf_len < 0 ? (getgr_buf_len = 4096) : getgr_buf_len));
|
||||||
|
@ -4726,7 +4732,7 @@ check_gid_switch(void)
|
||||||
#if defined(HAVE_PWD_H)
|
#if defined(HAVE_PWD_H)
|
||||||
static rb_uid_t
|
static rb_uid_t
|
||||||
obj2uid(VALUE id
|
obj2uid(VALUE id
|
||||||
# ifdef HAVE_GETPWNAM_R
|
# ifdef USE_GETPWNAM_R
|
||||||
, char *getpw_buf, size_t getpw_buf_len
|
, char *getpw_buf, size_t getpw_buf_len
|
||||||
# endif
|
# endif
|
||||||
)
|
)
|
||||||
|
@ -4740,7 +4746,7 @@ obj2uid(VALUE id
|
||||||
else {
|
else {
|
||||||
const char *usrname = StringValueCStr(id);
|
const char *usrname = StringValueCStr(id);
|
||||||
struct passwd *pwptr;
|
struct passwd *pwptr;
|
||||||
#ifdef HAVE_GETPWNAM_R
|
#ifdef USE_GETPWNAM_R
|
||||||
struct passwd pwbuf;
|
struct passwd pwbuf;
|
||||||
if (getpwnam_r(usrname, &pwbuf, getpw_buf, getpw_buf_len, &pwptr))
|
if (getpwnam_r(usrname, &pwbuf, getpw_buf, getpw_buf_len, &pwptr))
|
||||||
rb_sys_fail("getpwnam_r");
|
rb_sys_fail("getpwnam_r");
|
||||||
|
@ -4748,13 +4754,13 @@ obj2uid(VALUE id
|
||||||
pwptr = getpwnam(usrname);
|
pwptr = getpwnam(usrname);
|
||||||
#endif
|
#endif
|
||||||
if (!pwptr) {
|
if (!pwptr) {
|
||||||
#ifndef HAVE_GETPWNAM_R
|
#ifndef USE_GETPWNAM_R
|
||||||
endpwent();
|
endpwent();
|
||||||
#endif
|
#endif
|
||||||
rb_raise(rb_eArgError, "can't find user for %s", usrname);
|
rb_raise(rb_eArgError, "can't find user for %s", usrname);
|
||||||
}
|
}
|
||||||
uid = pwptr->pw_uid;
|
uid = pwptr->pw_uid;
|
||||||
#ifndef HAVE_GETPWNAM_R
|
#ifndef USE_GETPWNAM_R
|
||||||
endpwent();
|
endpwent();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -4774,7 +4780,7 @@ p_uid_from_name(VALUE self, VALUE id)
|
||||||
#if defined(HAVE_GRP_H)
|
#if defined(HAVE_GRP_H)
|
||||||
static rb_gid_t
|
static rb_gid_t
|
||||||
obj2gid(VALUE id
|
obj2gid(VALUE id
|
||||||
# ifdef HAVE_GETGRNAM_R
|
# ifdef USE_GETGRNAM_R
|
||||||
, char *getgr_buf, size_t getgr_buf_len
|
, char *getgr_buf, size_t getgr_buf_len
|
||||||
# endif
|
# endif
|
||||||
)
|
)
|
||||||
|
@ -4788,7 +4794,7 @@ obj2gid(VALUE id
|
||||||
else {
|
else {
|
||||||
const char *grpname = StringValueCStr(id);
|
const char *grpname = StringValueCStr(id);
|
||||||
struct group *grptr;
|
struct group *grptr;
|
||||||
#ifdef HAVE_GETGRNAM_R
|
#ifdef USE_GETGRNAM_R
|
||||||
struct group grbuf;
|
struct group grbuf;
|
||||||
if (getgrnam_r(grpname, &grbuf, getgr_buf, getgr_buf_len, &grptr))
|
if (getgrnam_r(grpname, &grbuf, getgr_buf, getgr_buf_len, &grptr))
|
||||||
rb_sys_fail("getgrnam_r");
|
rb_sys_fail("getgrnam_r");
|
||||||
|
@ -4796,13 +4802,13 @@ obj2gid(VALUE id
|
||||||
grptr = getgrnam(grpname);
|
grptr = getgrnam(grpname);
|
||||||
#endif
|
#endif
|
||||||
if (!grptr) {
|
if (!grptr) {
|
||||||
#ifndef HAVE_GETGRNAM_R
|
#ifndef USE_GETGRNAM_R
|
||||||
endgrent();
|
endgrent();
|
||||||
#endif
|
#endif
|
||||||
rb_raise(rb_eArgError, "can't find group for %s", grpname);
|
rb_raise(rb_eArgError, "can't find group for %s", grpname);
|
||||||
}
|
}
|
||||||
gid = grptr->gr_gid;
|
gid = grptr->gr_gid;
|
||||||
#ifndef HAVE_GETGRNAM_R
|
#ifndef USE_GETGRNAM_R
|
||||||
endgrent();
|
endgrent();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче