From: Sam Roberts Date: 2006-07-25T04:40:02+09:00 Subject: Re: Patch for Unix socket peer credentials On Sat, Jul 22, 2006 at 03:54:19PM +0900, Tanaka Akira wrote: > > Are negative values allowed on Linux? AFAICT, if the credentials aren't > > available on Linux, say when I check a TCPServer socket's credentials > > after accepting a connection from another host, the system call returns > > 0 but sets the uid & gid to -1: Whether allowed or not by the OS, returning -1 in the hash as :uid and :gid seems reasonable, it makes the Socket method behave like the underlying system call, so less surprising to users, and if they want to know what -1 means, they can read the man page for their system. At least some binutils don't seem to think a uid can be negative, GNU coreutils 5.93, id.c:print_user() ... printf ("%lu", (unsigned long int) uid) Perhaps more interesting to this list, ruby's File::chown doesn't allow -1 as a uid or gid, though it does allow other negative values: File.chown(owner_int, group_int, file_name,... ) -> integer ... A +nil+ or -1 owner or group id is ignored. ... root:/tmp # ruby -e'File.chown(-2, -2, "neg2")' root:/tmp # ls -l neg2 -rw-r--r-- 1 4294967294 4294967294 0 2006-07-24 12:15 neg2 root:/tmp # ruby -e'File.chown(-1, -3, "neg2")' root:/tmp # ls -l neg2 -rw-r--r-- 1 4294967294 4294967293 0 2006-07-24 12:15 neg2 root:/tmp # ruby -e'File.chown(-3, -1, "neg2")' root:/tmp # ls -l neg2 -rw-r--r-- 1 4294967293 4294967293 0 2006-07-24 12:15 neg2 Maybe only nil should be ignored? Cheers, Sam