diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-08 00:25:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-08 00:25:40 +0000 |
commit | 15f0e53a0698b5b7abd003f9cf305a456a98babc (patch) | |
tree | 702aed166aa207beef8ef266c9b005a0fdeba938 /process.c | |
parent | 487185de671234a650f43b2de16c9253171a3388 (diff) | |
download | bundler-15f0e53a0698b5b7abd003f9cf305a456a98babc.tar.gz |
* 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
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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; } } } |