7e3deb51de4b549f2131df5ead5004321bdaec4a
[hcoop/domtool2.git] / src / plugins / apache.sml
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
25 val _ = Env.type_one "web_node"
26 Env.string
27 (fn node =>
28 List.exists (fn (x, _) => x = node) Config.Apache.webNodes_all
29 orelse (Domain.hasPriv "www"
30 andalso List.exists (fn (x, _) => x = node) Config.Apache.webNodes_admin))
31
32 val _ = Env.registerFunction ("web_node_to_node",
33 fn [e] => SOME e
34 | _ => NONE)
35
36 val _ = Env.type_one "proxy_port"
37 Env.int
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)
56
57 val _ = Env.type_one "rewrite_arg"
58 Env.string
59 (CharVector.all Char.isAlphaNum)
60
61 val _ = Env.type_one "suexec_flag"
62 Env.bool
63 (fn b => b orelse Domain.hasPriv "www")
64
65 fun validLocation s =
66 size s > 0 andalso size s < 1000 andalso CharVector.all
67 (fn ch => Char.isAlphaNum ch
68 orelse ch = #"-"
69 orelse ch = #"_"
70 orelse ch = #"."
71 orelse ch = #"/") s
72
73 val _ = Env.type_one "location"
74 Env.string
75 validLocation
76
77 fun validCert s = Acl.query {user = Domain.getUser (),
78 class = "cert",
79 value = s}
80
81 val _ = Env.type_one "ssl_cert_path"
82 Env.string
83 validCert
84
85 fun ssl e = case e of
86 (EVar "no_ssl", _) => SOME NONE
87 | (EApp ((EVar "use_cert", _), s), _) => Option.map SOME (Env.string s)
88 | _ => NONE
89
90 val dl = ErrorMsg.dummyLoc
91
92 val _ = Defaults.registerDefault ("WebNodes",
93 (TList (TBase "web_node", dl), dl),
94 (fn () => (EList (map (fn s => (EString s, dl)) Config.Apache.webNodes_default), dl)))
95
96 val _ = Defaults.registerDefault ("SSL",
97 (TBase "ssl", dl),
98 (fn () => (EVar "no_ssl", dl)))
99
100 val _ = Defaults.registerDefault ("User",
101 (TBase "your_user", dl),
102 (fn () => (EString (Domain.getUser ()), dl)))
103
104 val _ = Defaults.registerDefault ("Group",
105 (TBase "your_group", dl),
106 (fn () => (EString (Domain.getUser ()), dl)))
107
108 val _ = Defaults.registerDefault ("DocumentRoot",
109 (TBase "your_path", dl),
110 (fn () => (EString (Domain.homedir () ^ "/" ^ Config.Apache.public_html), dl)))
111
112 val _ = Defaults.registerDefault ("ServerAdmin",
113 (TBase "email", dl),
114 (fn () => (EString (Domain.getUser () ^ "@" ^ Config.defaultDomain), dl)))
115
116 val _ = Defaults.registerDefault ("SuExec",
117 (TBase "suexec_flag", dl),
118 (fn () => (EVar "true", dl)))
119
120 val redirect_code = fn (EVar "temp", _) => SOME "temp"
121 | (EVar "permanent", _) => SOME "permanent"
122 | (EVar "seeother", _) => SOME "seeother"
123 | (EVar "redir300", _) => SOME "300"
124 | (EVar "redir301", _) => SOME "301"
125 | (EVar "redir302", _) => SOME "302"
126 | (EVar "redir303", _) => SOME "303"
127 | (EVar "redir304", _) => SOME "304"
128 | (EVar "redir305", _) => SOME "305"
129 | (EVar "redir307", _) => SOME "307"
130 | _ => NONE
131
132 val flag = fn (EVar "redirect", _) => SOME "R"
133 | (EVar "forbidden", _) => SOME "F"
134 | (EVar "gone", _) => SOME "G"
135 | (EVar "last", _) => SOME "L"
136 | (EVar "chain", _) => SOME "C"
137 | (EVar "nosubreq", _) => SOME "NS"
138 | (EVar "nocase", _) => SOME "NC"
139 | (EVar "qsappend", _) => SOME "QSA"
140 | (EVar "noescape", _) => SOME "NE"
141 | (EVar "passthrough", _) => SOME "PT"
142 | (EApp ((EVar "mimeType", _), e), _) =>
143 Option.map (fn s => "T=" ^ s) (Env.string e)
144 | (EApp ((EVar "redirectWith", _), e), _) =>
145 Option.map (fn s => "R=" ^ s) (redirect_code e)
146 | (EApp ((EVar "skip", _), e), _) =>
147 Option.map (fn n => "S=" ^ Int.toString n) (Env.int e)
148 | (EApp ((EApp ((EVar "env", _), e1), _), e2), _) =>
149 (case Env.string e1 of
150 NONE => NONE
151 | SOME s1 => Option.map (fn s2 => "E=" ^ s1 ^ ":" ^ s2)
152 (Env.string e2))
153
154 | _ => NONE
155
156 val cond_flag = fn (EVar "cond_nocase", _) => SOME "NC"
157 | (EVar "ornext", _) => SOME "OR"
158 | _ => NONE
159
160 val apache_option = fn (EVar "execCGI", _) => SOME "ExecCGI"
161 | (EVar "includesNOEXEC", _) => SOME "IncludesNOEXEC"
162 | (EVar "indexes", _) => SOME "Indexes"
163 | _ => NONE
164
165 val autoindex_width = fn (EVar "autofit", _) => SOME "*"
166 | (EApp ((EVar "characters", _), n), _) =>
167 Option.map Int.toString (Env.int n)
168 | _ => NONE
169
170 val autoindex_option = fn (EApp ((EVar "descriptionWidth", _), w), _) =>
171 Option.map (fn w => ("DescriptionWidth", SOME w))
172 (autoindex_width w)
173 | (EVar "fancyIndexing", _) => SOME ("FancyIndexing", NONE)
174 | (EVar "foldersFirst", _) => SOME ("FoldersFirst", NONE)
175 | (EVar "htmlTable", _) => SOME ("HTMLTable", NONE)
176 | (EVar "iconsAreLinks", _) => SOME ("IconsAreLinks", NONE)
177 | (EApp ((EVar "iconHeight", _), n), _) =>
178 Option.map (fn w => ("IconHeight", SOME (Int.toString w)))
179 (Env.int n)
180 | (EApp ((EVar "iconWidth", _), n), _) =>
181 Option.map (fn w => ("IconWidth", SOME (Int.toString w)))
182 (Env.int n)
183 | (EVar "ignoreCase", _) => SOME ("IgnoreCase", NONE)
184 | (EVar "ignoreClient", _) => SOME ("IgnoreClient", NONE)
185 | (EApp ((EVar "nameWidth", _), w), _) =>
186 Option.map (fn w => ("NameWidth", SOME w))
187 (autoindex_width w)
188 | (EVar "scanHtmlTitles", _) => SOME ("ScanHTMLTitles", NONE)
189 | (EVar "suppressColumnSorting", _) => SOME ("SuppressColumnSorting", NONE)
190 | (EVar "suppressDescription", _) => SOME ("SuppressDescription", NONE)
191 | (EVar "suppressHtmlPreamble", _) => SOME ("SuppressHTMLPreamble", NONE)
192 | (EVar "suppressIcon", _) => SOME ("SuppressIcon", NONE)
193 | (EVar "suppressLastModified", _) => SOME ("SuppressLastModified", NONE)
194 | (EVar "suppressRules", _) => SOME ("SuppressRules", NONE)
195 | (EVar "suppressSize", _) => SOME ("SuppressSize", NONE)
196 | (EVar "trackModified", _) => SOME ("TrackModified", NONE)
197 | (EVar "versionSort", _) => SOME ("VersionSort", NONE)
198 | (EVar "xhtml", _) => SOME ("XHTML", NONE)
199
200 | _ => NONE
201
202 val vhostsChanged = ref false
203 val logDeleted = ref false
204
205 val () = Slave.registerPreHandler
206 (fn () => (vhostsChanged := false;
207 logDeleted := false))
208
209 fun findVhostUser fname =
210 let
211 val inf = TextIO.openIn fname
212
213 fun loop () =
214 case TextIO.inputLine inf of
215 NONE => NONE
216 | SOME line =>
217 if String.isPrefix "# Owner: " line then
218 case String.tokens Char.isSpace line of
219 [_, _, user] => SOME user
220 | _ => NONE
221 else
222 loop ()
223 in
224 loop ()
225 before TextIO.closeIn inf
226 end handle _ => NONE
227
228 val webNodes_full = Config.Apache.webNodes_all @ Config.Apache.webNodes_admin
229
230 fun isVersion1 node =
231 List.exists (fn (n, {version = ConfigTypes.APACHE_1_3, ...}) => n = node
232 | _ => false) webNodes_full
233
234 fun imVersion1 () = isVersion1 (Slave.hostname ())
235
236 fun isWaklog node =
237 List.exists (fn (n, {auth = ConfigTypes.MOD_WAKLOG, ...}) => n = node
238 | _ => false) webNodes_full
239
240 fun down () = if imVersion1 () then Config.Apache.down1 else Config.Apache.down
241 fun undown () = if imVersion1 () then Config.Apache.undown1 else Config.Apache.undown
242 fun reload () = if imVersion1 () then Config.Apache.reload1 else Config.Apache.reload
243
244 fun logDir {user, node, vhostId} =
245 String.concat [Config.Apache.logDirOf (isVersion1 node) user,
246 "/",
247 node,
248 "/",
249 vhostId]
250
251 val () = Slave.registerFileHandler (fn fs =>
252 let
253 val spl = OS.Path.splitDirFile (#file fs)
254 in
255 if String.isSuffix ".vhost" (#file spl)
256 orelse String.isSuffix ".vhost_ssl" (#file spl) then let
257 val realVhostFile = OS.Path.joinDirFile
258 {dir = Config.Apache.confDir,
259 file = #file spl}
260
261 val user = findVhostUser (#file fs)
262 val oldUser = findVhostUser realVhostFile
263 in
264 if (oldUser = NONE andalso #action fs <> Slave.Add)
265 orelse (user = NONE andalso #action fs <> Slave.Delete) then
266 print ("Can't find user in " ^ #file fs ^ " or " ^ realVhostFile ^ "! Taking no action.\n")
267 else
268 let
269 val vhostId = if OS.Path.ext (#file spl) = SOME "vhost_ssl" then
270 OS.Path.base (#file spl) ^ ".ssl"
271 else
272 OS.Path.base (#file spl)
273
274 fun realLogDir user =
275 logDir {user = valOf user,
276 node = Slave.hostname (),
277 vhostId = vhostId}
278 in
279 vhostsChanged := true;
280 case #action fs of
281 Slave.Delete =>
282 (if !logDeleted then
283 ()
284 else
285 (ignore (OS.Process.system (down ()));
286 logDeleted := true);
287 ignore (OS.Process.system (Config.rm
288 ^ " -rf "
289 ^ realVhostFile));
290 ignore (OS.Process.system (Config.rm
291 ^ " -rf "
292 ^ realLogDir oldUser)))
293 | Slave.Add =>
294 let
295 val rld = realLogDir user
296 in
297 ignore (OS.Process.system (Config.cp
298 ^ " "
299 ^ #file fs
300 ^ " "
301 ^ realVhostFile));
302 if Posix.FileSys.access (rld, []) then
303 ()
304 else
305 Slave.mkDirAll rld
306 end
307
308 | _ =>
309 (ignore (OS.Process.system (Config.cp
310 ^ " "
311 ^ #file fs
312 ^ " "
313 ^ realVhostFile));
314 if user <> oldUser then
315 let
316 val old = realLogDir oldUser
317 val rld = realLogDir user
318 in
319 if !logDeleted then
320 ()
321 else
322 (ignore (OS.Process.system (down ()));
323 logDeleted := true);
324 ignore (OS.Process.system (Config.rm
325 ^ " -rf "
326 ^ realLogDir oldUser));
327 if Posix.FileSys.access (rld, []) then
328 ()
329 else
330 Slave.mkDirAll rld
331 end
332 else
333 ())
334 end
335 end
336 else
337 ()
338 end)
339
340 val () = Slave.registerPostHandler
341 (fn () =>
342 (if !vhostsChanged then
343 Slave.shellF ([if !logDeleted then undown () else reload ()],
344 fn cl => "Error reloading Apache with " ^ cl)
345 else
346 ()))
347
348 val vhostFiles : (string * TextIO.outstream) list ref = ref []
349 fun write' s = app (fn (node, file) => TextIO.output (file, s node)) (!vhostFiles)
350 fun write s = app (fn (_, file) => TextIO.output (file, s)) (!vhostFiles)
351
352 val rewriteEnabled = ref false
353 val localRewriteEnabled = ref false
354 val currentVhost = ref ""
355 val currentVhostId = ref ""
356
357 val pre = ref (fn _ : {user : string, nodes : string list, id : string, hostname : string} => ())
358 fun registerPre f =
359 let
360 val old = !pre
361 in
362 pre := (fn x => (old x; f x))
363 end
364
365 val post = ref (fn () => ())
366 fun registerPost f =
367 let
368 val old = !post
369 in
370 post := (fn () => (old (); f ()))
371 end
372
373 val aliaser = ref (fn _ : string => ())
374 fun registerAliaser f =
375 let
376 val old = !aliaser
377 in
378 aliaser := (fn x => (old x; f x))
379 end
380
381 val () = Env.containerV_one "vhost"
382 ("host", Env.string)
383 (fn (env, host) =>
384 let
385 val nodes = Env.env (Env.list Env.string) (env, "WebNodes")
386
387 val ssl = Env.env ssl (env, "SSL")
388 val user = Env.env Env.string (env, "User")
389 val group = Env.env Env.string (env, "Group")
390 val docroot = Env.env Env.string (env, "DocumentRoot")
391 val sadmin = Env.env Env.string (env, "ServerAdmin")
392 val suexec = Env.env Env.bool (env, "SuExec")
393
394 val fullHost = host ^ "." ^ Domain.currentDomain ()
395 val vhostId = fullHost ^ (if Option.isSome ssl then ".ssl" else "")
396 val confFile = fullHost ^ (if Option.isSome ssl then ".vhost_ssl" else ".vhost")
397 in
398 currentVhost := fullHost;
399 currentVhostId := vhostId;
400
401 rewriteEnabled := false;
402 localRewriteEnabled := false;
403 vhostFiles := map (fn node =>
404 let
405 val file = Domain.domainFile {node = node,
406 name = confFile}
407
408 val ld = logDir {user = user, node = node, vhostId = vhostId}
409 in
410 TextIO.output (file, "# Owner: ");
411 TextIO.output (file, user);
412 TextIO.output (file, "\n<VirtualHost ");
413 TextIO.output (file, Domain.nodeIp node);
414 TextIO.output (file, ":");
415 TextIO.output (file, case ssl of
416 SOME _ => "443"
417 | NONE => "80");
418 TextIO.output (file, ">\n");
419 TextIO.output (file, "\tErrorLog ");
420 TextIO.output (file, ld);
421 TextIO.output (file, "/error.log\n\tCustomLog ");
422 TextIO.output (file, ld);
423 TextIO.output (file, "/access.log combined\n");
424 TextIO.output (file, "\tServerName ");
425 TextIO.output (file, fullHost);
426 app
427 (fn dom => (TextIO.output (file, "\n\tServerAlias ");
428 TextIO.output (file, host);
429 TextIO.output (file, ".");
430 TextIO.output (file, dom)))
431 (Domain.currentAliasDomains ());
432 if suexec then
433 if isVersion1 node then
434 (TextIO.output (file, "\n\tUser ");
435 TextIO.output (file, user);
436 TextIO.output (file, "\n\tGroup ");
437 TextIO.output (file, group))
438 else
439 (TextIO.output (file, "\n\tSuexecUserGroup ");
440 TextIO.output (file, user);
441 TextIO.output (file, " ");
442 TextIO.output (file, group))
443 else
444 ();
445 if isWaklog node then
446 (TextIO.output (file, "\n\tWaklogProtected on\n\tWaklogPrincipal ");
447 TextIO.output (file, user);
448 TextIO.output (file, "/cgi@HCOOP.NET /etc/keytabs/cgi/");
449 TextIO.output (file, user))
450 else
451 ();
452 (ld, file)
453 end)
454 nodes;
455 write "\n\tDocumentRoot ";
456 write docroot;
457 write "\n\tServerAdmin ";
458 write sadmin;
459 case ssl of
460 SOME cert =>
461 (write "\n\tSSLEngine on\n\tSSLCertificateFile ";
462 write cert)
463 | NONE => ();
464 write "\n";
465 !pre {user = user, nodes = nodes, id = vhostId, hostname = fullHost}
466 end,
467 fn () => (!post ();
468 write "</VirtualHost>\n";
469 app (TextIO.closeOut o #2) (!vhostFiles)))
470
471 val inLocal = ref false
472
473 val () = Env.container_one "location"
474 ("prefix", Env.string)
475 (fn prefix =>
476 (write "\t<Location ";
477 write prefix;
478 write ">\n";
479 inLocal := true),
480 fn () => (write "\t</Location>\n";
481 inLocal := false;
482 localRewriteEnabled := false))
483
484 val () = Env.container_one "directory"
485 ("directory", Env.string)
486 (fn directory =>
487 (write "\t<Directory ";
488 write directory;
489 write ">\n";
490 inLocal := true),
491 fn () => (write "\t</Directory>\n";
492 inLocal := false;
493 localRewriteEnabled := false))
494
495 fun checkRewrite () =
496 if !inLocal then
497 if !rewriteEnabled orelse !localRewriteEnabled then
498 ()
499 else
500 (write "\tRewriteEngine on\n";
501 localRewriteEnabled := true)
502 else if !rewriteEnabled then
503 ()
504 else
505 (write "\tRewriteEngine on\n";
506 rewriteEnabled := true)
507
508 val () = Env.action_three "localProxyRewrite"
509 ("from", Env.string, "to", Env.string, "port", Env.int)
510 (fn (from, to, port) =>
511 (checkRewrite ();
512 write "\tRewriteRule\t";
513 write from;
514 write "\thttp://localhost:";
515 write (Int.toString port);
516 write "/";
517 write to;
518 write " [P]\n"))
519
520 val () = Env.action_two "proxyPass"
521 ("from", Env.string, "to", Env.string)
522 (fn (from, to) =>
523 (write "\tProxyPass\t";
524 write from;
525 write "\t";
526 write to;
527 write "\n"))
528
529 val () = Env.action_two "proxyPassReverse"
530 ("from", Env.string, "to", Env.string)
531 (fn (from, to) =>
532 (write "\tProxyPassReverse\t";
533 write from;
534 write "\t";
535 write to;
536 write "\n"))
537
538 val () = Env.action_three "rewriteRule"
539 ("from", Env.string, "to", Env.string, "flags", Env.list flag)
540 (fn (from, to, flags) =>
541 (checkRewrite ();
542 write "\tRewriteRule\t";
543 write from;
544 write "\t";
545 write to;
546 case flags of
547 [] => ()
548 | flag::rest => (write " [";
549 write flag;
550 app (fn flag => (write ",";
551 write flag)) rest;
552 write "]");
553 write "\n"))
554
555 val () = Env.action_three "rewriteCond"
556 ("test", Env.string, "pattern", Env.string, "flags", Env.list cond_flag)
557 (fn (from, to, flags) =>
558 (checkRewrite ();
559 write "\tRewriteCond\t";
560 write from;
561 write "\t";
562 write to;
563 case flags of
564 [] => ()
565 | flag::rest => (write " [";
566 write flag;
567 app (fn flag => (write ",";
568 write flag)) rest;
569 write "]");
570 write "\n"))
571
572 val () = Env.action_one "rewriteLogLevel"
573 ("level", Env.int)
574 (fn level =>
575 (checkRewrite ();
576 write "\tRewriteLog ";
577 write' (fn x => x);
578 write "/rewrite.log\n\tRewriteLogLevel ";
579 write (Int.toString level);
580 write "\n"))
581
582 val () = Env.action_two "alias"
583 ("from", Env.string, "to", Env.string)
584 (fn (from, to) =>
585 (write "\tAlias\t";
586 write from;
587 write " ";
588 write to;
589 write "\n"))
590
591 val () = Env.action_two "scriptAlias"
592 ("from", Env.string, "to", Env.string)
593 (fn (from, to) =>
594 (write "\tScriptAlias\t";
595 write from;
596 write " ";
597 write to;
598 write "\n"))
599
600 val () = Env.action_two "errorDocument"
601 ("code", Env.string, "handler", Env.string)
602 (fn (code, handler) =>
603 (write "\tErrorDocument\t";
604 write code;
605 write " ";
606 write handler;
607 write "\n"))
608
609 val () = Env.action_one "options"
610 ("options", Env.list apache_option)
611 (fn opts =>
612 case opts of
613 [] => ()
614 | _ => (write "\tOptions";
615 app (fn opt => (write " "; write opt)) opts;
616 write "\n"))
617
618 val () = Env.action_one "set_options"
619 ("options", Env.list apache_option)
620 (fn opts =>
621 case opts of
622 [] => ()
623 | _ => (write "\tOptions";
624 app (fn opt => (write " +"; write opt)) opts;
625 write "\n"))
626
627 val () = Env.action_one "unset_options"
628 ("options", Env.list apache_option)
629 (fn opts =>
630 case opts of
631 [] => ()
632 | _ => (write "\tOptions";
633 app (fn opt => (write " -"; write opt)) opts;
634 write "\n"))
635
636 val () = Env.action_one "directoryIndex"
637 ("filenames", Env.list Env.string)
638 (fn opts =>
639 (write "\tDirectoryIndex";
640 app (fn opt => (write " "; write opt)) opts;
641 write "\n"))
642
643 val () = Env.action_one "serverAliasHost"
644 ("host", Env.string)
645 (fn host =>
646 (write "\tServerAlias ";
647 write host;
648 write "\n";
649 !aliaser host))
650
651 val () = Env.action_one "serverAlias"
652 ("host", Env.string)
653 (fn host =>
654 (app
655 (fn dom =>
656 let
657 val full = host ^ "." ^ dom
658 in
659 write "\tServerAlias ";
660 write full;
661 write "\n";
662 !aliaser full
663 end)
664 (Domain.currentDomains ())))
665
666 val () = Env.action_none "serverAliasDefault"
667 (fn () =>
668 (app
669 (fn dom =>
670 (write "\tServerAlias ";
671 write dom;
672 write "\n";
673 !aliaser dom))
674 (Domain.currentDomains ())))
675
676 val authType = fn (EVar "basic", _) => SOME "basic"
677 | (EVar "digest", _) => SOME "digest"
678 | _ => NONE
679
680 val () = Env.action_one "authType"
681 ("type", authType)
682 (fn ty =>
683 (write "\tAuthType ";
684 write ty;
685 write "\n"))
686
687 val () = Env.action_one "authName"
688 ("name", Env.string)
689 (fn name =>
690 (write "\tAuthName \"";
691 write name;
692 write "\"\n"))
693
694 val () = Env.action_one "authUserFile"
695 ("file", Env.string)
696 (fn name =>
697 (write "\tAuthUserFile ";
698 write name;
699 write "\n"))
700
701 val () = Env.action_none "requireValidUser"
702 (fn () => write "\tRequire valid-user\n")
703
704 val () = Env.action_one "requireUser"
705 ("users", Env.list Env.string)
706 (fn names =>
707 case names of
708 [] => ()
709 | _ => (write "\tRequire user";
710 app (fn name => (write " "; write name)) names;
711 write "\n"))
712
713 val () = Env.action_one "requireGroup"
714 ("groups", Env.list Env.string)
715 (fn names =>
716 case names of
717 [] => ()
718 | _ => (write "\tRequire group";
719 app (fn name => (write " "; write name)) names;
720 write "\n"))
721
722 val () = Env.action_none "orderAllowDeny"
723 (fn () => write "\tOrder allow,deny\n")
724
725 val () = Env.action_none "orderDenyAllow"
726 (fn () => write "\tOrder deny,allow\n")
727
728 val () = Env.action_none "allowFromAll"
729 (fn () => write "\tAllow from all\n")
730
731 val () = Env.action_one "allowFrom"
732 ("entries", Env.list Env.string)
733 (fn names =>
734 case names of
735 [] => ()
736 | _ => (write "\tAllow from";
737 app (fn name => (write " "; write name)) names;
738 write "\n"))
739
740 val () = Env.action_none "denyFromAll"
741 (fn () => write "\tDeny from all\n")
742
743 val () = Env.action_one "denyFrom"
744 ("entries", Env.list Env.string)
745 (fn names =>
746 case names of
747 [] => ()
748 | _ => (write "\tDeny from";
749 app (fn name => (write " "; write name)) names;
750 write "\n"))
751
752 val () = Env.action_none "satisfyAll"
753 (fn () => write "\tSatisfy all\n")
754
755 val () = Env.action_none "satisfyAny"
756 (fn () => write "\tSatisfy any\n")
757
758 val () = Env.action_one "forceType"
759 ("type", Env.string)
760 (fn ty => (write "\tForceType ";
761 write ty;
762 write "\n"))
763
764 val () = Env.action_none "forceTypeOff"
765 (fn () => write "\tForceType None\n")
766
767 val () = Env.action_two "action"
768 ("what", Env.string, "how", Env.string)
769 (fn (what, how) => (write "\tAction ";
770 write what;
771 write " ";
772 write how;
773 write "\n"))
774
775 val () = Env.action_one "addDefaultCharset"
776 ("charset", Env.string)
777 (fn ty => (write "\tAddDefaultCharset ";
778 write ty;
779 write "\n"))
780
781 (*val () = Env.action_one "davSvn"
782 ("path", Env.string)
783 (fn path => (write "\tDAV svn\n\tSVNPath ";
784 write path;
785 write "\n"))
786
787 val () = Env.action_one "authzSvnAccessFile"
788 ("path", Env.string)
789 (fn path => (write "\tAuthzSVNAccessFile ";
790 write path;
791 write "\n"))*)
792
793 val () = Env.action_two "addDescription"
794 ("description", Env.string, "patterns", Env.list Env.string)
795 (fn (desc, pats) =>
796 case pats of
797 [] => ()
798 | _ => (write "\tAddDescription \"";
799 write (String.toString desc);
800 write "\"";
801 app (fn pat => (write " "; write pat)) pats;
802 write "\n"))
803
804 val () = Env.action_one "indexOptions"
805 ("options", Env.list autoindex_option)
806 (fn opts =>
807 case opts of
808 [] => ()
809 | _ => (write "\tIndexOptions";
810 app (fn (opt, arg) =>
811 (write " ";
812 write opt;
813 Option.app (fn arg =>
814 (write "="; write arg)) arg)) opts;
815 write "\n"))
816
817 val () = Env.action_one "set_indexOptions"
818 ("options", Env.list autoindex_option)
819 (fn opts =>
820 case opts of
821 [] => ()
822 | _ => (write "\tIndexOptions";
823 app (fn (opt, arg) =>
824 (write " +";
825 write opt;
826 Option.app (fn arg =>
827 (write "="; write arg)) arg)) opts;
828 write "\n"))
829
830 val () = Env.action_one "unset_indexOptions"
831 ("options", Env.list autoindex_option)
832 (fn opts =>
833 case opts of
834 [] => ()
835 | _ => (write "\tIndexOptions";
836 app (fn (opt, _) =>
837 (write " -";
838 write opt)) opts;
839 write "\n"))
840
841 val () = Env.action_one "headerName"
842 ("name", Env.string)
843 (fn name => (write "\tHeaderName ";
844 write name;
845 write "\n"))
846
847 val () = Env.action_one "readmeName"
848 ("name", Env.string)
849 (fn name => (write "\tReadmeName ";
850 write name;
851 write "\n"))
852
853 val () = Domain.registerResetLocal (fn () =>
854 ignore (OS.Process.system (Config.rm ^ " -rf /var/domtool/vhosts/*")))
855
856 end