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"
181 |
(EVar
"followSymLinks", _
) => SOME
"FollowSymLinks"
184 val autoindex_width
= fn (EVar
"autofit", _
) => SOME
"*"
185 |
(EApp ((EVar
"characters", _
), n
), _
) =>
186 Option
.map
Int.toString (Env
.int n
)
189 val autoindex_option
= fn (EApp ((EVar
"descriptionWidth", _
), w
), _
) =>
190 Option
.map (fn w
=> ("DescriptionWidth", SOME w
))
192 |
(EVar
"fancyIndexing", _
) => SOME ("FancyIndexing", NONE
)
193 |
(EVar
"foldersFirst", _
) => SOME ("FoldersFirst", NONE
)
194 |
(EVar
"htmlTable", _
) => SOME ("HTMLTable", NONE
)
195 |
(EVar
"iconsAreLinks", _
) => SOME ("IconsAreLinks", NONE
)
196 |
(EApp ((EVar
"iconHeight", _
), n
), _
) =>
197 Option
.map (fn w
=> ("IconHeight", SOME (Int.toString w
)))
199 |
(EApp ((EVar
"iconWidth", _
), n
), _
) =>
200 Option
.map (fn w
=> ("IconWidth", SOME (Int.toString w
)))
202 |
(EVar
"ignoreCase", _
) => SOME ("IgnoreCase", NONE
)
203 |
(EVar
"ignoreClient", _
) => SOME ("IgnoreClient", NONE
)
204 |
(EApp ((EVar
"nameWidth", _
), w
), _
) =>
205 Option
.map (fn w
=> ("NameWidth", SOME w
))
207 |
(EVar
"scanHtmlTitles", _
) => SOME ("ScanHTMLTitles", NONE
)
208 |
(EVar
"suppressColumnSorting", _
) => SOME ("SuppressColumnSorting", NONE
)
209 |
(EVar
"suppressDescription", _
) => SOME ("SuppressDescription", NONE
)
210 |
(EVar
"suppressHtmlPreamble", _
) => SOME ("SuppressHTMLPreamble", NONE
)
211 |
(EVar
"suppressIcon", _
) => SOME ("SuppressIcon", NONE
)
212 |
(EVar
"suppressLastModified", _
) => SOME ("SuppressLastModified", NONE
)
213 |
(EVar
"suppressRules", _
) => SOME ("SuppressRules", NONE
)
214 |
(EVar
"suppressSize", _
) => SOME ("SuppressSize", NONE
)
215 |
(EVar
"trackModified", _
) => SOME ("TrackModified", NONE
)
216 |
(EVar
"versionSort", _
) => SOME ("VersionSort", NONE
)
217 |
(EVar
"xhtml", _
) => SOME ("XHTML", NONE
)
221 val vhostsChanged
= ref
false
222 val logDeleted
= ref
false
224 val () = Slave
.registerPreHandler
225 (fn () => (vhostsChanged
:= false;
226 logDeleted
:= false))
228 fun findVhostUser fname
=
230 val inf
= TextIO.openIn fname
233 case TextIO.inputLine inf
of
236 if String.isPrefix
"# Owner: " line
then
237 case String.tokens
Char.isSpace line
of
238 [_
, _
, user
] => SOME user
244 before TextIO.closeIn inf
247 val webNodes_full
= Config
.Apache
.webNodes_all @ Config
.Apache
.webNodes_admin
249 fun isVersion1 node
=
250 List.exists (fn (n
, {version
= ConfigTypes
.APACHE_1_3
, ...}) => n
= node
251 | _
=> false) webNodes_full
253 fun imVersion1 () = isVersion1 (Slave
.hostname ())
256 List.exists (fn (n
, {auth
= ConfigTypes
.MOD_WAKLOG
, ...}) => n
= node
257 | _
=> false) webNodes_full
259 fun down () = if imVersion1 () then Config
.Apache
.down1
else Config
.Apache
.down
260 fun undown () = if imVersion1 () then Config
.Apache
.undown1
else Config
.Apache
.undown
261 fun reload () = if imVersion1 () then Config
.Apache
.reload1
else Config
.Apache
.reload
262 fun fixperms () = if imVersion1 () then Config
.Apache
.fixperms1
else Config
.Apache
.fixperms
264 fun logDir
{user
, node
, vhostId
} =
265 String.concat
[Config
.Apache
.logDirOf (isVersion1 node
) user
,
271 fun realLogDir
{user
, node
, vhostId
} =
272 String.concat
[Config
.Apache
.realLogDirOf user
,
278 val () = Slave
.registerFileHandler (fn fs
=>
280 val spl
= OS
.Path
.splitDirFile (#file fs
)
282 if String.isSuffix
".vhost" (#file spl
)
283 orelse String.isSuffix
".vhost_ssl" (#file spl
) then let
284 val realVhostFile
= OS
.Path
.joinDirFile
285 {dir
= Config
.Apache
.confDir
,
288 val user
= findVhostUser (#file fs
)
289 val oldUser
= case #action fs
of
290 Slave
.Delete
false => user
291 | _
=> findVhostUser realVhostFile
293 if (oldUser
= NONE
andalso #action fs
<> Slave
.Add
)
294 orelse (user
= NONE
andalso not (Slave
.isDelete (#action fs
))) then
295 print ("Can't find user in " ^ #file fs ^
" or " ^ realVhostFile ^
"! Taking no action.\n")
298 val vhostId
= if OS
.Path
.ext (#file spl
) = SOME
"vhost_ssl" then
299 OS
.Path
.base (#file spl
) ^
".ssl"
301 OS
.Path
.base (#file spl
)
303 fun realLogDir user
=
304 logDir
{user
= valOf user
,
305 node
= Slave
.hostname (),
310 {dir
= Config
.Apache
.backupLogDirOf
311 (isVersion1 (Slave
.hostname ())),
314 vhostsChanged
:= true;
318 val ldir
= realLogDir oldUser
323 (ignore (OS
.Process
.system (down ()));
324 ignore (OS
.Process
.system (fixperms ()));
326 ignore (OS
.Process
.system (Config
.rm
329 Slave
.moveDirCreate
{from
= ldir
,
334 val rld
= realLogDir user
336 ignore (OS
.Process
.system (Config
.cp
341 if Posix
.FileSys
.access (rld
, []) then
344 Slave
.moveDirCreate
{from
= backupLogs (),
349 (ignore (OS
.Process
.system (Config
.cp
354 if user
<> oldUser
then
356 val old
= realLogDir oldUser
357 val rld
= realLogDir user
362 (ignore (OS
.Process
.system (down ()));
364 ignore (OS
.Process
.system (Config
.rm
366 ^ realLogDir oldUser
));
367 if Posix
.FileSys
.access (rld
, []) then
380 val () = Slave
.registerPostHandler
382 (if !vhostsChanged
then
383 Slave
.shellF ([if !logDeleted
then undown () else reload ()],
384 fn cl
=> "Error reloading Apache with " ^ cl
)
388 val vhostFiles
: (string * TextIO.outstream
) list ref
= ref
[]
389 fun write
' s
= app (fn (node
, file
) => TextIO.output (file
, s node
)) (!vhostFiles
)
390 fun write s
= app (fn (_
, file
) => TextIO.output (file
, s
)) (!vhostFiles
)
392 val rewriteEnabled
= ref
false
393 val localRewriteEnabled
= ref
false
394 val currentVhost
= ref
""
395 val currentVhostId
= ref
""
396 val sslEnabled
= ref
false
398 val pre
= ref (fn _
: {user
: string, nodes
: string list
, id
: string, hostname
: string} => ())
403 pre
:= (fn x
=> (old x
; f x
))
406 val post
= ref (fn () => ())
411 post
:= (fn () => (old (); f ()))
415 fun doPost () = !post ()
417 val aliaser
= ref (fn _
: string => ())
418 fun registerAliaser f
=
422 aliaser
:= (fn x
=> (old x
; f x
))
425 val () = Env
.containerV_one
"vhost"
429 val places
= Env
.env (Env
.list webPlace
) (env
, "WebPlaces")
431 val ssl
= Env
.env
ssl (env
, "SSL")
432 val user
= Env
.env Env
.string (env
, "User")
433 val group
= Env
.env Env
.string (env
, "Group")
434 val docroot
= Env
.env Env
.string (env
, "DocumentRoot")
435 val sadmin
= Env
.env Env
.string (env
, "ServerAdmin")
436 val suexec
= Env
.env Env
.bool (env
, "SuExec")
438 val fullHost
= host ^
"." ^ Domain
.currentDomain ()
439 val vhostId
= fullHost ^
(if Option
.isSome ssl
then ".ssl" else "")
440 val confFile
= fullHost ^
(if Option
.isSome ssl
then ".vhost_ssl" else ".vhost")
442 currentVhost
:= fullHost
;
443 currentVhostId
:= vhostId
;
444 sslEnabled
:= Option
.isSome ssl
;
446 rewriteEnabled
:= false;
447 localRewriteEnabled
:= false;
448 vhostFiles
:= map (fn (node
, ip
) =>
450 val file
= Domain
.domainFile
{node
= node
,
453 val ld
= logDir
{user
= user
, node
= node
, vhostId
= vhostId
}
455 TextIO.output (file
, "# Owner: ");
456 TextIO.output (file
, user
);
457 TextIO.output (file
, "\n<VirtualHost ");
458 TextIO.output (file
, ip
);
459 TextIO.output (file
, ":");
460 TextIO.output (file
, case ssl
of
463 TextIO.output (file
, ">\n");
464 TextIO.output (file
, "\tErrorLog ");
465 TextIO.output (file
, ld
);
466 TextIO.output (file
, "/error.log\n\tCustomLog ");
467 TextIO.output (file
, ld
);
468 TextIO.output (file
, "/access.log combined\n");
469 TextIO.output (file
, "\tServerName ");
470 TextIO.output (file
, fullHost
);
472 (fn dom
=> (TextIO.output (file
, "\n\tServerAlias ");
473 TextIO.output (file
, host
);
474 TextIO.output (file
, ".");
475 TextIO.output (file
, dom
)))
476 (Domain
.currentAliasDomains ());
479 if isVersion1 node
then
480 (TextIO.output (file
, "\n\tUser ");
481 TextIO.output (file
, user
);
482 TextIO.output (file
, "\n\tGroup ");
483 TextIO.output (file
, group
))
485 (TextIO.output (file
, "\n\tSuexecUserGroup ");
486 TextIO.output (file
, user
);
487 TextIO.output (file
, " ");
488 TextIO.output (file
, group
))
492 if isWaklog node
then
493 (TextIO.output (file
, "\n\tWaklogEnabled on\n\tWaklogLocationPrincipal ");
494 TextIO.output (file
, user
);
495 TextIO.output (file
, "/daemon@HCOOP.NET /etc/keytabs/user.daemon/");
496 TextIO.output (file
, user
))
500 TextIO.output (file
, "\n\tDAVLockDB /var/lock/apache2/dav/");
501 TextIO.output (file
, user
);
502 TextIO.output (file
, "/DAVLock");
507 write
"\n\tDocumentRoot ";
509 write
"\n\tServerAdmin ";
513 (write
"\n\tSSLEngine on\n\tSSLCertificateFile ";
517 !pre
{user
= user
, nodes
= map #
1 places
, id
= vhostId
, hostname
= fullHost
};
518 app (fn dom
=> !aliaser (host ^
"." ^ dom
)) (Domain
.currentAliasDomains ())
521 write
"</VirtualHost>\n";
522 app (TextIO.closeOut
o #
2) (!vhostFiles
)))
524 val inLocal
= ref
false
526 val () = Env
.container_one
"location"
527 ("prefix", Env
.string)
529 (write
"\t<Location ";
533 fn () => (write
"\t</Location>\n";
535 localRewriteEnabled
:= false))
537 val () = Env
.container_one
"directory"
538 ("directory", Env
.string)
540 (write
"\t<Directory ";
544 fn () => (write
"\t</Directory>\n";
546 localRewriteEnabled
:= false))
548 fun checkRewrite () =
550 if !localRewriteEnabled
then
553 (write
"\tRewriteEngine on\n";
554 localRewriteEnabled
:= true)
555 else if !rewriteEnabled
then
558 (write
"\tRewriteEngine on\n";
559 rewriteEnabled
:= true)
561 val () = Env
.action_three
"localProxyRewrite"
562 ("from", Env
.string, "to", Env
.string, "port", Env
.int)
563 (fn (from
, to
, port
) =>
565 write
"\tRewriteRule\t";
567 write
"\thttp://localhost:";
568 write (Int.toString port
);
573 val () = Env
.action_two
"proxyPass"
574 ("from", Env
.string, "to", Env
.string)
576 (write
"\tProxyPass\t";
582 val () = Env
.action_two
"proxyPassReverse"
583 ("from", Env
.string, "to", Env
.string)
585 (write
"\tProxyPassReverse\t";
591 val () = Env
.action_three
"rewriteRule"
592 ("from", Env
.string, "to", Env
.string, "flags", Env
.list flag
)
593 (fn (from
, to
, flags
) =>
595 write
"\tRewriteRule\t";
601 | flag
::rest
=> (write
" [";
603 app (fn flag
=> (write
",";
608 val () = Env
.action_three
"rewriteCond"
609 ("test", Env
.string, "pattern", Env
.string, "flags", Env
.list cond_flag
)
610 (fn (from
, to
, flags
) =>
612 write
"\tRewriteCond\t";
618 | flag
::rest
=> (write
" [";
620 app (fn flag
=> (write
",";
625 val () = Env
.action_one
"rewriteBase"
626 ("prefix", Env
.string)
629 write
"\tRewriteBase\t";
633 val () = Env
.action_one
"rewriteLogLevel"
637 write
"\tRewriteLog ";
639 write
"/rewrite.log\n\tRewriteLogLevel ";
640 write (Int.toString level
);
643 val () = Env
.action_two
"alias"
644 ("from", Env
.string, "to", Env
.string)
652 val () = Env
.action_two
"scriptAlias"
653 ("from", Env
.string, "to", Env
.string)
655 (write
"\tScriptAlias\t";
661 val () = Env
.action_two
"errorDocument"
662 ("code", Env
.string, "handler", Env
.string)
663 (fn (code
, handler
) =>
665 val hasSpaces
= CharVector
.exists
Char.isSpace handler
673 write
"\tErrorDocument\t";
682 val () = Env
.action_one
"options"
683 ("options", Env
.list apache_option
)
687 | _
=> (write
"\tOptions";
688 app (fn opt
=> (write
" "; write opt
)) opts
;
691 val () = Env
.action_one
"set_options"
692 ("options", Env
.list apache_option
)
696 | _
=> (write
"\tOptions";
697 app (fn opt
=> (write
" +"; write opt
)) opts
;
700 val () = Env
.action_one
"unset_options"
701 ("options", Env
.list apache_option
)
705 | _
=> (write
"\tOptions";
706 app (fn opt
=> (write
" -"; write opt
)) opts
;
709 val () = Env
.action_one
"directoryIndex"
710 ("filenames", Env
.list Env
.string)
712 (write
"\tDirectoryIndex";
713 app (fn opt
=> (write
" "; write opt
)) opts
;
716 val () = Env
.action_one
"serverAliasHost"
719 (write
"\tServerAlias ";
724 val () = Env
.action_one
"serverAlias"
730 val full
= host ^
"." ^ dom
732 write
"\tServerAlias ";
737 (Domain
.currentDomains ())))
739 val () = Env
.action_none
"serverAliasDefault"
743 (write
"\tServerAlias ";
747 (Domain
.currentDomains ())))
749 val authType
= fn (EVar
"basic", _
) => SOME
"basic"
750 |
(EVar
"digest", _
) => SOME
"digest"
751 |
(EVar
"kerberos", _
) => SOME
"kerberos"
754 fun allowAuthType
"kerberos" = !sslEnabled
755 | allowAuthType _
= true
757 val () = Env
.action_one
"authType"
760 if allowAuthType ty
then
761 (write
"\tAuthType ";
766 write
"\tKrbMethodNegotiate off\n\tKrbMethodK5Passwd on\n\tKrbVerifyKDC off\n\tKrbAuthRealms HCOOP.NET\n\tKrbSaveCredentials on\n"
769 print
"WARNING: Skipped Kerberos authType because this isn't an SSL vhost.\n")
771 val () = Env
.action_one
"authName"
774 (write
"\tAuthName \"";
778 val () = Env
.action_one
"authUserFile"
781 (write
"\tAuthUserFile ";
785 val () = Env
.action_none
"requireValidUser"
786 (fn () => write
"\tRequire valid-user\n")
788 val () = Env
.action_one
"requireUser"
789 ("users", Env
.list Env
.string)
793 | _
=> (write
"\tRequire user";
794 app (fn name
=> (write
" "; write name
)) names
;
797 val () = Env
.action_one
"requireGroup"
798 ("groups", Env
.list Env
.string)
802 | _
=> (write
"\tRequire group";
803 app (fn name
=> (write
" "; write name
)) names
;
806 val () = Env
.action_none
"orderAllowDeny"
807 (fn () => write
"\tOrder allow,deny\n")
809 val () = Env
.action_none
"orderDenyAllow"
810 (fn () => write
"\tOrder deny,allow\n")
812 val () = Env
.action_none
"allowFromAll"
813 (fn () => write
"\tAllow from all\n")
815 val () = Env
.action_one
"allowFrom"
816 ("entries", Env
.list Env
.string)
820 | _
=> (write
"\tAllow from";
821 app (fn name
=> (write
" "; write name
)) names
;
824 val () = Env
.action_none
"denyFromAll"
825 (fn () => write
"\tDeny from all\n")
827 val () = Env
.action_one
"denyFrom"
828 ("entries", Env
.list Env
.string)
832 | _
=> (write
"\tDeny from";
833 app (fn name
=> (write
" "; write name
)) names
;
836 val () = Env
.action_none
"satisfyAll"
837 (fn () => write
"\tSatisfy all\n")
839 val () = Env
.action_none
"satisfyAny"
840 (fn () => write
"\tSatisfy any\n")
842 val () = Env
.action_one
"forceType"
844 (fn ty
=> (write
"\tForceType ";
848 val () = Env
.action_none
"forceTypeOff"
849 (fn () => write
"\tForceType None\n")
851 val () = Env
.action_two
"action"
852 ("what", Env
.string, "how", Env
.string)
853 (fn (what
, how
) => (write
"\tAction ";
859 val () = Env
.action_one
"addDefaultCharset"
860 ("charset", Env
.string)
861 (fn ty
=> (write
"\tAddDefaultCharset ";
865 (*val () = Env
.action_one
"davSvn"
867 (fn path
=> (write
"\tDAV svn\n\tSVNPath ";
871 val () = Env
.action_one
"authzSvnAccessFile"
873 (fn path
=> (write
"\tAuthzSVNAccessFile ";
877 val () = Env
.action_none
"davFilesystem"
878 (fn path
=> write
"\tDAV filesystem\n")
880 val () = Env
.action_two
"addDescription"
881 ("description", Env
.string, "patterns", Env
.list Env
.string)
885 | _
=> (write
"\tAddDescription \"";
886 write (String.toString desc
);
888 app (fn pat
=> (write
" "; write pat
)) pats
;
891 val () = Env
.action_one
"indexOptions"
892 ("options", Env
.list autoindex_option
)
896 | _
=> (write
"\tIndexOptions";
897 app (fn (opt
, arg
) =>
900 Option
.app (fn arg
=>
901 (write
"="; write arg
)) arg
)) opts
;
904 val () = Env
.action_one
"set_indexOptions"
905 ("options", Env
.list autoindex_option
)
909 | _
=> (write
"\tIndexOptions";
910 app (fn (opt
, arg
) =>
913 Option
.app (fn arg
=>
914 (write
"="; write arg
)) arg
)) opts
;
917 val () = Env
.action_one
"unset_indexOptions"
918 ("options", Env
.list autoindex_option
)
922 | _
=> (write
"\tIndexOptions";
928 val () = Env
.action_one
"headerName"
930 (fn name
=> (write
"\tHeaderName ";
934 val () = Env
.action_one
"readmeName"
936 (fn name
=> (write
"\tReadmeName ";
940 val () = Env
.action_two
"setEnv"
941 ("key", Env
.string, "value", Env
.string)
942 (fn (key
, value
) => (write
"\tSetEnv \"";
945 write (String.translate (fn #
"\"" => "\\\""
946 | ch
=> str ch
) value
);
949 val () = Domain
.registerResetLocal (fn () =>
950 ignore (OS
.Process
.system (Config
.rm ^
" -rf /var/domtool/vhosts/*")))
952 val () = Domain
.registerDescriber (Domain
.considerAll
953 [Domain
.Extension
{extension
= "vhost",
954 heading
= fn host
=> "Web vhost " ^ host ^
":"},
955 Domain
.Extension
{extension
= "vhost_ssl",
956 heading
= fn host
=> "SSL web vhost " ^ host ^
":"}])