Hello,
While building Subversion, a source control system which uses APR, I
found an issue which I could trace back to getpwnam_safe() on BeOS.
The problem is that BeOS doesn't properly implement multi-user support,
so the built-in getpwnam() always returns 0. One could say that it is
up to the clients of the library to handle this, and I would agree that
it is a bug of Subversion that it doesn't (in the getpwnam_safe()
function in userinfo.c, I see a comment about FreeBSD 4.3 even leaving
errno zero in that case, so it is something clients need to be aware
of).
On the other hand, BeOS _does_ implement getpwuid, and since the
"current uid" is always "0" for all practical purposes, doing the
following:
#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) &&
defined(HAVE_GETPWNAM_R)
/* IRIX getpwnam_r() returns 0 and sets pwptr to NULL on failure */
if (!getpwnam_r(username, pw, pwbuf, PWBUF_SIZE, &pwptr) && pwptr)
{
/* nothing extra to do on success */
#elif __BEOS__
if ((pwptr = getpwuid(0)) != NULL) {
memcpy(pw, pwptr, sizeof *pw);
#else
if ((pwptr = getpwnam(username)) != NULL) {
memcpy(pw, pwptr, sizeof *pw);
#endif
makes things work on my system. It is (marginally) less-than-ideal,
because a program _can_ call setuid() and have it work as expected, but
there is no way to link a uid to a username on BeOS - it is essentially
a single-user system.
Any thoughts on this patch?
Thanks in advance,
Sander Stoks