develooper Front page | perl.perl5.porters | Postings from April 2003

nobody has uid -2 on OS X, this confuses getpwnam()

Thread Next
From:
Michael G Schwern
Date:
April 8, 2003 02:54
Subject:
nobody has uid -2 on OS X, this confuses getpwnam()
Message ID:
20030408095422.GA22743@windhund.schwern.org
Not really sure what to do about this:

$ grep nobody /etc/passwd
nobody:*:-2:-2:Unprivileged User:/dev/null:/dev/null
$ uname -a
Darwin windhund.schwern.org 6.4 Darwin Kernel Version 6.4: Wed Jan 29 18:50:42 PST 2003; root:xnu/xnu-344.26.obj~1/RELEASE_PPC  Power Macintosh powerpc
$ perl -wle 'print scalar getpwnam("nobody")'
4294967294

passwd in /usr/include/pwd.h looks normal:
struct passwd {
        char    *pw_name;               /* user name */
        char    *pw_passwd;             /* encrypted password */
        uid_t   pw_uid;                 /* user uid */
        gid_t   pw_gid;                 /* user gid */
        time_t  pw_change;              /* password change time */
        char    *pw_class;              /* user access class */
        char    *pw_gecos;              /* Honeywell login info */
        char    *pw_dir;                /* home directory */
        char    *pw_shell;              /* default shell */
        time_t  pw_expire;              /* account expiration */
};

and uid_t is defined in sys/types.h as:
typedef u_int32_t       uid_t;          /* user id */

and u_int32_t is in ppc/types.h as an unsigned int as you'd expect:
typedef unsigned int            u_int32_t;

As far as I can tell its perfectly normal for nobody to be set to
-2 on OS X, at least in Apple's universe.

I noticed this because it meant perldoc couldn't drop privledges.  It kept
trying to setuid to 2**32-2.


-- 
If I got anything to say, I'll say it with lead.
    -- Jon Wayne

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About