From 3fcc044205a02ec1546b8ccbd6db8766eda2f122 Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Tue, 2 Oct 2012 20:10:21 +0000 Subject: [PATCH] mod_auth_form: Make sure that get_notes_auth() sets the user as does get_form_auth() and get_session_auth(). Makes sure that REMOTE_USER does not vanish during mod_include driven subrequests. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1393152 13f79535-47bb-0310-9956-ffa450edef68 --- modules/aaa/mod_auth_form.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/modules/aaa/mod_auth_form.c b/modules/aaa/mod_auth_form.c index 5f60c88c4e..dca3496a41 100644 --- a/modules/aaa/mod_auth_form.c +++ b/modules/aaa/mod_auth_form.c @@ -489,34 +489,40 @@ static void set_notes_auth(request_rec * r, * Get the auth username and password from the main request * notes table, if present. */ -static void get_notes_auth(request_rec * r, +static void get_notes_auth(request_rec *r, const char **user, const char **pw, const char **method, const char **mimetype) { const char *authname; + request_rec *m = r; /* find the main request */ - while (r->main) { - r = r->main; + while (m->main) { + m = m->main; } /* find the first redirect */ - while (r->prev) { - r = r->prev; + while (m->prev) { + m = m->prev; } /* have we isolated the user and pw before? */ - authname = ap_auth_name(r); + authname = ap_auth_name(m); if (user) { - *user = (char *) apr_table_get(r->notes, apr_pstrcat(r->pool, authname, "-user", NULL)); + *user = (char *) apr_table_get(m->notes, apr_pstrcat(m->pool, authname, "-user", NULL)); } if (pw) { - *pw = (char *) apr_table_get(r->notes, apr_pstrcat(r->pool, authname, "-pw", NULL)); + *pw = (char *) apr_table_get(m->notes, apr_pstrcat(m->pool, authname, "-pw", NULL)); } if (method) { - *method = (char *) apr_table_get(r->notes, apr_pstrcat(r->pool, authname, "-method", NULL)); + *method = (char *) apr_table_get(m->notes, apr_pstrcat(m->pool, authname, "-method", NULL)); } if (mimetype) { - *mimetype = (char *) apr_table_get(r->notes, apr_pstrcat(r->pool, authname, "-mimetype", NULL)); + *mimetype = (char *) apr_table_get(m->notes, apr_pstrcat(m->pool, authname, "-mimetype", NULL)); + } + + /* set the user, even though the user is unauthenticated at this point */ + if (user && *user) { + r->user = (char *) *user; } ap_log_rerror(APLOG_MARK, APLOG_TRACE6, 0, r, -- 2.49.0