]> granicus.if.org Git - apache/commitdiff
add apr_get_home_directory(), teach mod_userdir to use that
authorJeff Trawick <trawick@apache.org>
Mon, 13 Nov 2000 03:18:18 +0000 (03:18 +0000)
committerJeff Trawick <trawick@apache.org>
Mon, 13 Nov 2000 03:18:18 +0000 (03:18 +0000)
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
modules/mappers/mod_userdir.c

index 7bf261a28e38bed8ae5324770e1697fe45e2fa48..9aaa782cc18f43e81260a4274d3664b659e133d9 100644 (file)
@@ -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)
 
index 56c236d54f92628ae54afc9263c90eff8c40dd45..c173272075e603028af2e59b50bc98a334e8600e 100644 (file)
@@ -96,6 +96,7 @@
 #endif
 
 #include "apr_strings.h"
+#include "apr_user.h"
 #include "ap_config.h"
 #include "httpd.h"
 #include "http_config.h"
 #ifdef HAVE_UNIX_SUEXEC
 #include "unixd.h"        /* Contains the suexec_identity hook used on Unix */
 #endif
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #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
         }
 
         /*