You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "William A. Rowe, Jr." <wr...@rowe-clan.net> on 2001/01/28 05:23:50 UTC
[patch] mod_include
Likewise with this patch, is there any reason to pass on to the
user the internal id of a now-defunct user account? It seems a
bit bogus... this patch substitutes <unknown>, as mod_rewrite
would do.
Index: mod_include.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/filters/mod_include.c,v
retrieving revision 1.89
diff -u -r1.89 mod_include.c
--- mod_include.c 2001/01/20 21:42:18 1.89
+++ mod_include.c 2001/01/28 04:21:57
@@ -68,6 +68,7 @@
#include "apr_strings.h"
#include "apr_thread_proc.h"
#include "apr_hash.h"
+#include "apr_user.h"
#define CORE_PRIVATE
@@ -89,9 +90,6 @@
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
#include "util_ebcdic.h"
@@ -102,9 +100,7 @@
/* XXX: could use ap_table_overlap here */
static void add_include_vars(request_rec *r, char *timefmt)
{
-#ifndef WIN32
- struct passwd *pw;
-#endif /* ndef WIN32 */
+ char *pwname;
apr_table_t *e = r->subprocess_env;
char *t;
apr_time_t date = r->request_time;
@@ -115,17 +111,12 @@
ap_ht_time(r->pool, r->finfo.mtime, timefmt, 0));
apr_table_setn(e, "DOCUMENT_URI", r->uri);
apr_table_setn(e, "DOCUMENT_PATH_INFO", r->path_info);
-#ifndef WIN32
- pw = getpwuid(r->finfo.user);
- if (pw) {
- apr_table_setn(e, "USER_NAME", apr_pstrdup(r->pool, pw->pw_name));
+ if (apr_get_username(&pwname, r->finfo.user, r->pool) == APR_SUCCESS) {
+ apr_table_setn(e, "USER_NAME", pwname);
}
else {
- apr_table_setn(e, "USER_NAME", apr_psprintf(r->pool, "user#%lu",
- (unsigned long) r->finfo.user));
+ apr_table_setn(e, "USER_NAME", "<unknown>");
}
-#endif /* ndef WIN32 */
-
if ((t = strrchr(r->filename, '/'))) {
apr_table_setn(e, "DOCUMENT_NAME", ++t);
}