Received: (qmail 26164 invoked by uid 501); 10 Nov 2000 18:33:55 -0000 Message-Id: <20001110183355.26163.qmail@locus.apache.org> Date: 10 Nov 2000 18:33:55 -0000 From: Anthony Howe Reply-To: achowe@snert.com To: submit@bugz.apache.org Subject: mod_userdir should check for location URIs X-Send-Pr-Version: 3.110 >Number: 6828 >Category: mod_userdir >Synopsis: mod_userdir should check for location URIs >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: apache >Arrival-Date: Fri Nov 10 10:40:00 PST 2000 >Closed-Date: Wed Nov 15 15:01:53 PST 2000 >Last-Modified: Wed Nov 15 15:01:53 PST 2000 >Originator: achowe@snert.com >Release: 1.3.14 >Organization: >Environment: Linux mail.snert.net 2.0.34C52_SK #1 Tue Nov 30 18:14:40 PST 1999 mips unknown (Cobalt Qube 1 running Redhat) >Description: The following does not work: http://www.snert.com/~chrisma/server-info Server-info, server-status, and other handlers that would have been defined as URIs with sections are not found when the URI prefix is /~user. Everything after the /~user should be considered like a URI, be it a file or a module handler. mod_userdir should perform a subrequest on the remaining URI to determine if its a file or handler. If it is a handler, it should be the module's responsibility to determine whether or not it processes the request in relation to users. This issue came up during the development of mod_throttle 3.0, where I want to have a special handler to return the status of an induhvidual server or user. >How-To-Repeat: Install something like server-info or server-status. Request a URL something like this: http://www.snert.com/~chrisma/server-info >Fix: Not as yet. >Release-Note: >Audit-Trail: From: Anthony Howe To: gnats-admin@bugz.apache.org, apache-bugdb@apache.org Cc: apbugs@apache.org Subject: Re: mod_userdir/6828: mod_userdir should check for location URIs Date: Tue, 14 Nov 2000 15:21:15 +0100 Here is a proposed patch for mod_userdir.c An example of this patch in operation can be found here: http://www.snert.com:8888/~chrisma/server-info While the above is not of great interest, the following is now possible: http://www.snert.com:8888/~chrisma/throttle-me http://www.snert.com:8888/throttle-me I can now specify a that invokes the throttle-me handler in mod_throttle/3.0 and get different results depending whether a ~user is specified or not. ---- *** mod_userdir.c.orig Sat Nov 11 15:37:01 2000 --- mod_userdir.c Sat Nov 11 15:44:35 2000 *************** *** 92,97 **** --- 92,98 ---- #include "httpd.h" #include "http_config.h" + #include "http_request.h" module userdir_module; *************** *** 308,313 **** --- 309,315 ---- #endif /* WIN32 & NetWare */ } + #ifdef ORIGINAL /* * Now see if it exists, or we're at the last entry. If we are at the * last entry, then use the filename generated (if there is one) *************** *** 323,328 **** --- 325,373 ---- r->finfo = statbuf; return OK; } + + #else + /* Background: The built-up "filename" will either be null or + * contain the document root of the user, "w", derived from one + * or more patterns pointed to by "userdirs". The remainder of + * the URI is pointed to by "dname", which may be an empty string. + * + * Check if the user's document root exists or if we are on the + * last entry for the list of patterns, in which case we use the + * last generated filename in case some handler might handle it, + * such as cgi-script. + */ + if (filename != (char *) 0) { + if (*userdirs == '\0') { + request_rec *sub; + + r->filename = ap_pstrcat(r->pool, filename, dname, NULL); + + /* Check if the remainder of the URI refers to some + * special location or handler and set it as the + * default. + */ + sub = ap_sub_req_lookup_uri(dname, r); + if (ap_is_HTTP_SUCCESS(sub->status)) + r->handler = ap_pstrdup(r->pool, sub->handler); + ap_destroy_sub_req(sub); + + return OK; + } else if (stat(filename, &statbuf) == 0) { + r->filename = ap_pstrcat(r->pool, filename, dname, NULL); + + /* When the URI is just "/~user", then we can save + * an additional stat() by saving the information as + * part of this request. + */ + if (*dname == '\0') + r->finfo = statbuf; + + return OK; + } + } + #endif + } return DECLINED; -- Anthony C Howe 1489 Ch. des Collines, 06110 Le Cannet, France +33 (0)6 1189 7378 (p) +33 (0)4 9346 8901 (f) ICQ# 7116561 mailto:achowe@snert.com http://www.snert.com/ From: Tony Finch To: Anthony Howe Cc: apbugs@apache.org Subject: Re: mod_userdir/6828: mod_userdir should check for location URIs Date: Wed, 15 Nov 2000 02:05:28 +0000 Anthony Howe wrote: > >The following does not work: > > http://www.snert.com/~chrisma/server-info > >Server-info, server-status, and other handlers that would have been defined as >URIs with sections are not found when the URI prefix is >/~user. Why do you expect a location starting to match a URI starting <~user/>? Why can't you use this config? SetHandler cool-handler Tony. -- en oeccget g mtcaa f.a.n.finch v spdlkishrhtewe y dot@dotat.at eatp o v eiti i d. fanf@covalent.net State-Changed-From-To: open-closed State-Changed-By: fanf State-Changed-When: Wed Nov 15 15:01:52 PST 2000 State-Changed-Why: Problem solved. Thanks for using Apache! >Unformatted: [In order for any reply to be added to the PR database, you need] [to include in the Cc line and make sure the] [subject line starts with the report component and number, with ] [or without any 'Re:' prefixes (such as "general/1098:" or ] ["Re: general/1098:"). If the subject doesn't match this ] [pattern, your message will be misfiled and ignored. The ] ["apbugs" address is not added to the Cc line of messages from ] [the database automatically because of the potential for mail ] [loops. If you do not include this Cc, your reply may be ig- ] [nored unless you are responding to an explicit request from a ] [developer. Reply only with text; DO NOT SEND ATTACHMENTS! ]