From 66d70ba27db23d3de71198ca25f99b5f7a8fe2d0 Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Tue, 31 Jan 2017 21:22:16 -0500 Subject: [PATCH] apache: improved fastScriptAlias Implementation using Alias + proved unworkable -- Apache has an obnoxious property wherein Aliases are first match and Locations are last match, causing all sorts of exciting side-effects (e.g. having to add a `SetHandler None' afterward for any aliases that otherwise would have matched). A directory + file match however works and does not cause strange alias behavior. Also fix not stripping trailing `/' when setting up wrapper. --- src/plugins/apache.sml | 46 +++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index b959219..6174110 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -790,23 +790,37 @@ val () = Env.action_two "scriptAlias" val () = Env.action_two "fastScriptAlias" ("from", Env.string, "to", Env.string) (fn (from, to) => - (write "\tAlias\t"; - write from; - write " "; - write to; - write "\n"; + let + (* mod_fcgid + kerberos limit this to working with + individual fcgi programs. assume the target path is a + file and any trailing `/' is just aliasing + syntax. Directory+File on the script is used to + activate fcgid instead of Location on the alias to + limit effects (alias+location also match in inverse + order causing pernicious side-effects *) + val fcgi_path = if String.sub (to, size to - 1) = #"/" + then + String.substring (to, 0, size to - 1) + else + to + val fcgi_dir = OS.Path.dir fcgi_path + val fcgi_file = OS.Path.file fcgi_path + in + write "\tAlias\t"; write from; write " "; write to; write "\n"; - write "\t\n"; - write "\t\tSetHandler fcgid-script\n"; - (* FIXME: only set kerberos wrapper of waklog is on *) - write "\t\tFcgidWrapper \""; - write (Config.Apache.fastCgiWrapperOf (Domain.getUser ())); - write " "; - write to; - write "\"\n"; - write "\t\n")) + write "\t\n"; + write "\t\n"; + write "\tSetHandler fcgid-script\n"; + + (* FIXME: only set kerberos wrapper of waklog is on *) + write "\tFcgidWrapper \""; + write (Config.Apache.fastCgiWrapperOf (Domain.getUser ())); + write " "; + write fcgi_path; + write "\"\n"; + + write "\t\n\t\n" + end) val () = Env.action_two "errorDocument" ("code", Env.string, "handler", Env.string) -- 2.20.1