From: nobu@... Date: 2006-06-27T02:08:15+09:00 Subject: Re: Large uid's with Etc.getpwnam Hi, At Tue, 27 Jun 2006 00:06:18 +0900, Ryan McGovern wrote in [ruby-talk:199102]: > I beleve there is a bug in Etc.getpwnam. On our OS X server > running 10.4 with ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] > we use AD for user management. Does this help? * ext/etc/etc.c (setup_passwd, setup_group): allow bignum uid, gid and so on. [ruby-talk:199102] Index: ext/etc/etc.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/etc/etc.c,v retrieving revision 1.22 diff -p -u -2 -r1.22 etc.c --- ext/etc/etc.c 20 Jun 2006 18:02:14 -0000 1.22 +++ ext/etc/etc.c 26 Jun 2006 16:53:48 -0000 @@ -77,6 +77,6 @@ setup_passwd(struct passwd *pwd) safe_setup_str(pwd->pw_passwd), #endif - INT2FIX(pwd->pw_uid), - INT2FIX(pwd->pw_gid), + PW_UID2VAL(pwd->pw_uid), + PW_GID2VAL(pwd->pw_gid), #ifdef HAVE_ST_PW_GECOS safe_setup_str(pwd->pw_gecos), @@ -85,8 +85,8 @@ setup_passwd(struct passwd *pwd) safe_setup_str(pwd->pw_shell), #ifdef HAVE_ST_PW_CHANGE - INT2FIX(pwd->pw_change), + INT2NUM(pwd->pw_change), #endif #ifdef HAVE_ST_PW_QUOTA - INT2FIX(pwd->pw_quota), + INT2NUM(pwd->pw_quota), #endif #ifdef HAVE_ST_PW_AGE @@ -100,5 +100,5 @@ setup_passwd(struct passwd *pwd) #endif #ifdef HAVE_ST_PW_EXPIRE - INT2FIX(pwd->pw_expire), + INT2NUM(pwd->pw_expire), #endif 0 /*dummy*/ @@ -302,5 +302,5 @@ setup_group(struct group *grp) safe_setup_str(grp->gr_passwd), #endif - INT2FIX(grp->gr_gid), + PW_GID2VAL(grp->gr_gid), mem); } Index: ext/etc/extconf.rb =================================================================== RCS file: /cvs/ruby/src/ruby/ext/etc/extconf.rb,v retrieving revision 1.6 diff -p -u -2 -r1.6 extconf.rb --- ext/etc/extconf.rb 6 Sep 2005 23:35:15 -0000 1.6 +++ ext/etc/extconf.rb 26 Jun 2006 17:05:23 -0000 @@ -25,5 +25,18 @@ if a or b or c have_struct_member('struct passwd', 'pw_passwd', 'pwd.h') have_struct_member('struct group', 'gr_passwd', 'grp.h') - have_type("uid_t"); + have_header("lastlog.h") and have_header("paths.h") + [%w"uid_t pwd.h", %w"gid_t grp.h"].each do |t, h| + if have_type(t, ["sys/types.h", h]) + if try_static_assert("sizeof(#{t}) > sizeof(long)") + f = "LL2NUM" + else + f = "INT2NUM" + end + if try_static_assert("(#{t})-1 > 0") + f = "U#{f}" + end + $defs.push("-DPW_#{t.chomp('_t').upcase}2VAL=#{f}") + end + end create_makefile("etc") end -- Nobu Nakada