You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jeff Trawick <tr...@bellsouth.net> on 2000/11/12 15:05:19 UTC

[PATCH] move getpwnam hackery to APR

The following patch adds Unix support for apr_get_home_directory() to
APR.  

Bill Rowe will handle for Win32, at which point mod_userdir and
mod_rewrite will pick up the corresponding function on Win32.

In a nutshell: 
. if APR_HAS_HOME_DIR is non-zero, apr_get_home_directory() is
  provided 
. it is expected that all current APR platforms have it once Bill Rowe
  implements for NT and the Unix implementation is copied to OS/2 (but
  see OS/2 comment below)

To do:

. Is the interface appropriate for all known platforms?
. Can an OS/2 APR implementation handle the manual inclusion of the
  userid in the string?
. Add a Win32 implementation
. Is it APR_ENOTIMPL on Win9x?
. Update mod_rewrite to use this too.
. test this with mod_userdir :)

A separate issue still (to be moved to APR with this patch) is what to
do about _POSIX_THREAD_SAFE_FUNCTION/getpwnam[_r], but at least that
is out of user-level code.


Index: lib/apr/configure.in
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/configure.in,v
retrieving revision 1.170
diff -u -r1.170 configure.in
--- lib/apr/configure.in	2000/11/11 06:05:58	1.170
+++ lib/apr/configure.in	2000/11/12 13:52:05
@@ -265,6 +265,7 @@
 AC_CHECK_HEADERS(netdb.h)
 AC_CHECK_HEADERS(osreldate.h)
 AC_CHECK_HEADERS(process.h)
+AC_CHECK_HEADERS(pwd.h)
 AC_CHECK_HEADERS(sys/sem.h)
 AC_CHECK_HEADERS(signal.h, signalh="1", signalh="0")
 AC_CHECK_HEADERS(stdarg.h, stdargh="1", stdargh="0")
Index: lib/apr/file_io/unix/dir.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/file_io/unix/dir.c,v
retrieving revision 1.39
diff -u -r1.39 dir.c
--- lib/apr/file_io/unix/dir.c	2000/11/09 06:15:53	1.39
+++ lib/apr/file_io/unix/dir.c	2000/11/12 13:52:05
@@ -55,6 +55,12 @@
 #include "unix/fileio.h"
 #include "apr_strings.h"
 #include "apr_portable.h"
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 static apr_status_t dir_cleanup(void *thedir)
 {
@@ -271,4 +277,29 @@
     return APR_SUCCESS;
 }
 
+apr_status_t apr_get_home_directory(char *buf, apr_size_t bufsize, const char *userid)
+{
+    struct passwd *pw;
+#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+    struct passwd pwd;
+    char pwbuf[512];
+#endif
+
+#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+    if (!getpwnam_r(userid, &pwd, pwbuf, sizeof(pwbuf), &pw)) {
+#else
+    if ((pw = getpwnam(userid)) != NULL) {
+#endif
+        if (strlen(pw->pw_dir) < bufsize) {
+            strcpy(buf, pw->pw_dir);
+        }
+        else {
+            return APR_EINVAL;
+        }
+    }
+    else {
+        return errno;
+    }
+    return APR_SUCCESS;
+}
   
Index: lib/apr/include/apr.h.in
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/include/apr.h.in,v
retrieving revision 1.50
diff -u -r1.50 apr.h.in
--- lib/apr/include/apr.h.in	2000/11/11 06:05:59	1.50
+++ lib/apr/include/apr.h.in	2000/11/12 13:52:06
@@ -96,6 +96,7 @@
 #define APR_HAS_OTHER_CHILD       @oc@
 #define APR_HAS_DSO               @aprdso@
 #define APR_HAS_UNICODE_FS        0
+#define APR_HAS_HOME_DIR          1
 
 /* This macro tells APR that it is safe to make a file masquerade as a 
  * socket.  This is necessary, because some platforms support poll'ing
Index: lib/apr/include/apr_file_io.h
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/include/apr_file_io.h,v
retrieving revision 1.73
diff -u -r1.73 apr_file_io.h
--- lib/apr/include/apr_file_io.h	2000/11/10 15:19:53	1.73
+++ lib/apr/include/apr_file_io.h	2000/11/12 13:52:07
@@ -682,6 +682,18 @@
 APR_DECLARE(int) apr_fprintf(apr_file_t *fptr, const char *format, ...)
         __attribute__((format(printf,2,3)));
 
+/***
+ * Get the home directory for a specified userid.
+ * @param buf Storage to be filled in with the user id
+ * @param bufsize Size of user id buffer
+ * @param userid The userid
+ * @deffunc apr_status_t apr_get_home_directory(const char *userid, char *buf, apr_size_t bufsize)
+ * @tip If the buffer is not large enough to contain the home directory
+ * and a terminating '\0', APR_EINVAL will be returned.
+ * @tip This function is available only if APR_HAS_HOME_DIR is defined.
+ */
+apr_status_t apr_get_home_directory(char *buf, apr_size_t bufsize, const char *userid);
+
 #ifdef __cplusplus
 }
 #endif
Index: modules/standard/mod_userdir.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/modules/standard/mod_userdir.c,v
retrieving revision 1.26
diff -u -r1.26 mod_userdir.c
--- modules/standard/mod_userdir.c	2000/11/10 23:52:18	1.26
+++ modules/standard/mod_userdir.c	2000/11/12 13:52:13
@@ -103,9 +103,6 @@
 #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 +317,23 @@
             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_HOME_DIR
+            char homedir[512];
 
-            if (!getpwnam_r(w, &pwd, buf, buflen, &pw)) {
-#else
-            if ((pw = getpwnam(w))) {
-#endif
-#ifdef OS2
+            if (apr_get_home_directory(homedir, sizeof(homedir), w) == 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
         }
 
         /*


-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: [PATCH] move getpwnam hackery to APR

Posted by Jeff Trawick <tr...@bellsouth.net>.
rbb@covalent.net writes:

> On 12 Nov 2000, Jeff Trawick wrote:
> 
> > Here is the latest patch, taking into account comments from Ryan and
> > OtherBill.
> 
> +1.  I have some cleanup to add to the configure script, but that can go
> in at any time.

Now the hard part... actually getting the damn thing committed.  Maybe
I should set the alarm for 4:00 or so in the morning...
-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: [PATCH] move getpwnam hackery to APR

Posted by rb...@covalent.net.
On 12 Nov 2000, Jeff Trawick wrote:

> Here is the latest patch, taking into account comments from Ryan and
> OtherBill.

+1.  I have some cleanup to add to the configure script, but that can go
in at any time.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: [PATCH] move getpwnam hackery to APR

Posted by Jeff Trawick <tr...@bellsouth.net>.
Here is the latest patch, taking into account comments from Ryan and
OtherBill.

? lib/apr/user
--lib/apr/user/unix/homedir.c----------------------
/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

#include "apr_strings.h"
#include "apr_portable.h"
#include "apr_user.h"
#include "apr_private.h"
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif

apr_status_t apr_get_home_directory(char **dirname, const char *userid, apr_pool_t *p)
{
    struct passwd *pw;
#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
    struct passwd pwd;
    char pwbuf[512];
#endif

#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
    if (!getpwnam_r(userid, &pwd, pwbuf, sizeof(pwbuf), &pw)) {
#else
    if ((pw = getpwnam(userid)) != NULL) {
#endif
        *dirname = apr_pstrdup(p, pw->pw_dir);
    }
    else {
        return errno;
    }
    return APR_SUCCESS;
}
----lib/apr/user/unix/Makefile.in--------------------

RM=@RM@
CC=@CC@
RANLIB=@RANLIB@
CFLAGS=@CFLAGS@ @OPTIM@
LIBS=@LIBS@
LDFLAGS=@LDFLAGS@ $(LIBS)
INCDIR=../../include
INCLUDES=-I$(INCDIR) -I$(INCDIR)/arch

OBJS=homedir.o

.c.o:
	$(CC) $(CFLAGS) -c $(INCLUDES) $<

all: $(OBJS)

clean:
	$(RM) -f *.o *.a *.so

distclean: clean
	-$(RM) -f Makefile


#
# We really don't expect end users to use this rule.  It works only with
# gcc, and rebuilds Makefile.in.  You have to re-run configure after
# using it.
#
depend:
	cp Makefile.in Makefile.in.bak \
	    && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > Makefile.new \
	    && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
	    && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
	           -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
		> Makefile.in \
	    && rm Makefile.new

# DO NOT REMOVE
homedir.o: homedir.c $(INCDIR)/apr_strings.h $(INCDIR)/apr.h \
 $(INCDIR)/apr_lib.h $(INCDIR)/apr_pools.h \
 $(INCDIR)/apr_thread_proc.h $(INCDIR)/apr_file_io.h \
 $(INCDIR)/apr_general.h $(INCDIR)/apr_errno.h \
 $(INCDIR)/apr_time.h $(INCDIR)/apr_tables.h \
 $(INCDIR)/apr_portable.h $(INCDIR)/apr_network_io.h \
 $(INCDIR)/apr_lock.h $(INCDIR)/apr_dso.h \
 $(INCDIR)/apr_user.h $(INCDIR)/apr_private.h

? lib/apr/include/apr_user.h
--------------------apr_user.h-----------------
/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

#ifndef APR_USER_H
#define APR_USER_H

#include "apr.h"

#if APR_HAS_USER

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/**
 * @package APR user id services
 */

/***
 * Get the home directory for a specified userid.
 * @param dirname Pointer to new string containing directory name (on output)
 * @param userid The userid
 * @param p The pool from which to allocate the string
 * @deffunc apr_status_t apr_get_home_directory(char **dirname, const char *userid, apr_pool_t *p)
 * @tip This function is available only if APR_HAS_USER is defined.
 */
apr_status_t apr_get_home_directory(char **dirname, const char *userid, apr_pool_t *p);

#ifdef __cplusplus
}
#endif

#endif  /* ! APR_HAS_USER */

#endif  /* ! APR_USER_H */

Index: lib/apr/configure.in
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/configure.in,v
retrieving revision 1.170
diff -u -r1.170 configure.in
--- lib/apr/configure.in	2000/11/11 06:05:58	1.170
+++ lib/apr/configure.in	2000/11/12 22:12:08
@@ -35,7 +35,7 @@
 # These added to allow default directories to be used...
 DEFAULT_OSDIR="unix"
 echo "(Default will be ${DEFAULT_OSDIR})"
-MODULES="file_io network_io threadproc misc locks time mmap shmem i18n"
+MODULES="file_io network_io threadproc misc locks time mmap shmem i18n user"
 
 # Most platforms use a prefix of 'lib' on their library files.
 LIBPREFIX='lib'
@@ -265,6 +265,7 @@
 AC_CHECK_HEADERS(netdb.h)
 AC_CHECK_HEADERS(osreldate.h)
 AC_CHECK_HEADERS(process.h)
+AC_CHECK_HEADERS(pwd.h)
 AC_CHECK_HEADERS(sys/sem.h)
 AC_CHECK_HEADERS(signal.h, signalh="1", signalh="0")
 AC_CHECK_HEADERS(stdarg.h, stdargh="1", stdargh="0")
Index: lib/apr/include/apr.h.in
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/include/apr.h.in,v
retrieving revision 1.50
diff -u -r1.50 apr.h.in
--- lib/apr/include/apr.h.in	2000/11/11 06:05:59	1.50
+++ lib/apr/include/apr.h.in	2000/11/12 22:12:09
@@ -96,6 +96,7 @@
 #define APR_HAS_OTHER_CHILD       @oc@
 #define APR_HAS_DSO               @aprdso@
 #define APR_HAS_UNICODE_FS        0
+#define APR_HAS_USER              1
 
 /* This macro tells APR that it is safe to make a file masquerade as a 
  * socket.  This is necessary, because some platforms support poll'ing
Index: lib/apr/include/apr.hw
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/include/apr.hw,v
retrieving revision 1.34
diff -u -r1.34 apr.hw
--- lib/apr/include/apr.hw	2000/11/02 15:24:08	1.34
+++ lib/apr/include/apr.hw	2000/11/12 22:12:10
@@ -160,6 +160,8 @@
  */
 #define APR_HAS_UNICODE_FS     1
 
+#define APR_HAS_USER           0
+
 /* Typedefs that APR needs. */
 
 typedef  short           apr_int16_t;
Index: modules/standard/config.m4
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/modules/standard/config.m4,v
retrieving revision 1.31
diff -u -r1.31 config.m4
--- modules/standard/config.m4	2000/11/10 23:52:18	1.31
+++ modules/standard/config.m4	2000/11/12 22:12:15
@@ -25,9 +25,7 @@
 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: modules/standard/mod_userdir.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/modules/standard/mod_userdir.c,v
retrieving revision 1.26
diff -u -r1.26 mod_userdir.c
--- modules/standard/mod_userdir.c	2000/11/10 23:52:18	1.26
+++ modules/standard/mod_userdir.c	2000/11/12 22:20:58
@@ -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 <pwd.h>
-#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -320,29 +318,23 @@
             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
         }
 
         /*

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: [PATCH] move getpwnam hackery to APR

Posted by rb...@covalent.net.
I ahve a couple of nits that I would like to see fixed before this is
committed.

1)  This doesn't belong in dir.c.  This should  have it's own directory in
APR, call it something like user or pw.  This is not file related at all.

2)  APR_HAS_USER_DIR is too specific.  I would prefer to see something
like APR_HAS_PWD or APR_HAS_USER.  That allows us to configurat APR
with or without the passwd or user stuff as the program requires.

Ryan

On Sun, 12 Nov 2000, Jeff Trawick wrote:

> The following patch adds Unix support for apr_get_home_directory() to
> APR.  
> 
> Bill Rowe will handle for Win32, at which point mod_userdir and
> mod_rewrite will pick up the corresponding function on Win32.
> 
> In a nutshell: 
> . if APR_HAS_HOME_DIR is non-zero, apr_get_home_directory() is
>   provided 
> . it is expected that all current APR platforms have it once Bill Rowe
>   implements for NT and the Unix implementation is copied to OS/2 (but
>   see OS/2 comment below)
> 
> To do:
> 
> . Is the interface appropriate for all known platforms?
> . Can an OS/2 APR implementation handle the manual inclusion of the
>   userid in the string?
> . Add a Win32 implementation
> . Is it APR_ENOTIMPL on Win9x?
> . Update mod_rewrite to use this too.
> . test this with mod_userdir :)
> 
> A separate issue still (to be moved to APR with this patch) is what to
> do about _POSIX_THREAD_SAFE_FUNCTION/getpwnam[_r], but at least that
> is out of user-level code.


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


RE: [PATCH] move getpwnam hackery to APR

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
> From: Jeff Trawick [mailto:trawickj@bellsouth.net]
> Sent: Sunday, November 12, 2000 8:05 AM
> 
> To do:
> 
> . Is the interface appropriate for all known platforms?

I'd pass a char** to accept the path, and a apr_pool_t for the ctx.

> . Can an OS/2 APR implementation handle the manual inclusion of the
>   userid in the string?
> . Add a Win32 implementation

I'll get on it.  in the interim, remember the #defines in apr.hw (the
win32 cousin to apr.h.in).

> . Is it APR_ENOTIMPL on Win9x?

Nope, even Win9x has %windir%/profiles/username/ paths.

Looking good :-)