d68ab27c |
1 | (* HCoop Domtool (http://hcoop.sourceforge.net/) |
2 | * Copyright (c) 2006, Adam Chlipala |
3 | * |
4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU General Public License |
6 | * as published by the Free Software Foundation; either version 2 |
7 | * of the License, or (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | *) |
18 | |
19 | (* Apache HTTPD handling *) |
20 | |
21 | structure Apache :> APACHE = struct |
22 | |
23 | open Ast |
24 | |
4cb2e7e7 |
25 | val _ = Env.type_one "web_node" |
26 | Env.string |
27 | (fn node => |
28 | List.exists (fn x => x = node) Config.Apache.webNodes_all |
1bb29dea |
29 | orelse (Domain.hasPriv "www" |
4cb2e7e7 |
30 | andalso List.exists (fn x => x = node) Config.Apache.webNodes_admin)) |
31 | |
19bdfddd |
32 | val _ = Env.registerFunction ("web_node_to_node", |
33 | fn [e] => SOME e |
34 | | _ => NONE) |
35 | |
697d1a52 |
36 | val _ = Env.type_one "proxy_port" |
37 | Env.int |
169731e9 |
38 | (fn n => n > 1024) |
39 | |
40 | val _ = Env.type_one "proxy_target" |
41 | Env.string |
42 | (fn s => |
43 | let |
44 | fun default () = List.exists (fn s' => s = s') Config.Apache.proxyTargets |
45 | in |
46 | case String.fields (fn ch => ch = #":") s of |
47 | ["http", "//localhost", rest] => |
48 | (case String.fields (fn ch => ch = #"/") rest of |
49 | port :: _ => |
50 | (case Int.fromString port of |
51 | NONE => default () |
52 | | SOME n => n > 1024 orelse default ()) |
53 | | _ => default ()) |
54 | | _ => default () |
55 | end) |
697d1a52 |
56 | |
57 | val _ = Env.type_one "rewrite_arg" |
58 | Env.string |
59 | (CharVector.all Char.isAlphaNum) |
60 | |
ff2a424a |
61 | fun validLocation s = |
62 | size s > 0 andalso size s < 1000 andalso CharVector.all |
63 | (fn ch => Char.isAlphaNum ch |
64 | orelse ch = #"-" |
65 | orelse ch = #"_" |
66 | orelse ch = #"." |
67 | orelse ch = #"/") s |
68 | |
69 | val _ = Env.type_one "location" |
70 | Env.string |
71 | validLocation |
72 | |
d68ab27c |
73 | val dl = ErrorMsg.dummyLoc |
74 | |
53d222a3 |
75 | val _ = Defaults.registerDefault ("WebNodes", |
4cb2e7e7 |
76 | (TList (TBase "web_node", dl), dl), |
77 | (fn () => (EList (map (fn s => (EString s, dl)) Config.Apache.webNodes_default), dl))) |
d68ab27c |
78 | |
53d222a3 |
79 | val _ = Defaults.registerDefault ("SSL", |
80 | (TBase "bool", dl), |
81 | (fn () => (EVar "false", dl))) |
d68ab27c |
82 | |
53d222a3 |
83 | val _ = Defaults.registerDefault ("User", |
84 | (TBase "your_user", dl), |
85 | (fn () => (EString (Domain.getUser ()), dl))) |
d68ab27c |
86 | |
53d222a3 |
87 | val _ = Defaults.registerDefault ("Group", |
88 | (TBase "your_group", dl), |
89 | (fn () => (EString (Domain.getUser ()), dl))) |
d68ab27c |
90 | |
53d222a3 |
91 | val _ = Defaults.registerDefault ("DocumentRoot", |
92 | (TBase "your_path", dl), |
ab5d2803 |
93 | (fn () => (EString (Config.homeBase ^ "/" ^ Domain.getUser () ^ "/" ^ Config.Apache.public_html), dl))) |
d68ab27c |
94 | |
53d222a3 |
95 | val _ = Defaults.registerDefault ("ServerAdmin", |
96 | (TBase "email", dl), |
97 | (fn () => (EString (Domain.getUser () ^ "@" ^ Config.defaultDomain), dl))) |
d68ab27c |
98 | |
697d1a52 |
99 | |
100 | val redirect_code = fn (EVar "temp", _) => SOME "temp" |
101 | | (EVar "permanent", _) => SOME "permanent" |
102 | | (EVar "seeother", _) => SOME "seeother" |
103 | | (EVar "redir300", _) => SOME "300" |
104 | | (EVar "redir301", _) => SOME "301" |
105 | | (EVar "redir302", _) => SOME "302" |
106 | | (EVar "redir303", _) => SOME "303" |
107 | | (EVar "redir304", _) => SOME "304" |
108 | | (EVar "redir305", _) => SOME "305" |
109 | | (EVar "redir307", _) => SOME "307" |
110 | | _ => NONE |
111 | |
112 | val flag = fn (EVar "redirect", _) => SOME "R" |
113 | | (EVar "forbidden", _) => SOME "F" |
114 | | (EVar "gone", _) => SOME "G" |
115 | | (EVar "last", _) => SOME "L" |
116 | | (EVar "chain", _) => SOME "C" |
117 | | (EVar "nosubreq", _) => SOME "NS" |
118 | | (EVar "nocase", _) => SOME "NC" |
119 | | (EVar "qsappend", _) => SOME "QSA" |
120 | | (EVar "noescape", _) => SOME "NE" |
121 | | (EVar "passthrough", _) => SOME "PT" |
122 | | (EApp ((EVar "mimeType", _), e), _) => |
123 | Option.map (fn s => "T=" ^ s) (Env.string e) |
124 | | (EApp ((EVar "redirectWith", _), e), _) => |
125 | Option.map (fn s => "R=" ^ s) (redirect_code e) |
126 | | (EApp ((EVar "skip", _), e), _) => |
127 | Option.map (fn n => "S=" ^ Int.toString n) (Env.int e) |
128 | | (EApp ((EApp ((EVar "env", _), e1), _), e2), _) => |
129 | (case Env.string e1 of |
130 | NONE => NONE |
131 | | SOME s1 => Option.map (fn s2 => "E=" ^ s1 ^ ":" ^ s2) |
132 | (Env.string e2)) |
133 | |
134 | | _ => NONE |
135 | |
169731e9 |
136 | val cond_flag = fn (EVar "cond_nocase", _) => SOME "NC" |
137 | | (EVar "ornext", _) => SOME "OR" |
138 | | _ => NONE |
139 | |
ff8db773 |
140 | val apache_option = fn (EVar "execCGI", _) => SOME "ExecCGI" |
141 | | (EVar "includesNOEXEC", _) => SOME "IncludesNOEXEC" |
142 | | (EVar "indexes", _) => SOME "Indexes" |
143 | | _ => NONE |
144 | |
db9c7cb7 |
145 | val autoindex_width = fn (EVar "autofit", _) => SOME "*" |
146 | | (EApp ((EVar "characters", _), n), _) => |
147 | Option.map Int.toString (Env.int n) |
148 | | _ => NONE |
149 | |
150 | val autoindex_option = fn (EApp ((EVar "descriptionWidth", _), w), _) => |
151 | Option.map (fn w => ("DescriptionWidth", SOME w)) |
152 | (autoindex_width w) |
153 | | (EVar "fancyIndexing", _) => SOME ("FancyIndexing", NONE) |
154 | | (EVar "foldersFirst", _) => SOME ("FoldersFirst", NONE) |
155 | | (EVar "htmlTable", _) => SOME ("HTMLTable", NONE) |
156 | | (EVar "iconsAreLinks", _) => SOME ("IconsAreLinks", NONE) |
157 | | (EApp ((EVar "iconHeight", _), n), _) => |
158 | Option.map (fn w => ("IconHeight", SOME (Int.toString w))) |
159 | (Env.int n) |
160 | | (EApp ((EVar "iconWidth", _), n), _) => |
161 | Option.map (fn w => ("IconWidth", SOME (Int.toString w))) |
162 | (Env.int n) |
163 | | (EVar "ignoreCase", _) => SOME ("IgnoreCase", NONE) |
164 | | (EVar "ignoreClient", _) => SOME ("IgnoreClient", NONE) |
165 | | (EApp ((EVar "nameWidth", _), w), _) => |
166 | Option.map (fn w => ("NameWidth", SOME w)) |
167 | (autoindex_width w) |
168 | | (EVar "scanHtmlTitles", _) => SOME ("ScanHTMLTitles", NONE) |
169 | | (EVar "suppressColumnSorting", _) => SOME ("SuppressColumnSorting", NONE) |
170 | | (EVar "suppressDescription", _) => SOME ("SuppressDescription", NONE) |
171 | | (EVar "suppressHtmlPreamble", _) => SOME ("SuppressHTMLPreamble", NONE) |
172 | | (EVar "suppressIcon", _) => SOME ("SuppressIcon", NONE) |
173 | | (EVar "suppressLastModified", _) => SOME ("SuppressLastModified", NONE) |
174 | | (EVar "suppressRules", _) => SOME ("SuppressRules", NONE) |
175 | | (EVar "suppressSize", _) => SOME ("SuppressSize", NONE) |
176 | | (EVar "trackModified", _) => SOME ("TrackModified", NONE) |
177 | | (EVar "versionSort", _) => SOME ("VersionSort", NONE) |
178 | | (EVar "xhtml", _) => SOME ("XHTML", NONE) |
179 | |
180 | | _ => NONE |
697d1a52 |
181 | |
d68ab27c |
182 | val vhostsChanged = ref false |
8bd6a399 |
183 | val logDeleted = ref false |
d68ab27c |
184 | |
185 | val () = Slave.registerPreHandler |
8bd6a399 |
186 | (fn () => (vhostsChanged := false; |
187 | logDeleted := false)) |
d68ab27c |
188 | |
acb4199f |
189 | fun findVhostUser fname = |
190 | let |
191 | val inf = TextIO.openIn fname |
192 | |
193 | fun loop () = |
194 | case TextIO.inputLine inf of |
195 | NONE => NONE |
196 | | SOME line => |
197 | case String.tokens Char.isSpace line of |
198 | ["SuexecUserGroup", user, _] => SOME user |
199 | | _ => loop () |
200 | in |
201 | loop () |
202 | before TextIO.closeIn inf |
203 | end |
204 | |
d68ab27c |
205 | val () = Slave.registerFileHandler (fn fs => |
037af74e |
206 | let |
207 | val spl = OS.Path.splitDirFile (#file fs) |
208 | in |
209 | if String.isSuffix ".vhost" (#file spl) |
210 | orelse String.isSuffix ".vhost_ssl" (#file spl) then |
211 | case findVhostUser (#file fs) of |
212 | NONE => print ("Can't find user in " ^ #file fs ^ "! Taking no action.\n") |
213 | | SOME user => |
214 | let |
215 | val realVhostFile = OS.Path.joinDirFile |
216 | {dir = Config.Apache.confDir, |
217 | file = #file spl} |
218 | |
219 | val realLogDir = OS.Path.joinDirFile |
220 | {dir = Config.homeBase, |
221 | file = user} |
222 | val realLogDir = OS.Path.joinDirFile |
223 | {dir = realLogDir, |
224 | file = "apache"} |
225 | val realLogDir = OS.Path.joinDirFile |
226 | {dir = realLogDir, |
227 | file = "log"} |
228 | val realLogDir = OS.Path.joinDirFile |
229 | {dir = realLogDir, |
230 | file = Slave.hostname ()} |
231 | val {base, ...} = OS.Path.splitBaseExt (#file spl) |
232 | val realLogDir = OS.Path.joinDirFile |
233 | {dir = realLogDir, |
234 | file = base} |
235 | in |
236 | vhostsChanged := true; |
237 | case #action fs of |
238 | Slave.Delete => |
8bd6a399 |
239 | (if !logDeleted then |
240 | () |
241 | else |
242 | (ignore (OS.Process.system Config.Apache.down); |
243 | logDeleted := true); |
244 | ignore (OS.Process.system (Config.rm |
037af74e |
245 | ^ " -rf " |
246 | ^ realVhostFile)); |
acb4199f |
247 | ignore (OS.Process.system (Config.rm |
248 | ^ " -rf " |
037af74e |
249 | ^ realLogDir))) |
250 | | Slave.Add => |
251 | (ignore (OS.Process.system (Config.cp |
252 | ^ " " |
253 | ^ #file fs |
254 | ^ " " |
255 | ^ realVhostFile)); |
7d32cf2f |
256 | if Posix.FileSys.access (realLogDir, []) then |
257 | () |
258 | else |
259 | OS.FileSys.mkDir realLogDir) |
037af74e |
260 | |
261 | | _ => |
262 | ignore (OS.Process.system (Config.cp |
263 | ^ " " |
264 | ^ #file fs |
265 | ^ " " |
266 | ^ realVhostFile)) |
267 | end |
268 | else |
269 | () |
270 | end) |
d68ab27c |
271 | |
272 | val () = Slave.registerPostHandler |
273 | (fn () => |
274 | (if !vhostsChanged then |
8bd6a399 |
275 | Slave.shellF ([if !logDeleted then Config.Apache.undown else Config.Apache.reload], |
d68ab27c |
276 | fn cl => "Error reloading Apache with " ^ cl) |
277 | else |
278 | ())) |
279 | |
037af74e |
280 | val vhostFiles : (string * TextIO.outstream) list ref = ref [] |
281 | fun write' s = app (fn (node, file) => TextIO.output (file, s node)) (!vhostFiles) |
282 | fun write s = app (fn (_, file) => TextIO.output (file, s)) (!vhostFiles) |
d68ab27c |
283 | |
697d1a52 |
284 | val rewriteEnabled = ref false |
19bdfddd |
285 | val localRewriteEnabled = ref false |
3d3acca9 |
286 | val currentVhost = ref "" |
287 | val currentVhostId = ref "" |
697d1a52 |
288 | |
037af74e |
289 | val pre = ref (fn _ : {user : string, nodes : string list, id : string, hostname : string} => ()) |
e1cb845e |
290 | fun registerPre f = |
291 | let |
292 | val old = !pre |
293 | in |
294 | pre := (fn x => (old x; f x)) |
295 | end |
296 | |
297 | val post = ref (fn () => ()) |
298 | fun registerPost f = |
299 | let |
300 | val old = !post |
301 | in |
302 | post := (fn () => (old (); f ())) |
303 | end |
304 | |
305 | val aliaser = ref (fn _ : string => ()) |
306 | fun registerAliaser f = |
307 | let |
308 | val old = !aliaser |
309 | in |
310 | aliaser := (fn x => (old x; f x)) |
311 | end |
312 | |
d68ab27c |
313 | val () = Env.containerV_one "vhost" |
314 | ("host", Env.string) |
315 | (fn (env, host) => |
316 | let |
317 | val nodes = Env.env (Env.list Env.string) (env, "WebNodes") |
318 | |
319 | val ssl = Env.env Env.bool (env, "SSL") |
320 | val user = Env.env Env.string (env, "User") |
321 | val group = Env.env Env.string (env, "Group") |
322 | val docroot = Env.env Env.string (env, "DocumentRoot") |
323 | val sadmin = Env.env Env.string (env, "ServerAdmin") |
324 | |
325 | val fullHost = host ^ "." ^ Domain.currentDomain () |
3d3acca9 |
326 | val vhostId = fullHost ^ (if ssl then ".ssl" else "") |
d68ab27c |
327 | val confFile = fullHost ^ (if ssl then ".vhost_ssl" else ".vhost") |
328 | in |
3d3acca9 |
329 | currentVhost := fullHost; |
330 | currentVhostId := vhostId; |
331 | |
697d1a52 |
332 | rewriteEnabled := false; |
19bdfddd |
333 | localRewriteEnabled := false; |
d68ab27c |
334 | vhostFiles := map (fn node => |
335 | let |
336 | val file = Domain.domainFile {node = node, |
337 | name = confFile} |
338 | in |
339 | TextIO.output (file, "<VirtualHost "); |
340 | TextIO.output (file, Domain.nodeIp node); |
341 | TextIO.output (file, ":"); |
342 | TextIO.output (file, if ssl then |
343 | "443" |
344 | else |
345 | "80"); |
346 | TextIO.output (file, ">\n"); |
037af74e |
347 | TextIO.output (file, "\tErrorLog "); |
348 | TextIO.output (file, Config.homeBase); |
349 | TextIO.output (file, "/"); |
350 | TextIO.output (file, user); |
351 | TextIO.output (file, "/apache/log/"); |
352 | TextIO.output (file, node); |
353 | TextIO.output (file, "/"); |
354 | TextIO.output (file, vhostId); |
355 | TextIO.output (file, "/error.log\n\tCustomLog "); |
356 | TextIO.output (file, Config.homeBase); |
357 | TextIO.output (file, "/"); |
358 | TextIO.output (file, user); |
359 | TextIO.output (file, "/apache/log/"); |
360 | TextIO.output (file, node); |
361 | TextIO.output (file, "/"); |
362 | TextIO.output (file, vhostId); |
363 | TextIO.output (file, "/access.log combined\n"); |
364 | (Config.homeBase ^ "/" ^ user ^ "/apache/log/" |
365 | ^ node ^ "/" ^ vhostId, file) |
d68ab27c |
366 | end) |
367 | nodes; |
69d98465 |
368 | write "\tServerName "; |
369 | write fullHost; |
370 | write "\n\tSuexecUserGroup "; |
d68ab27c |
371 | write user; |
372 | write " "; |
373 | write group; |
374 | write "\n\tDocumentRoot "; |
375 | write docroot; |
376 | write "\n\tServerAdmin "; |
377 | write sadmin; |
037af74e |
378 | write "\n"; |
379 | !pre {user = user, nodes = nodes, id = vhostId, hostname = fullHost} |
d68ab27c |
380 | end, |
e1cb845e |
381 | fn () => (!post (); |
382 | write "</VirtualHost>\n"; |
037af74e |
383 | app (TextIO.closeOut o #2) (!vhostFiles))) |
d68ab27c |
384 | |
19bdfddd |
385 | val inLocal = ref false |
386 | |
ff2a424a |
387 | val () = Env.container_one "location" |
388 | ("prefix", Env.string) |
389 | (fn prefix => |
390 | (write "\t<Location "; |
391 | write prefix; |
19bdfddd |
392 | write ">\n"; |
393 | inLocal := true), |
394 | fn () => (write "\t</Location>\n"; |
395 | inLocal := false; |
396 | localRewriteEnabled := false)) |
ff2a424a |
397 | |
398 | val () = Env.container_one "directory" |
399 | ("directory", Env.string) |
400 | (fn directory => |
401 | (write "\t<Directory "; |
402 | write directory; |
19bdfddd |
403 | write ">\n"; |
404 | inLocal := true), |
405 | fn () => (write "\t</Directory>\n"; |
406 | inLocal := false; |
407 | localRewriteEnabled := false)) |
ff2a424a |
408 | |
697d1a52 |
409 | fun checkRewrite () = |
19bdfddd |
410 | if !inLocal then |
411 | if !rewriteEnabled orelse !localRewriteEnabled then |
412 | () |
413 | else |
414 | (write "\tRewriteEngine on\n"; |
415 | localRewriteEnabled := true) |
416 | else if !rewriteEnabled then |
697d1a52 |
417 | () |
418 | else |
419 | (write "\tRewriteEngine on\n"; |
420 | rewriteEnabled := true) |
421 | |
422 | val () = Env.action_three "localProxyRewrite" |
423 | ("from", Env.string, "to", Env.string, "port", Env.int) |
424 | (fn (from, to, port) => |
425 | (checkRewrite (); |
426 | write "\tRewriteRule\t"; |
427 | write from; |
428 | write "\thttp://localhost:"; |
429 | write (Int.toString port); |
430 | write "/"; |
431 | write to; |
432 | write " [P]\n")) |
433 | |
169731e9 |
434 | val () = Env.action_two "proxyPass" |
435 | ("from", Env.string, "to", Env.string) |
436 | (fn (from, to) => |
437 | (write "\tProxyPass\t"; |
438 | write from; |
439 | write "\t"; |
440 | write to; |
441 | write "\n")) |
442 | |
443 | val () = Env.action_two "proxyPassReverse" |
444 | ("from", Env.string, "to", Env.string) |
445 | (fn (from, to) => |
446 | (write "\tProxyPassReverse\t"; |
447 | write from; |
448 | write "\t"; |
449 | write to; |
450 | write "\n")) |
697d1a52 |
451 | |
452 | val () = Env.action_three "rewriteRule" |
453 | ("from", Env.string, "to", Env.string, "flags", Env.list flag) |
454 | (fn (from, to, flags) => |
455 | (checkRewrite (); |
456 | write "\tRewriteRule\t"; |
457 | write from; |
458 | write "\t"; |
459 | write to; |
460 | case flags of |
461 | [] => () |
462 | | flag::rest => (write " ["; |
463 | write flag; |
464 | app (fn flag => (write ","; |
465 | write flag)) rest; |
466 | write "]"); |
467 | write "\n")) |
468 | |
169731e9 |
469 | val () = Env.action_three "rewriteCond" |
470 | ("test", Env.string, "pattern", Env.string, "flags", Env.list cond_flag) |
471 | (fn (from, to, flags) => |
472 | (checkRewrite (); |
473 | write "\tRewriteCond\t"; |
474 | write from; |
475 | write "\t"; |
476 | write to; |
477 | case flags of |
478 | [] => () |
479 | | flag::rest => (write " ["; |
480 | write flag; |
481 | app (fn flag => (write ","; |
482 | write flag)) rest; |
483 | write "]"); |
484 | write "\n")) |
485 | |
3d3acca9 |
486 | val () = Env.action_one "rewriteLogLevel" |
487 | ("level", Env.int) |
488 | (fn level => |
489 | (checkRewrite (); |
490 | write "\tRewriteLog "; |
037af74e |
491 | write' (fn x => x); |
3d3acca9 |
492 | write "/rewrite.log\n\tRewriteLogLevel "; |
493 | write (Int.toString level); |
494 | write "\n")) |
495 | |
0279185b |
496 | val () = Env.action_two "alias" |
497 | ("from", Env.string, "to", Env.string) |
498 | (fn (from, to) => |
499 | (write "\tAlias\t"; |
500 | write from; |
501 | write " "; |
502 | write to; |
503 | write "\n")) |
504 | |
505 | val () = Env.action_two "scriptAlias" |
506 | ("from", Env.string, "to", Env.string) |
507 | (fn (from, to) => |
508 | (write "\tScriptAlias\t"; |
509 | write from; |
510 | write " "; |
511 | write to; |
512 | write "\n")) |
513 | |
514 | val () = Env.action_two "errorDocument" |
515 | ("code", Env.string, "handler", Env.string) |
516 | (fn (code, handler) => |
517 | (write "\tErrorDocument\t"; |
518 | write code; |
519 | write " "; |
520 | write handler; |
521 | write "\n")) |
522 | |
ff8db773 |
523 | val () = Env.action_one "options" |
524 | ("options", Env.list apache_option) |
525 | (fn opts => |
526 | case opts of |
527 | [] => () |
528 | | _ => (write "\tOptions"; |
529 | app (fn opt => (write " "; write opt)) opts; |
530 | write "\n")) |
531 | |
532 | val () = Env.action_one "set_options" |
533 | ("options", Env.list apache_option) |
534 | (fn opts => |
535 | case opts of |
536 | [] => () |
537 | | _ => (write "\tOptions"; |
538 | app (fn opt => (write " +"; write opt)) opts; |
539 | write "\n")) |
540 | |
541 | val () = Env.action_one "unset_options" |
542 | ("options", Env.list apache_option) |
543 | (fn opts => |
544 | case opts of |
545 | [] => () |
546 | | _ => (write "\tOptions"; |
547 | app (fn opt => (write " -"; write opt)) opts; |
548 | write "\n")) |
0279185b |
549 | |
69d98465 |
550 | val () = Env.action_one "directoryIndex" |
551 | ("filenames", Env.list Env.string) |
552 | (fn opts => |
553 | (write "\tDirectoryIndex"; |
554 | app (fn opt => (write " "; write opt)) opts; |
555 | write "\n")) |
556 | |
557 | val () = Env.action_one "serverAlias" |
558 | ("host", Env.string) |
559 | (fn host => |
560 | (write "\tServerAlias "; |
561 | write host; |
e1cb845e |
562 | write "\n"; |
563 | !aliaser host)) |
69d98465 |
564 | |
00e4345d |
565 | val authType = fn (EVar "basic", _) => SOME "basic" |
566 | | (EVar "digest", _) => SOME "digest" |
567 | | _ => NONE |
568 | |
569 | val () = Env.action_one "authType" |
570 | ("type", authType) |
571 | (fn ty => |
572 | (write "\tAuthType "; |
573 | write ty; |
574 | write "\n")) |
575 | |
576 | val () = Env.action_one "authName" |
577 | ("name", Env.string) |
578 | (fn name => |
579 | (write "\tAuthName \""; |
580 | write name; |
581 | write "\"\n")) |
582 | |
583 | val () = Env.action_one "authUserFile" |
584 | ("file", Env.string) |
585 | (fn name => |
586 | (write "\tAuthUserFile "; |
587 | write name; |
588 | write "\n")) |
589 | |
590 | val () = Env.action_none "requireValidUser" |
591 | (fn () => write "\tRequire valid-user\n") |
592 | |
593 | val () = Env.action_one "requireUser" |
594 | ("users", Env.list Env.string) |
595 | (fn names => |
596 | case names of |
597 | [] => () |
598 | | _ => (write "\tRequire user"; |
599 | app (fn name => (write " "; write name)) names; |
600 | write "\n")) |
601 | |
602 | val () = Env.action_one "requireGroup" |
603 | ("groups", Env.list Env.string) |
604 | (fn names => |
605 | case names of |
606 | [] => () |
607 | | _ => (write "\tRequire group"; |
608 | app (fn name => (write " "; write name)) names; |
609 | write "\n")) |
610 | |
611 | val () = Env.action_none "orderAllowDeny" |
612 | (fn () => write "\tOrder allow,deny\n") |
613 | |
614 | val () = Env.action_none "orderDenyAllow" |
615 | (fn () => write "\tOrder deny,allow\n") |
616 | |
617 | val () = Env.action_none "allowFromAll" |
618 | (fn () => write "\tAllow from all\n") |
619 | |
620 | val () = Env.action_one "allowFrom" |
621 | ("entries", Env.list Env.string) |
622 | (fn names => |
623 | case names of |
624 | [] => () |
625 | | _ => (write "\tAllow from"; |
626 | app (fn name => (write " "; write name)) names; |
627 | write "\n")) |
628 | |
629 | val () = Env.action_none "denyFromAll" |
630 | (fn () => write "\tDeny from all\n") |
631 | |
632 | val () = Env.action_one "denyFrom" |
633 | ("entries", Env.list Env.string) |
634 | (fn names => |
635 | case names of |
636 | [] => () |
637 | | _ => (write "\tDeny from"; |
638 | app (fn name => (write " "; write name)) names; |
639 | write "\n")) |
640 | |
641 | val () = Env.action_none "satisfyAll" |
642 | (fn () => write "\tSatisfy all\n") |
643 | |
644 | val () = Env.action_none "satisfyAny" |
645 | (fn () => write "\tSatisfy any\n") |
646 | |
4cc63b03 |
647 | val () = Env.action_one "forceType" |
648 | ("type", Env.string) |
649 | (fn ty => (write "\tForceType "; |
650 | write ty; |
651 | write "\n")) |
652 | |
653 | val () = Env.action_none "forceTypeOff" |
654 | (fn () => write "\tForceType None\n") |
655 | |
656 | val () = Env.action_two "action" |
657 | ("what", Env.string, "how", Env.string) |
658 | (fn (what, how) => (write "\tAction "; |
659 | write what; |
660 | write " "; |
661 | write how; |
662 | write "\n")) |
663 | |
664 | val () = Env.action_one "addDefaultCharset" |
665 | ("charset", Env.string) |
666 | (fn ty => (write "\tAddDefaultCharset "; |
667 | write ty; |
668 | write "\n")) |
669 | |
26716b02 |
670 | (*val () = Env.action_one "davSvn" |
efffba2a |
671 | ("path", Env.string) |
672 | (fn path => (write "\tDAV svn\n\tSVNPath "; |
673 | write path; |
674 | write "\n")) |
675 | |
676 | val () = Env.action_one "authzSvnAccessFile" |
677 | ("path", Env.string) |
678 | (fn path => (write "\tAuthzSVNAccessFile "; |
679 | write path; |
26716b02 |
680 | write "\n"))*) |
efffba2a |
681 | |
db9c7cb7 |
682 | val () = Env.action_two "addDescription" |
683 | ("description", Env.string, "patterns", Env.list Env.string) |
684 | (fn (desc, pats) => |
685 | case pats of |
686 | [] => () |
687 | | _ => (write "\tAddDescription \""; |
688 | write (String.toString desc); |
689 | write "\""; |
690 | app (fn pat => (write " "; write pat)) pats; |
691 | write "\n")) |
692 | |
693 | val () = Env.action_one "indexOptions" |
694 | ("options", Env.list autoindex_option) |
695 | (fn opts => |
696 | case opts of |
697 | [] => () |
698 | | _ => (write "\tIndexOptions"; |
699 | app (fn (opt, arg) => |
700 | (write " "; |
701 | write opt; |
702 | Option.app (fn arg => |
703 | (write "="; write arg)) arg)) opts; |
704 | write "\n")) |
705 | |
706 | val () = Env.action_one "set_indexOptions" |
707 | ("options", Env.list autoindex_option) |
708 | (fn opts => |
709 | case opts of |
710 | [] => () |
711 | | _ => (write "\tIndexOptions"; |
712 | app (fn (opt, arg) => |
713 | (write " +"; |
714 | write opt; |
715 | Option.app (fn arg => |
716 | (write "="; write arg)) arg)) opts; |
717 | write "\n")) |
718 | |
719 | val () = Env.action_one "unset_indexOptions" |
720 | ("options", Env.list autoindex_option) |
721 | (fn opts => |
722 | case opts of |
723 | [] => () |
724 | | _ => (write "\tIndexOptions"; |
725 | app (fn (opt, _) => |
726 | (write " -"; |
727 | write opt)) opts; |
728 | write "\n")) |
729 | |
730 | val () = Env.action_one "headerName" |
731 | ("name", Env.string) |
732 | (fn name => (write "\tHeaderName "; |
733 | write name; |
734 | write "\n")) |
735 | |
736 | val () = Env.action_one "readmeName" |
737 | ("name", Env.string) |
738 | (fn name => (write "\tReadmeName "; |
739 | write name; |
740 | write "\n")) |
741 | |
d68ab27c |
742 | end |