1 (* HCoop
Domtool (http
://hcoop
.sourceforge
.net
/)
2 * Copyright (c
) 2006-2007, Adam Chlipala
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
.
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
.
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
.
19 (* Apache HTTPD handling
*)
21 structure Apache
:> APACHE
= struct
25 val dl
= ErrorMsg
.dummyLoc
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
)
32 val _
= Env
.type_one
"web_node"
36 val _
= Env
.registerFunction ("web_node_to_node",
40 fun webPlace (EApp ((EVar
"web_place_default", _
), (EString node
, _
)), _
) =
41 SOME (node
, Domain
.nodeIp node
)
42 |
webPlace (EApp ((EApp ((EVar
"web_place", _
), (EString node
, _
)), _
), (EString ip
, _
)), _
) =
46 fun webPlaceDefault node
= (EApp ((EVar
"web_place_default", dl
), (EString node
, dl
)), dl
)
48 val _
= Env
.registerFunction ("web_place_to_web_node",
49 fn [e
] => Option
.map (fn (node
, _
) => (EString node
, dl
)) (webPlace e
)
52 val _
= Env
.registerFunction ("web_place_to_node",
53 fn [e
] => Option
.map (fn (node
, _
) => (EString node
, dl
)) (webPlace e
)
56 val _
= Env
.registerFunction ("web_place_to_ip",
57 fn [e
] => Option
.map (fn (_
, ip
) => (EString ip
, dl
)) (webPlace e
)
60 val _
= Env
.type_one
"proxy_port"
64 val _
= Env
.type_one
"proxy_target"
68 fun default () = List.exists (fn s
' => s
= s
') Config
.Apache
.proxyTargets
70 case String.fields (fn ch
=> ch
= #
":") s
of
71 ["http", "//localhost", rest
] =>
72 (case String.fields (fn ch
=> ch
= #
"/") rest
of
74 (case Int.fromString port
of
76 | SOME n
=> n
> 1024 orelse default ())
81 val _
= Env
.type_one
"rewrite_arg"
83 (CharVector
.all
Char.isAlphaNum
)
85 val _
= Env
.type_one
"suexec_flag"
87 (fn b
=> b
orelse Domain
.hasPriv
"www")
90 size s
> 0 andalso size s
< 1000 andalso CharVector
.all
91 (fn ch
=> Char.isAlphaNum ch
97 val _
= Env
.type_one
"location"
101 fun validCert s
= Acl
.query
{user
= Domain
.getUser (),
105 val _
= Env
.type_one
"ssl_cert_path"
109 fun ssl e
= case e
of
110 (EVar
"no_ssl", _
) => SOME NONE
111 |
(EApp ((EVar
"use_cert", _
), s
), _
) => Option
.map
SOME (Env
.string s
)
114 val defaults
= [("WebPlaces",
115 (TList (TBase
"web_place", dl
), dl
),
116 (fn () => (EList (map webPlaceDefault Config
.Apache
.webNodes_default
), dl
))),
119 (fn () => (EVar
"no_ssl", dl
))),
121 (TBase
"your_user", dl
),
122 (fn () => (EString (Domain
.getUser ()), dl
))),
124 (TBase
"your_group", dl
),
125 (fn () => (EString
"nogroup", dl
))),
127 (TBase
"your_path", dl
),
128 (fn () => (EString (Domain
.homedir () ^
"/" ^ Config
.Apache
.public_html
), dl
))),
131 (fn () => (EString (Domain
.getUser () ^
"@" ^ Config
.defaultDomain
), dl
))),
133 (TBase
"suexec_flag", dl
),
134 (fn () => (EVar
"true", dl
)))]
136 val () = app Defaults
.registerDefault defaults
138 val redirect_code
= fn (EVar
"temp", _
) => SOME
"temp"
139 |
(EVar
"permanent", _
) => SOME
"permanent"
140 |
(EVar
"seeother", _
) => SOME
"seeother"
141 |
(EVar
"redir300", _
) => SOME
"300"
142 |
(EVar
"redir301", _
) => SOME
"301"
143 |
(EVar
"redir302", _
) => SOME
"302"
144 |
(EVar
"redir303", _
) => SOME
"303"
145 |
(EVar
"redir304", _
) => SOME
"304"
146 |
(EVar
"redir305", _
) => SOME
"305"
147 |
(EVar
"redir307", _
) => SOME
"307"
150 val flag
= fn (EVar
"redirect", _
) => SOME
"R"
151 |
(EVar
"forbidden", _
) => SOME
"F"
152 |
(EVar
"gone", _
) => SOME
"G"
153 |
(EVar
"last", _
) => SOME
"L"
154 |
(EVar
"chain", _
) => SOME
"C"
155 |
(EVar
"nosubreq", _
) => SOME
"NS"
156 |
(EVar
"nocase", _
) => SOME
"NC"
157 |
(EVar
"qsappend", _
) => SOME
"QSA"
158 |
(EVar
"noescape", _
) => SOME
"NE"
159 |
(EVar
"passthrough", _
) => SOME
"PT"
160 |
(EApp ((EVar
"mimeType", _
), e
), _
) =>
161 Option
.map (fn s
=> "T=" ^ s
) (Env
.string e
)
162 |
(EApp ((EVar
"redirectWith", _
), e
), _
) =>
163 Option
.map (fn s
=> "R=" ^ s
) (redirect_code e
)
164 |
(EApp ((EVar
"skip", _
), e
), _
) =>
165 Option
.map (fn n
=> "S=" ^
Int.toString n
) (Env
.int e
)
166 |
(EApp ((EApp ((EVar
"env", _
), e1
), _
), e2
), _
) =>
167 (case Env
.string e1
of
169 | SOME s1
=> Option
.map (fn s2
=> "E=" ^ s1 ^
":" ^ s2
)
174 val cond_flag
= fn (EVar
"cond_nocase", _
) => SOME
"NC"
175 |
(EVar
"ornext", _
) => SOME
"OR"
178 val apache_option
= fn (EVar
"execCGI", _
) => SOME
"ExecCGI"
179 |
(EVar
"includesNOEXEC", _
) => SOME
"IncludesNOEXEC"
180 |
(EVar
"indexes", _
) => SOME
"Indexes"
183 val autoindex_width
= fn (EVar
"autofit", _
) => SOME
"*"
184 |
(EApp ((EVar
"characters", _
), n
), _
) =>
185 Option
.map
Int.toString (Env
.int n
)
188 val autoindex_option
= fn (EApp ((EVar
"descriptionWidth", _
), w
), _
) =>
189 Option
.map (fn w
=> ("DescriptionWidth", SOME w
))
191 |
(EVar
"fancyIndexing", _
) => SOME ("FancyIndexing", NONE
)
192 |
(EVar
"foldersFirst", _
) => SOME ("FoldersFirst", NONE
)
193 |
(EVar
"htmlTable", _
) => SOME ("HTMLTable", NONE
)
194 |
(EVar
"iconsAreLinks", _
) => SOME ("IconsAreLinks", NONE
)
195 |
(EApp ((EVar
"iconHeight", _
), n
), _
) =>
196 Option
.map (fn w
=> ("IconHeight", SOME (Int.toString w
)))
198 |
(EApp ((EVar
"iconWidth", _
), n
), _
) =>
199 Option
.map (fn w
=> ("IconWidth", SOME (Int.toString w
)))
201 |
(EVar
"ignoreCase", _
) => SOME ("IgnoreCase", NONE
)
202 |
(EVar
"ignoreClient", _
) => SOME ("IgnoreClient", NONE
)
203 |
(EApp ((EVar
"nameWidth", _
), w
), _
) =>
204 Option
.map (fn w
=> ("NameWidth", SOME w
))
206 |
(EVar
"scanHtmlTitles", _
) => SOME ("ScanHTMLTitles", NONE
)
207 |
(EVar
"suppressColumnSorting", _
) => SOME ("SuppressColumnSorting", NONE
)
208 |
(EVar
"suppressDescription", _
) => SOME ("SuppressDescription", NONE
)
209 |
(EVar
"suppressHtmlPreamble", _
) => SOME ("SuppressHTMLPreamble", NONE
)
210 |
(EVar
"suppressIcon", _
) => SOME ("SuppressIcon", NONE
)
211 |
(EVar
"suppressLastModified", _
) => SOME ("SuppressLastModified", NONE
)
212 |
(EVar
"suppressRules", _
) => SOME ("SuppressRules", NONE
)
213 |
(EVar
"suppressSize", _
) => SOME ("SuppressSize", NONE
)
214 |
(EVar
"trackModified", _
) => SOME ("TrackModified", NONE
)
215 |
(EVar
"versionSort", _
) => SOME ("VersionSort", NONE
)
216 |
(EVar
"xhtml", _
) => SOME ("XHTML", NONE
)
220 val vhostsChanged
= ref
false
221 val logDeleted
= ref
false
223 val () = Slave
.registerPreHandler
224 (fn () => (vhostsChanged
:= false;
225 logDeleted
:= false))
227 fun findVhostUser fname
=
229 val inf
= TextIO.openIn fname
232 case TextIO.inputLine inf
of
235 if String.isPrefix
"# Owner: " line
then
236 case String.tokens
Char.isSpace line
of
237 [_
, _
, user
] => SOME user
243 before TextIO.closeIn inf
246 val webNodes_full
= Config
.Apache
.webNodes_all @ Config
.Apache
.webNodes_admin
248 fun isVersion1 node
=
249 List.exists (fn (n
, {version
= ConfigTypes
.APACHE_1_3
, ...}) => n
= node
250 | _
=> false) webNodes_full
252 fun imVersion1 () = isVersion1 (Slave
.hostname ())
255 List.exists (fn (n
, {auth
= ConfigTypes
.MOD_WAKLOG
, ...}) => n
= node
256 | _
=> false) webNodes_full
258 fun down () = if imVersion1 () then Config
.Apache
.down1
else Config
.Apache
.down
259 fun undown () = if imVersion1 () then Config
.Apache
.undown1
else Config
.Apache
.undown
260 fun reload () = if imVersion1 () then Config
.Apache
.reload1
else Config
.Apache
.reload
261 fun fixperms () = if imVersion1 () then Config
.Apache
.fixperms1
else Config
.Apache
.fixperms
263 fun logDir
{user
, node
, vhostId
} =
264 String.concat
[Config
.Apache
.logDirOf (isVersion1 node
) user
,
270 val () = Slave
.registerFileHandler (fn fs
=>
272 val spl
= OS
.Path
.splitDirFile (#file fs
)
274 if String.isSuffix
".vhost" (#file spl
)
275 orelse String.isSuffix
".vhost_ssl" (#file spl
) then let
276 val realVhostFile
= OS
.Path
.joinDirFile
277 {dir
= Config
.Apache
.confDir
,
280 val user
= findVhostUser (#file fs
)
281 val oldUser
= case #action fs
of
282 Slave
.Delete
false => user
283 | _
=> findVhostUser realVhostFile
285 if (oldUser
= NONE
andalso #action fs
<> Slave
.Add
)
286 orelse (user
= NONE
andalso not (Slave
.isDelete (#action fs
))) then
287 print ("Can't find user in " ^ #file fs ^
" or " ^ realVhostFile ^
"! Taking no action.\n")
290 val vhostId
= if OS
.Path
.ext (#file spl
) = SOME
"vhost_ssl" then
291 OS
.Path
.base (#file spl
) ^
".ssl"
293 OS
.Path
.base (#file spl
)
295 fun realLogDir user
=
296 logDir
{user
= valOf user
,
297 node
= Slave
.hostname (),
302 {dir
= Config
.Apache
.backupLogDirOf
303 (isVersion1 (Slave
.hostname ())),
306 vhostsChanged
:= true;
310 val ldir
= realLogDir oldUser
315 (ignore (OS
.Process
.system (down ()));
316 ignore (OS
.Process
.system (fixperms ()));
318 ignore (OS
.Process
.system (Config
.rm
321 Slave
.moveDirCreate
{from
= ldir
,
326 val rld
= realLogDir user
328 ignore (OS
.Process
.system (Config
.cp
333 if Posix
.FileSys
.access (rld
, []) then
336 Slave
.moveDirCreate
{from
= backupLogs (),
341 (ignore (OS
.Process
.system (Config
.cp
346 if user
<> oldUser
then
348 val old
= realLogDir oldUser
349 val rld
= realLogDir user
354 (ignore (OS
.Process
.system (down ()));
356 ignore (OS
.Process
.system (Config
.rm
358 ^ realLogDir oldUser
));
359 if Posix
.FileSys
.access (rld
, []) then
372 val () = Slave
.registerPostHandler
374 (if !vhostsChanged
then
375 Slave
.shellF ([if !logDeleted
then undown () else reload ()],
376 fn cl
=> "Error reloading Apache with " ^ cl
)
380 val vhostFiles
: (string * TextIO.outstream
) list ref
= ref
[]
381 fun write
' s
= app (fn (node
, file
) => TextIO.output (file
, s node
)) (!vhostFiles
)
382 fun write s
= app (fn (_
, file
) => TextIO.output (file
, s
)) (!vhostFiles
)
384 val rewriteEnabled
= ref
false
385 val localRewriteEnabled
= ref
false
386 val currentVhost
= ref
""
387 val currentVhostId
= ref
""
388 val sslEnabled
= ref
false
390 val pre
= ref (fn _
: {user
: string, nodes
: string list
, id
: string, hostname
: string} => ())
395 pre
:= (fn x
=> (old x
; f x
))
398 val post
= ref (fn () => ())
403 post
:= (fn () => (old (); f ()))
407 fun doPost () = !post ()
409 val aliaser
= ref (fn _
: string => ())
410 fun registerAliaser f
=
414 aliaser
:= (fn x
=> (old x
; f x
))
417 val () = Env
.containerV_one
"vhost"
421 val places
= Env
.env (Env
.list webPlace
) (env
, "WebPlaces")
423 val ssl
= Env
.env
ssl (env
, "SSL")
424 val user
= Env
.env Env
.string (env
, "User")
425 val group
= Env
.env Env
.string (env
, "Group")
426 val docroot
= Env
.env Env
.string (env
, "DocumentRoot")
427 val sadmin
= Env
.env Env
.string (env
, "ServerAdmin")
428 val suexec
= Env
.env Env
.bool (env
, "SuExec")
430 val fullHost
= host ^
"." ^ Domain
.currentDomain ()
431 val vhostId
= fullHost ^
(if Option
.isSome ssl
then ".ssl" else "")
432 val confFile
= fullHost ^
(if Option
.isSome ssl
then ".vhost_ssl" else ".vhost")
434 currentVhost
:= fullHost
;
435 currentVhostId
:= vhostId
;
436 sslEnabled
:= Option
.isSome ssl
;
438 rewriteEnabled
:= false;
439 localRewriteEnabled
:= false;
440 vhostFiles
:= map (fn (node
, ip
) =>
442 val file
= Domain
.domainFile
{node
= node
,
445 val ld
= logDir
{user
= user
, node
= node
, vhostId
= vhostId
}
447 TextIO.output (file
, "# Owner: ");
448 TextIO.output (file
, user
);
449 TextIO.output (file
, "\n<VirtualHost ");
450 TextIO.output (file
, ip
);
451 TextIO.output (file
, ":");
452 TextIO.output (file
, case ssl
of
455 TextIO.output (file
, ">\n");
456 TextIO.output (file
, "\tErrorLog ");
457 TextIO.output (file
, ld
);
458 TextIO.output (file
, "/error.log\n\tCustomLog ");
459 TextIO.output (file
, ld
);
460 TextIO.output (file
, "/access.log combined\n");
461 TextIO.output (file
, "\tServerName ");
462 TextIO.output (file
, fullHost
);
464 (fn dom
=> (TextIO.output (file
, "\n\tServerAlias ");
465 TextIO.output (file
, host
);
466 TextIO.output (file
, ".");
467 TextIO.output (file
, dom
)))
468 (Domain
.currentAliasDomains ());
471 if isVersion1 node
then
472 (TextIO.output (file
, "\n\tUser ");
473 TextIO.output (file
, user
);
474 TextIO.output (file
, "\n\tGroup ");
475 TextIO.output (file
, group
))
477 (TextIO.output (file
, "\n\tSuexecUserGroup ");
478 TextIO.output (file
, user
);
479 TextIO.output (file
, " ");
480 TextIO.output (file
, group
))
484 if isWaklog node
then
485 (TextIO.output (file
, "\n\tWaklogEnabled on\n\tWaklogLocationPrincipal ");
486 TextIO.output (file
, user
);
487 TextIO.output (file
, "/daemon@HCOOP.NET /etc/keytabs/user.daemon/");
488 TextIO.output (file
, user
))
492 TextIO.output (file
, "\n\tDAVLockDB /var/lock/apache2/dav/");
493 TextIO.output (file
, user
);
494 TextIO.output (file
, "/DAVLock");
499 write
"\n\tDocumentRoot ";
501 write
"\n\tServerAdmin ";
505 (write
"\n\tSSLEngine on\n\tSSLCertificateFile ";
509 !pre
{user
= user
, nodes
= map #
1 places
, id
= vhostId
, hostname
= fullHost
};
510 app (fn dom
=> !aliaser (host ^
"." ^ dom
)) (Domain
.currentAliasDomains ())
513 write
"</VirtualHost>\n";
514 app (TextIO.closeOut
o #
2) (!vhostFiles
)))
516 val inLocal
= ref
false
518 val () = Env
.container_one
"location"
519 ("prefix", Env
.string)
521 (write
"\t<Location ";
525 fn () => (write
"\t</Location>\n";
527 localRewriteEnabled
:= false))
529 val () = Env
.container_one
"directory"
530 ("directory", Env
.string)
532 (write
"\t<Directory ";
536 fn () => (write
"\t</Directory>\n";
538 localRewriteEnabled
:= false))
540 fun checkRewrite () =
542 if !localRewriteEnabled
then
545 (write
"\tRewriteEngine on\n";
546 localRewriteEnabled
:= true)
547 else if !rewriteEnabled
then
550 (write
"\tRewriteEngine on\n";
551 rewriteEnabled
:= true)
553 val () = Env
.action_three
"localProxyRewrite"
554 ("from", Env
.string, "to", Env
.string, "port", Env
.int)
555 (fn (from
, to
, port
) =>
557 write
"\tRewriteRule\t";
559 write
"\thttp://localhost:";
560 write (Int.toString port
);
565 val () = Env
.action_two
"proxyPass"
566 ("from", Env
.string, "to", Env
.string)
568 (write
"\tProxyPass\t";
574 val () = Env
.action_two
"proxyPassReverse"
575 ("from", Env
.string, "to", Env
.string)
577 (write
"\tProxyPassReverse\t";
583 val () = Env
.action_three
"rewriteRule"
584 ("from", Env
.string, "to", Env
.string, "flags", Env
.list flag
)
585 (fn (from
, to
, flags
) =>
587 write
"\tRewriteRule\t";
593 | flag
::rest
=> (write
" [";
595 app (fn flag
=> (write
",";
600 val () = Env
.action_three
"rewriteCond"
601 ("test", Env
.string, "pattern", Env
.string, "flags", Env
.list cond_flag
)
602 (fn (from
, to
, flags
) =>
604 write
"\tRewriteCond\t";
610 | flag
::rest
=> (write
" [";
612 app (fn flag
=> (write
",";
617 val () = Env
.action_one
"rewriteBase"
618 ("prefix", Env
.string)
621 write
"\tRewriteBase\t";
625 val () = Env
.action_one
"rewriteLogLevel"
629 write
"\tRewriteLog ";
631 write
"/rewrite.log\n\tRewriteLogLevel ";
632 write (Int.toString level
);
635 val () = Env
.action_two
"alias"
636 ("from", Env
.string, "to", Env
.string)
644 val () = Env
.action_two
"scriptAlias"
645 ("from", Env
.string, "to", Env
.string)
647 (write
"\tScriptAlias\t";
653 val () = Env
.action_two
"errorDocument"
654 ("code", Env
.string, "handler", Env
.string)
655 (fn (code
, handler
) =>
656 (write
"\tErrorDocument\t";
662 val () = Env
.action_one
"options"
663 ("options", Env
.list apache_option
)
667 | _
=> (write
"\tOptions";
668 app (fn opt
=> (write
" "; write opt
)) opts
;
671 val () = Env
.action_one
"set_options"
672 ("options", Env
.list apache_option
)
676 | _
=> (write
"\tOptions";
677 app (fn opt
=> (write
" +"; write opt
)) opts
;
680 val () = Env
.action_one
"unset_options"
681 ("options", Env
.list apache_option
)
685 | _
=> (write
"\tOptions";
686 app (fn opt
=> (write
" -"; write opt
)) opts
;
689 val () = Env
.action_one
"directoryIndex"
690 ("filenames", Env
.list Env
.string)
692 (write
"\tDirectoryIndex";
693 app (fn opt
=> (write
" "; write opt
)) opts
;
696 val () = Env
.action_one
"serverAliasHost"
699 (write
"\tServerAlias ";
704 val () = Env
.action_one
"serverAlias"
710 val full
= host ^
"." ^ dom
712 write
"\tServerAlias ";
717 (Domain
.currentDomains ())))
719 val () = Env
.action_none
"serverAliasDefault"
723 (write
"\tServerAlias ";
727 (Domain
.currentDomains ())))
729 val authType
= fn (EVar
"basic", _
) => SOME
"basic"
730 |
(EVar
"digest", _
) => SOME
"digest"
731 |
(EVar
"kerberos", _
) => SOME
"kerberos"
734 fun allowAuthType
"kerberos" = !sslEnabled
735 | allowAuthType _
= true
737 val () = Env
.action_one
"authType"
740 if allowAuthType ty
then
741 (write
"\tAuthType ";
746 write
"\tKrbMethodNegotiate off\n\tKrbMethodK5Passwd on\n\tKrbVerifyKDC off\n\tKrbAuthRealms HCOOP.NET\n\tKrbSaveCredentials on\n"
749 print
"WARNING: Skipped Kerberos authType because this isn't an SSL vhost.\n")
751 val () = Env
.action_one
"authName"
754 (write
"\tAuthName \"";
758 val () = Env
.action_one
"authUserFile"
761 (write
"\tAuthUserFile ";
765 val () = Env
.action_none
"requireValidUser"
766 (fn () => write
"\tRequire valid-user\n")
768 val () = Env
.action_one
"requireUser"
769 ("users", Env
.list Env
.string)
773 | _
=> (write
"\tRequire user";
774 app (fn name
=> (write
" "; write name
)) names
;
777 val () = Env
.action_one
"requireGroup"
778 ("groups", Env
.list Env
.string)
782 | _
=> (write
"\tRequire group";
783 app (fn name
=> (write
" "; write name
)) names
;
786 val () = Env
.action_none
"orderAllowDeny"
787 (fn () => write
"\tOrder allow,deny\n")
789 val () = Env
.action_none
"orderDenyAllow"
790 (fn () => write
"\tOrder deny,allow\n")
792 val () = Env
.action_none
"allowFromAll"
793 (fn () => write
"\tAllow from all\n")
795 val () = Env
.action_one
"allowFrom"
796 ("entries", Env
.list Env
.string)
800 | _
=> (write
"\tAllow from";
801 app (fn name
=> (write
" "; write name
)) names
;
804 val () = Env
.action_none
"denyFromAll"
805 (fn () => write
"\tDeny from all\n")
807 val () = Env
.action_one
"denyFrom"
808 ("entries", Env
.list Env
.string)
812 | _
=> (write
"\tDeny from";
813 app (fn name
=> (write
" "; write name
)) names
;
816 val () = Env
.action_none
"satisfyAll"
817 (fn () => write
"\tSatisfy all\n")
819 val () = Env
.action_none
"satisfyAny"
820 (fn () => write
"\tSatisfy any\n")
822 val () = Env
.action_one
"forceType"
824 (fn ty
=> (write
"\tForceType ";
828 val () = Env
.action_none
"forceTypeOff"
829 (fn () => write
"\tForceType None\n")
831 val () = Env
.action_two
"action"
832 ("what", Env
.string, "how", Env
.string)
833 (fn (what
, how
) => (write
"\tAction ";
839 val () = Env
.action_one
"addDefaultCharset"
840 ("charset", Env
.string)
841 (fn ty
=> (write
"\tAddDefaultCharset ";
845 (*val () = Env
.action_one
"davSvn"
847 (fn path
=> (write
"\tDAV svn\n\tSVNPath ";
851 val () = Env
.action_one
"authzSvnAccessFile"
853 (fn path
=> (write
"\tAuthzSVNAccessFile ";
857 val () = Env
.action_none
"davFilesystem"
858 (fn path
=> write
"\tDAV filesystem\n")
860 val () = Env
.action_two
"addDescription"
861 ("description", Env
.string, "patterns", Env
.list Env
.string)
865 | _
=> (write
"\tAddDescription \"";
866 write (String.toString desc
);
868 app (fn pat
=> (write
" "; write pat
)) pats
;
871 val () = Env
.action_one
"indexOptions"
872 ("options", Env
.list autoindex_option
)
876 | _
=> (write
"\tIndexOptions";
877 app (fn (opt
, arg
) =>
880 Option
.app (fn arg
=>
881 (write
"="; write arg
)) arg
)) opts
;
884 val () = Env
.action_one
"set_indexOptions"
885 ("options", Env
.list autoindex_option
)
889 | _
=> (write
"\tIndexOptions";
890 app (fn (opt
, arg
) =>
893 Option
.app (fn arg
=>
894 (write
"="; write arg
)) arg
)) opts
;
897 val () = Env
.action_one
"unset_indexOptions"
898 ("options", Env
.list autoindex_option
)
902 | _
=> (write
"\tIndexOptions";
908 val () = Env
.action_one
"headerName"
910 (fn name
=> (write
"\tHeaderName ";
914 val () = Env
.action_one
"readmeName"
916 (fn name
=> (write
"\tReadmeName ";
920 val () = Env
.action_two
"setEnv"
921 ("key", Env
.string, "value", Env
.string)
922 (fn (key
, value
) => (write
"\tSetEnv \"";
925 write (String.translate (fn #
"\"" => "\\\""
926 | ch
=> str ch
) value
);
929 val () = Domain
.registerResetLocal (fn () =>
930 ignore (OS
.Process
.system (Config
.rm ^
" -rf /var/domtool/vhosts/*")))
932 val () = Domain
.registerDescriber (Domain
.considerAll
933 [Domain
.Extension
{extension
= "vhost",
934 heading
= fn host
=> "Web vhost " ^ host ^
":"},
935 Domain
.Extension
{extension
= "vhost_ssl",
936 heading
= fn host
=> "SSL web vhost " ^ host ^
":"}])