diff options
author | Joe Orton <jorton@apache.org> | 2005-08-24 08:56:03 +0000 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2005-08-24 08:56:03 +0000 |
commit | ad51f9183d42845cab618618cc590ce59b701efe (patch) | |
tree | 2141b66d877cebe43b5ca65503eb2a557b20b138 /user | |
parent | 123a9a81f5de530639eedb1b3feccf7d314362ea (diff) | |
download | apr-ad51f9183d42845cab618618cc590ce59b701efe.tar.gz |
* user/unix/userinfo.c (getpwnam_safe, apr_uid_name_get): Fix error
handling for platforms which do not set errno on non-threadsafe
get{pw,gr}* failures; always return APR_ENOENT for that case.
* user/unix/groupinfo.c (apr_gid_name_get, apr_gid_get): Likewise.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@239574 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'user')
-rw-r--r-- | user/unix/groupinfo.c | 6 | ||||
-rw-r--r-- | user/unix/userinfo.c | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/user/unix/groupinfo.c b/user/unix/groupinfo.c index 9f556b20f..8bf97691c 100644 --- a/user/unix/groupinfo.c +++ b/user/unix/groupinfo.c @@ -47,8 +47,9 @@ APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, apr_gid_t groupid, return APR_ENOENT; } #else + errno = 0; if ((gr = getgrgid(groupid)) == NULL) { - return errno; + return errno ? errno : APR_ENOENT; } #endif *groupname = apr_pstrdup(p, gr->gr_name); @@ -74,8 +75,9 @@ APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, return APR_ENOENT; } #else + errno = 0; if ((gr = getgrnam(groupname)) == NULL) { - return errno; + return errno ? errno : APR_ENOENT; } #endif *groupid = gr->gr_gid; diff --git a/user/unix/userinfo.c b/user/unix/userinfo.c index c2a7a1f95..3eb74113b 100644 --- a/user/unix/userinfo.c +++ b/user/unix/userinfo.c @@ -53,15 +53,14 @@ static apr_status_t getpwnam_safe(const char *username, return APR_ENOENT; } #else + /* Some platforms (e.g. FreeBSD 4.x) do not set errno on NULL "not + * found" return values for the non-threadsafe function either. */ + errno = 0; if ((pwptr = getpwnam(username)) != NULL) { memcpy(pw, pwptr, sizeof *pw); } else { - if (errno == 0) { - /* this can happen with getpwnam() on FreeBSD 4.3 */ - return APR_EGENERAL; - } - return errno; + return errno ? errno : APR_ENOENT; } #endif return APR_SUCCESS; @@ -137,8 +136,9 @@ APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, } #else + errno = 0; if ((pw = getpwuid(userid)) == NULL) { - return errno; + return errno ? errno : APR_ENOENT; } #endif *username = apr_pstrdup(p, pw->pw_name); |