You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2005/08/24 10:56:06 UTC

svn commit: r239574 - in /apr/apr/trunk/user/unix: groupinfo.c userinfo.c

Author: jorton
Date: Wed Aug 24 01:56:03 2005
New Revision: 239574

URL: http://svn.apache.org/viewcvs?rev=239574&view=rev
Log:
* 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.

Modified:
    apr/apr/trunk/user/unix/groupinfo.c
    apr/apr/trunk/user/unix/userinfo.c

Modified: apr/apr/trunk/user/unix/groupinfo.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/user/unix/groupinfo.c?rev=239574&r1=239573&r2=239574&view=diff
==============================================================================
--- apr/apr/trunk/user/unix/groupinfo.c (original)
+++ apr/apr/trunk/user/unix/groupinfo.c Wed Aug 24 01:56:03 2005
@@ -47,8 +47,9 @@
         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 @@
         return APR_ENOENT;
     }
 #else
+    errno = 0;
     if ((gr = getgrnam(groupname)) == NULL) {
-        return errno;
+        return errno ? errno : APR_ENOENT;
     }
 #endif
     *groupid = gr->gr_gid;

Modified: apr/apr/trunk/user/unix/userinfo.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/user/unix/userinfo.c?rev=239574&r1=239573&r2=239574&view=diff
==============================================================================
--- apr/apr/trunk/user/unix/userinfo.c (original)
+++ apr/apr/trunk/user/unix/userinfo.c Wed Aug 24 01:56:03 2005
@@ -53,15 +53,14 @@
         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 @@
     }
 
 #else
+    errno = 0;
     if ((pw = getpwuid(userid)) == NULL) {
-        return errno;
+        return errno ? errno : APR_ENOENT;
     }
 #endif
     *username = apr_pstrdup(p, pw->pw_name);