From 960d7c012f70fb8b72e69b6f01473eb2852e7fe4 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Mon, 13 Nov 2000 03:18:18 +0000 Subject: [PATCH] add apr_get_home_directory(), teach mod_userdir to use that instead of calling getpwnam[_r] directly, back out mod_userdir's config check for getpwnam_r git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86932 13f79535-47bb-0310-9956-ffa450edef68 --- modules/aaa/config.m4 | 4 +--- modules/mappers/mod_userdir.c | 34 +++++++++++++--------------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/modules/aaa/config.m4 b/modules/aaa/config.m4 index 7bf261a28e..9aaa782cc1 100644 --- a/modules/aaa/config.m4 +++ b/modules/aaa/config.m4 @@ -25,9 +25,7 @@ APACHE_CHECK_STANDARD_MODULE(asis, as-is filetypes, , yes) APACHE_CHECK_STANDARD_MODULE(imap, internal imagemaps, , yes) APACHE_CHECK_STANDARD_MODULE(actions, Action triggering on requests, action, yes) APACHE_CHECK_STANDARD_MODULE(speling, correct common URL misspellings, , no) -APACHE_CHECK_STANDARD_MODULE(userdir, mapping of user requests, , yes, [ - AC_CHECK_FUNCS(getpwnam_r) -]) +APACHE_CHECK_STANDARD_MODULE(userdir, mapping of user requests, , yes) APACHE_CHECK_STANDARD_MODULE(suexec, set uid and gid for spawned processes, , no) APACHE_CHECK_STANDARD_MODULE(alias, translation of requests, , yes) diff --git a/modules/mappers/mod_userdir.c b/modules/mappers/mod_userdir.c index 56c236d54f..c173272075 100644 --- a/modules/mappers/mod_userdir.c +++ b/modules/mappers/mod_userdir.c @@ -96,6 +96,7 @@ #endif #include "apr_strings.h" +#include "apr_user.h" #include "ap_config.h" #include "httpd.h" #include "http_config.h" @@ -103,9 +104,6 @@ #ifdef HAVE_UNIX_SUEXEC #include "unixd.h" /* Contains the suexec_identity hook used on Unix */ #endif -#ifdef HAVE_PWD_H -#include -#endif #ifdef HAVE_UNISTD_H #include #endif @@ -320,29 +318,23 @@ static int translate_userdir(request_rec *r) return HTTP_MOVED_TEMPORARILY; } else { -#ifdef WIN32 - /* Need to figure out home dirs on NT */ - return DECLINED; -#else /* WIN32 */ - struct passwd *pw; - -#if APR_HAS_THREADS && defined(HAVE_GETPWNAM_R) - struct passwd pwd; - size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); - char *buf = apr_pcalloc(r->pool, buflen); +#if APR_HAS_USER + char *homedir; - if (!getpwnam_r(w, &pwd, buf, buflen, &pw)) { -#else - if ((pw = getpwnam(w))) { -#endif -#ifdef OS2 + if (apr_get_home_directory(&homedir, w, r->pool) == APR_SUCCESS) { +#ifdef OS2 /* XXX should this OS/2 logic move to APR? */ /* Need to manually add user name for OS/2 */ - filename = apr_pstrcat(r->pool, pw->pw_dir, w, "/", userdir, NULL); + filename = apr_pstrcat(r->pool, homedir, w, "/", userdir, NULL); #else - filename = apr_pstrcat(r->pool, pw->pw_dir, "/", userdir, NULL); + filename = apr_pstrcat(r->pool, homedir, "/", userdir, NULL); #endif } -#endif /* WIN32 */ + else { + /* XXX old code ignored this error... */ + } +#else + return DECLINED; +#endif } /* -- 2.40.0