Project

General

Profile

Backport #1068

Ruby Cannot Handle Some UIDs

Added by JEG2 (James Gray) over 10 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal

Description

=begin
This shows the main problem:

$ sudo ruby -r etc -e 'n = Etc.getpwnam("nobody"); p n.uid; Process.uid = n.uid'
Password:
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin9.4.0]
4294967294
-e:1:in uid=': bignum too big to convert intolong' (RangeError)
from -e:1

The real UID for the nobody user on my system (Mac OS X 10.5.6) is -2. Thus it seems at least some systems use signed UID's and Ruby can't handle that.

The above example is from Ruby 1.8.6. Ruby 1.9 does seem to properly switch users, but it still shows the UID's incorrectly:

$ sudo ruby_dev -v -r etc -e 'n = Etc.getpwnam("nobody"); p n.uid; Process.uid = n.uid; p Process.uid; p Etc.getpwuid(Process.uid)'
ruby 1.9.1 (2008-12-30 patchlevel-0 revision 21203) [i386-darwin9.6.0]
4294967294
4294967294
#
=end

History

#1

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

=begin
Hi,

At Thu, 29 Jan 2009 01:23:48 +0900,
Ondrej Bilka wrote in [ruby-core:21642]:

Any reason why not handle UID and GID as signed?

Because they are defined as unsigned on that platform.

--
Nobu Nakada

=end

#2

Updated by shyouhei (Shyouhei Urabe) over 10 years ago

=begin
Ondrej Bilka wrote:

On Thu, Jan 29, 2009 at 08:53:38AM +0100, Nobuyoshi Nakada wrote:

Hi,

At Thu, 29 Jan 2009 01:23:48 +0900,
Ondrej Bilka wrote in [ruby-core:21642]:

Any reason why not handle UID and GID as signed?
Because they are defined as unsigned on that platform.
This can be ignored. It would only display incrorectly UIDs > 2000000000

Out of curiousity, on what basis you can believe that display (and ignore your
header instead)? I'd wather ignore that display and believe what header says
if I had such OS.

=end

#3

Updated by ko1 (Koichi Sasada) over 10 years ago

  • Assignee set to shyouhei (Shyouhei Urabe)
  • ruby -v set to ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin9.4.0]

=begin

=end

#4

Updated by shyouhei (Shyouhei Urabe) almost 9 years ago

  • Status changed from Open to Assigned

=begin

=end

#5

Updated by shyouhei (Shyouhei Urabe) over 2 years ago

  • Status changed from Assigned to Closed

Also available in: Atom PDF