summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--user/unix/groupinfo.c6
-rw-r--r--user/unix/userinfo.c12
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);