Subject: Re: endianness-agnostic getpwent()
To: Andrew Brown <atatat@atatdot.net>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-userlevel
Date: 11/13/2000 12:09:50
Andrew Brown wrote:
> >> This would not be too hard if dbopen()/DB would provide a way to find
> >> out the endiannes of the database.
> >
> >Better solutions would be to either use network byte order all keys, or
> >use ASCII keys instead of binary keys. The problem with any solution
> >is that you still need to keep native byte-order keys to support older
> >statically linked programs.
> >
> >And yes, I agree that not knowing the endianness of the database is a
> >bit of a pain...
>
> my pr, my solution, and now...my two cents.
>
> i was particularly amused at the time to see that even files owned by
> root were shown as owned by 0. so...how exactly are uids stored in
> the file? i always thought the little and big endian byte order
> representations of 0 were 0, regardless of the host endianness.
One representation stored in the passwd databases is "PW_KEYBYNUM" which
is the entries by sequence number. However this starts at 1 instead of
0. Perhaps whatever library routine that ls(1) uses to do the lookup
ends up using getpwent() instead of getpwuid() (or something like that).
Simon.
--
Simon Burge <simonb@wasabisystems.com>
NetBSD Sales, Support and Service: http://www.wasabisystems.com/