ruby-changes:27536
From: nagachika <ko1@a...>
Date: Tue, 5 Mar 2013 01:05:32 +0900 (JST)
Subject: [ruby-changes:27536] nagachika:r39588 (ruby_2_0_0): merge revision(s) 39349,39374: [Backport #7886]
nagachika 2013-03-05 01:04:53 +0900 (Tue, 05 Mar 2013) New Revision: 39588 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39588 Log: merge revision(s) 39349,39374: [Backport #7886] * file.c (rb_group_member): get rid of NGROUPS dependency. [Bug #7886] [ruby-core:52537] Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/file.c branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 39587) +++ ruby_2_0_0/ChangeLog (revision 39588) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Tue Mar 5 01:03:16 2013 KOSAKI Motohiro <kosaki.motohiro@g...> + + * file.c (rb_group_member): get rid of NGROUPS dependency. + [Bug #7886] [ruby-core:52537] + Tue Mar 5 00:16:56 2013 Eric Hodel <drbrain@s...> * ext/openssl/ossl.c (class OpenSSL): Use only inner parenthesis in Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 39587) +++ ruby_2_0_0/version.h (revision 39588) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-03-05" -#define RUBY_PATCHLEVEL 17 +#define RUBY_PATCHLEVEL 18 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_0_0/file.c =================================================================== --- ruby_2_0_0/file.c (revision 39587) +++ ruby_2_0_0/file.c (revision 39588) @@ -1013,39 +1013,52 @@ rb_file_lstat(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/file.c#L1013 #endif } +/* Linux allow 65536 groups and it is maximum value as far as we know. */ +#define RUBY_GROUP_MAX 65536 + static int rb_group_member(GETGROUPS_T gid) { +#ifdef _WIN32 + return FALSE; +#else int rv = FALSE; -#ifndef _WIN32 + int groups = 16; + VALUE v = 0; + GETGROUPS_T *gary; + int anum; + if (getgid() == gid || getegid() == gid) return TRUE; -# ifdef HAVE_GETGROUPS -# ifndef NGROUPS -# ifdef NGROUPS_MAX -# define NGROUPS NGROUPS_MAX -# else -# define NGROUPS 32 -# endif -# endif - { - GETGROUPS_T *gary; - int anum; - - gary = xmalloc(NGROUPS * sizeof(GETGROUPS_T)); - anum = getgroups(NGROUPS, gary); - while (--anum >= 0) { - if (gary[anum] == gid) { - rv = TRUE; - break; - } + /* + * On Mac OS X (Mountain Lion), NGROUPS is 16. But libc and kernel + * accept more larger value. + * So we don't trunk NGROUPS anymore. + */ + while (groups <= RUBY_GROUP_MAX) { + gary = ALLOCV_N(GETGROUPS_T, v, groups); + anum = getgroups(groups, gary); + if (anum != groups) + break; + groups *= 2; + if (v) { + ALLOCV_END(v); + v = 0; } - xfree(gary); } -# endif -#endif + + while (--anum >= 0) { + if (gary[anum] == gid) { + rv = TRUE; + break; + } + } + if (v) + ALLOCV_END(v); + return rv; +#endif } #ifndef S_IXUGO Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r39330-39331,39349,39374 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/