зеркало из https://github.com/github/ruby.git
* process.c (proc_setgroups): use getgrnam() if getgrnam_r() is
not available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
487185de67
Коммит
15f0e53a06
|
@ -1,4 +1,7 @@
|
|||
Tue Mar 8 09:08:00 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Tue Mar 8 09:25:23 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* process.c (proc_setgroups): use getgrnam() if getgrnam_r() is
|
||||
not available.
|
||||
|
||||
* process.c: RARRAY_LEN() returns long int.
|
||||
|
||||
|
|
|
@ -1306,7 +1306,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall __syscall chroot ge
|
|||
setitimer setruid seteuid setreuid setresuid setproctitle socketpair\
|
||||
setrgid setegid setregid setresgid issetugid pause lchown lchmod\
|
||||
getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
|
||||
getpriority getrlimit setrlimit sysconf close\
|
||||
getpriority getrlimit setrlimit sysconf close getgrnam_r\
|
||||
dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp\
|
||||
setsid telldir seekdir fchmod cosh sinh tanh log2 round\
|
||||
setuid setgid daemon select_large_fdset setenv unsetenv\
|
||||
|
|
12
process.c
12
process.c
|
@ -4626,12 +4626,14 @@ proc_setgroups(VALUE obj, VALUE ary)
|
|||
{
|
||||
int ngroups, i;
|
||||
rb_gid_t *groups;
|
||||
#ifdef HAVE_GETGRNAM_R
|
||||
long getgr_buf_len = sysconf(_SC_GETGR_R_SIZE_MAX);
|
||||
char* getgr_buf;
|
||||
|
||||
if (getgr_buf_len < 0)
|
||||
getgr_buf_len = 4096;
|
||||
getgr_buf = ALLOCA_N(char, getgr_buf_len);
|
||||
#endif
|
||||
|
||||
Check_Type(ary, T_ARRAY);
|
||||
|
||||
|
@ -4657,16 +4659,20 @@ proc_setgroups(VALUE obj, VALUE ary)
|
|||
groups[i] = NUM2GIDT(g);
|
||||
}
|
||||
else {
|
||||
StringValue(tmp);
|
||||
const char *grpname = StringValueCStr(tmp);
|
||||
|
||||
ret = getgrnam_r(RSTRING_PTR(tmp), &grp, getgr_buf, getgr_buf_len, &p);
|
||||
#ifdef HAVE_GETGRNAM_R
|
||||
ret = getgrnam_r(grpname, &grp, getgr_buf, getgr_buf_len, &p);
|
||||
if (ret)
|
||||
rb_sys_fail("getgrnam_r");
|
||||
#else
|
||||
p = getgrnam(grpname);
|
||||
#endif
|
||||
if (p == NULL) {
|
||||
rb_raise(rb_eArgError,
|
||||
"can't find group for %s", RSTRING_PTR(tmp));
|
||||
}
|
||||
groups[i] = grp.gr_gid;
|
||||
groups[i] = p->gr_gid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче