From: William A. Rowe Jr Date: Mon, 29 Jan 2001 00:03:11 +0000 (+0000) Subject: *) Adopt apr user/group name features for mod_rewrite. Eliminates some X-Git-Tag: APACHE_2_0_BETA_CANDIDATE_1~43 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fe3af6ae49e15f98d34c566929954ad147c1be0;p=apache *) Adopt apr user/group name features for mod_rewrite. Eliminates some 'extra' stat's for user/group since they should never occur, and now resolves the SCRIPT_USER and SCRIPT_GROUP, including on WinNT NTFS volumes. No-one commented on loosing the 'stat' calls, can anyone invent a scenario where they could be required? Also, I don't like the casts either, so if you have a better solution, don't whine, just fix it :) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87904 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 3fdd0658c7..064d79e974 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,10 @@ Changes with Apache 2.0b1 + *) Adopt apr user/group name features for mod_rewrite. Eliminates some + 'extra' stat's for user/group since they should never occur, and now + resolves the SCRIPT_USER and SCRIPT_GROUP, including on WinNT NTFS + volumes. [William Rowe] + *) Adopt apr features to simplify mod_includes. This changes the behavior of the USER_NAME variable, unknown uid's are now reported as USER_NAME="" rather than the old user#000 result. diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 222f07c466..ba1d02798f 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -113,12 +113,6 @@ #include #endif #endif -#ifdef HAVE_PWD_H -#include -#endif -#ifdef HAVE_GRP_H -#include -#endif #ifdef HAVE_UNISTD_H #include #endif @@ -3395,11 +3389,6 @@ static char *lookup_variable(request_rec *r, char *var) char resultbuf[LONG_STRING_LEN]; apr_exploded_time_t tm; request_rec *rsub; -#ifndef WIN32 - struct passwd *pw; - struct group *gr; - apr_finfo_t finfo; -#endif result = NULL; @@ -3588,44 +3577,19 @@ static char *lookup_variable(request_rec *r, char *var) LOOKAHEAD(ap_sub_req_lookup_file) } -#if !defined(WIN32) && !defined(NETWARE) - /* Win32 has a rather different view of file ownerships. - For now, just forget it */ - /* file stuff */ else if (strcasecmp(var, "SCRIPT_USER") == 0) { result = ""; - if (r->finfo.protection != 0) { - if ((pw = getpwuid(r->finfo.user)) != NULL) { - result = pw->pw_name; - } - } - else { - if (apr_stat(&finfo, r->filename, - APR_FINFO_NORM, r->pool) == APR_SUCCESS) { - if ((pw = getpwuid(finfo.user)) != NULL) { - result = pw->pw_name; - } - } + if (r->finfo.valid & APR_FINFO_USER) { + apr_get_username(&(char*)result, r->finfo.user, r->pool); } } else if (strcasecmp(var, "SCRIPT_GROUP") == 0) { result = ""; - if (r->finfo.protection != 0) { - if ((gr = getgrgid(r->finfo.group)) != NULL) { - result = gr->gr_name; - } - } - else { - if (apr_stat(&finfo, r->filename, - APR_FINFO_NORM, r->pool) == 0) { - if ((gr = getgrgid(finfo.group)) != NULL) { - result = gr->gr_name; - } - } + if (r->finfo.valid & APR_FINFO_GROUP) { + apr_get_groupname(&(char*)result, r->finfo.group, r->pool); } } -#endif /* ndef WIN32 && NETWARE*/ if (result == NULL) { return apr_pstrdup(r->pool, "");