Skip to content

Conversation

@iboukris
Copy link
Contributor

Internal redirects are a special case of subrequest - they
have no req->main but req->prev instead, so we should check
for that too in case the request is not initial.

Also, make sure to export MAG environment variables to
subrequests and internal redirects.

Signed-off-by: Isaac Boukris iboukris@gmail.com
Reported-by: scopev24

Fixes #114

while (main_req->prev)
main_req = main_req->prev;

if (main_req->main) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this check ?
Also it would be nice if you can explain the intended logic for getting to the "proper" main request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was intended as just-in-case check, to confirm we got the initial request (as we just checked for prev), however I didn't see such scenario in logs, and there is no such check in mod_auth_digest.c so I think it shouldn't happen.

src/environ.c Outdated
"KRB5CCNAME",
"GSS_SESSION_EXPIRATION",
NULL
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we make sure to keep this list current if we export new variables later ?
Should we just have tests confirming each env variable is present ? Or should we come up with some more elaboarate way to reference/set env vars that forces the programmer to update this list ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I wanted something better but it got complicated. What I had in mind was some intermediate function which will be called from both mag_set_req_data() and mag_dup_req_data(), in which we centralize the export of environment variables.

Another idea is to create a table in which variables are added as they are being determined, at the end, we save this table with ap_set_module_config(req->request_config) and only then call a generic function to export the table into req's environment.
Later, in subrequest / internal-redirect, we retrieve the table with ap_get_module_config(main_req->request_config), and export it via the generic function (which by the way would also confirm we got the main request which we have authenticated).

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using a table is a very good idea, this way if we add later we do not risk the two functions getting out of sync.
Please add the table stuff.

Copy link
Member

@frozencemetery frozencemetery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Barring already discussed changes, this looks good to me. Please rebase onto master while you're there. Thanks for adding a test.

@iboukris iboukris force-pushed the internal_redirects branch from f74280e to 1cfb1e5 Compare January 7, 2017 12:38
@iboukris
Copy link
Contributor Author

iboukris commented Jan 7, 2017

Updated based on review comments, please review - thanks!

@iboukris iboukris force-pushed the internal_redirects branch from 1cfb1e5 to 7a784b5 Compare January 7, 2017 20:14
Copy link
Contributor

@simo5 simo5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a minor change is needed.


/* It is either a subrequest or an internal redirect */
while (!ap_is_initial_req(main_req))
main_req = main_req->main ?: main_req->prev;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use and explicit if/else condition here, this syntax is hard to read and can easily lead to mistakes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do right now.

tests/httpd.conf Outdated
IncludeOptional conf.d/*.conf

CoreDumpDirectory /tmp
CoreDumpDirectory "${HTTPROOT}/logs"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change ? Seems unrelated to the patch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'll remove it from this commit.
Do you want it in a separate commit? I like all test data to be kept in scratchdir.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah probably better to have a spearate PR, and the dirs should probably be something like "${HTTPROOT}/cores" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with simply "${HTTPROOT}" to bump it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss this over new #121

Internal redirects are a special case of subrequest - they
have no req->main but req->prev instead, so we should check
for that too in case the request is not initial.

Also, make sure to export MAG environment variables to
subrequests and internal redirects.

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Reported-by: scopev24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants