apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sander Stoks" <san...@stoks.nl>
Subject BeOS patch
Date Wed, 17 Sep 2003 20:17:00 GMT

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 

On the other hand, BeOS _does_ implement getpwuid, and since the 
"current uid" is always "0" for all practical purposes, doing the 

    /* 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);
    if ((pwptr = getpwnam(username)) != NULL) {
        memcpy(pw, pwptr, sizeof *pw);

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

View raw message