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")
89 val _
= Env
.type_one
"regexp"
94 size s
> 0 andalso size s
< 1000 andalso CharVector
.all
95 (fn ch
=> Char.isAlphaNum ch
101 val _
= Env
.type_one
"location"
105 fun validCert s
= Acl
.query
{user
= Domain
.getUser (),
109 val _
= Env
.type_one
"ssl_cert_path"
113 fun ssl e
= case e
of
114 (EVar
"no_ssl", _
) => SOME NONE
115 |
(EApp ((EVar
"use_cert", _
), s
), _
) => Option
.map
SOME (Env
.string s
)
118 fun validExtension s
=
121 andalso CharVector
.all (fn ch
=> Char.isAlphaNum ch
orelse ch
= #
"_") s
123 val _
= Env
.type_one
"file_extension"
127 val defaults
= [("WebPlaces",
128 (TList (TBase
"web_place", dl
), dl
),
129 (fn () => (EList (map webPlaceDefault Config
.Apache
.webNodes_default
), dl
))),
132 (fn () => (EVar
"no_ssl", dl
))),
134 (TBase
"your_user", dl
),
135 (fn () => (EString (Domain
.getUser ()), dl
))),
137 (TBase
"your_group", dl
),
138 (fn () => (EString
"nogroup", dl
))),
140 (TBase
"your_path", dl
),
141 (fn () => (EString (Domain
.homedir () ^
"/" ^ Config
.Apache
.public_html
), dl
))),
144 (fn () => (EString (Domain
.getUser () ^
"@" ^ Config
.defaultDomain
), dl
))),
146 (TBase
"suexec_flag", dl
),
147 (fn () => (EVar
"true", dl
)))]
149 val () = app Defaults
.registerDefault defaults
151 val redirect_code
= fn (EVar
"temp", _
) => SOME
"temp"
152 |
(EVar
"permanent", _
) => SOME
"permanent"
153 |
(EVar
"seeother", _
) => SOME
"seeother"
154 |
(EVar
"redir300", _
) => SOME
"300"
155 |
(EVar
"redir301", _
) => SOME
"301"
156 |
(EVar
"redir302", _
) => SOME
"302"
157 |
(EVar
"redir303", _
) => SOME
"303"
158 |
(EVar
"redir304", _
) => SOME
"304"
159 |
(EVar
"redir305", _
) => SOME
"305"
160 |
(EVar
"redir307", _
) => SOME
"307"
163 val flag
= fn (EVar
"redirect", _
) => SOME
"R"
164 |
(EVar
"forbidden", _
) => SOME
"F"
165 |
(EVar
"gone", _
) => SOME
"G"
166 |
(EVar
"last", _
) => SOME
"L"
167 |
(EVar
"chain", _
) => SOME
"C"
168 |
(EVar
"nosubreq", _
) => SOME
"NS"
169 |
(EVar
"nocase", _
) => SOME
"NC"
170 |
(EVar
"qsappend", _
) => SOME
"QSA"
171 |
(EVar
"noescape", _
) => SOME
"NE"
172 |
(EVar
"passthrough", _
) => SOME
"PT"
173 |
(EApp ((EVar
"mimeType", _
), e
), _
) =>
174 Option
.map (fn s
=> "T=" ^ s
) (Env
.string e
)
175 |
(EApp ((EVar
"redirectWith", _
), e
), _
) =>
176 Option
.map (fn s
=> "R=" ^ s
) (redirect_code e
)
177 |
(EApp ((EVar
"skip", _
), e
), _
) =>
178 Option
.map (fn n
=> "S=" ^
Int.toString n
) (Env
.int e
)
179 |
(EApp ((EApp ((EVar
"env", _
), e1
), _
), e2
), _
) =>
180 (case Env
.string e1
of
182 | SOME s1
=> Option
.map (fn s2
=> "E=" ^ s1 ^
":" ^ s2
)
187 val cond_flag
= fn (EVar
"cond_nocase", _
) => SOME
"NC"
188 |
(EVar
"ornext", _
) => SOME
"OR"
191 val apache_option
= fn (EVar
"execCGI", _
) => SOME
"ExecCGI"
192 |
(EVar
"includesNOEXEC", _
) => SOME
"IncludesNOEXEC"
193 |
(EVar
"indexes", _
) => SOME
"Indexes"
194 |
(EVar
"followSymLinks", _
) => SOME
"FollowSymLinks"
197 val autoindex_width
= fn (EVar
"autofit", _
) => SOME
"*"
198 |
(EApp ((EVar
"characters", _
), n
), _
) =>
199 Option
.map
Int.toString (Env
.int n
)
202 val autoindex_option
= fn (EApp ((EVar
"descriptionWidth", _
), w
), _
) =>
203 Option
.map (fn w
=> ("DescriptionWidth", SOME w
))
205 |
(EVar
"fancyIndexing", _
) => SOME ("FancyIndexing", NONE
)
206 |
(EVar
"foldersFirst", _
) => SOME ("FoldersFirst", NONE
)
207 |
(EVar
"htmlTable", _
) => SOME ("HTMLTable", NONE
)
208 |
(EVar
"iconsAreLinks", _
) => SOME ("IconsAreLinks", NONE
)
209 |
(EApp ((EVar
"iconHeight", _
), n
), _
) =>
210 Option
.map (fn w
=> ("IconHeight", SOME (Int.toString w
)))
212 |
(EApp ((EVar
"iconWidth", _
), n
), _
) =>
213 Option
.map (fn w
=> ("IconWidth", SOME (Int.toString w
)))
215 |
(EVar
"ignoreCase", _
) => SOME ("IgnoreCase", NONE
)
216 |
(EVar
"ignoreClient", _
) => SOME ("IgnoreClient", NONE
)
217 |
(EApp ((EVar
"nameWidth", _
), w
), _
) =>
218 Option
.map (fn w
=> ("NameWidth", SOME w
))
220 |
(EVar
"scanHtmlTitles", _
) => SOME ("ScanHTMLTitles", NONE
)
221 |
(EVar
"suppressColumnSorting", _
) => SOME ("SuppressColumnSorting", NONE
)
222 |
(EVar
"suppressDescription", _
) => SOME ("SuppressDescription", NONE
)
223 |
(EVar
"suppressHtmlPreamble", _
) => SOME ("SuppressHTMLPreamble", NONE
)
224 |
(EVar
"suppressIcon", _
) => SOME ("SuppressIcon", NONE
)
225 |
(EVar
"suppressLastModified", _
) => SOME ("SuppressLastModified", NONE
)
226 |
(EVar
"suppressRules", _
) => SOME ("SuppressRules", NONE
)
227 |
(EVar
"suppressSize", _
) => SOME ("SuppressSize", NONE
)
228 |
(EVar
"trackModified", _
) => SOME ("TrackModified", NONE
)
229 |
(EVar
"versionSort", _
) => SOME ("VersionSort", NONE
)
230 |
(EVar
"xhtml", _
) => SOME ("XHTML", NONE
)
234 val vhostsChanged
= ref
false
235 val logDeleted
= ref
false
237 val () = Slave
.registerPreHandler
238 (fn () => (vhostsChanged
:= false;
239 logDeleted
:= false))
241 fun findVhostUser fname
=
243 val inf
= TextIO.openIn fname
246 case TextIO.inputLine inf
of
249 if String.isPrefix
"# Owner: " line
then
250 case String.tokens
Char.isSpace line
of
251 [_
, _
, user
] => SOME user
257 before TextIO.closeIn inf
260 val webNodes_full
= Config
.Apache
.webNodes_all @ Config
.Apache
.webNodes_admin
262 fun isVersion1 node
=
263 List.exists (fn (n
, {version
= ConfigTypes
.APACHE_1_3
, ...}) => n
= node
264 | _
=> false) webNodes_full
266 fun imVersion1 () = isVersion1 (Slave
.hostname ())
269 List.exists (fn (n
, {auth
= ConfigTypes
.MOD_WAKLOG
, ...}) => n
= node
270 | _
=> false) webNodes_full
272 fun down () = if imVersion1 () then Config
.Apache
.down1
else Config
.Apache
.down
273 fun undown () = if imVersion1 () then Config
.Apache
.undown1
else Config
.Apache
.undown
274 fun reload () = if imVersion1 () then Config
.Apache
.reload1
else Config
.Apache
.reload
275 fun fixperms () = if imVersion1 () then Config
.Apache
.fixperms1
else Config
.Apache
.fixperms
277 fun logDir
{user
, node
, vhostId
} =
278 String.concat
[Config
.Apache
.logDirOf (isVersion1 node
) user
,
284 fun realLogDir
{user
, node
, vhostId
} =
285 String.concat
[Config
.Apache
.realLogDirOf user
,
291 val () = Slave
.registerFileHandler (fn fs
=>
293 val spl
= OS
.Path
.splitDirFile (#file fs
)
295 if String.isSuffix
".vhost" (#file spl
)
296 orelse String.isSuffix
".vhost_ssl" (#file spl
) then let
297 val realVhostFile
= OS
.Path
.joinDirFile
298 {dir
= Config
.Apache
.confDir
,
301 val user
= findVhostUser (#file fs
)
302 val oldUser
= case #action fs
of
303 Slave
.Delete
false => user
304 | _
=> findVhostUser realVhostFile
306 if (oldUser
= NONE
andalso #action fs
<> Slave
.Add
)
307 orelse (user
= NONE
andalso not (Slave
.isDelete (#action fs
))) then
308 print ("Can't find user in " ^ #file fs ^
" or " ^ realVhostFile ^
"! Taking no action.\n")
311 val vhostId
= if OS
.Path
.ext (#file spl
) = SOME
"vhost_ssl" then
312 OS
.Path
.base (#file spl
) ^
".ssl"
314 OS
.Path
.base (#file spl
)
316 fun realLogDir user
=
317 logDir
{user
= valOf user
,
318 node
= Slave
.hostname (),
323 {dir
= Config
.Apache
.backupLogDirOf
324 (isVersion1 (Slave
.hostname ())),
327 vhostsChanged
:= true;
331 val ldir
= realLogDir oldUser
336 (ignore (OS
.Process
.system (down ()));
337 ignore (OS
.Process
.system (fixperms ()));
339 ignore (OS
.Process
.system (Config
.rm
342 Slave
.moveDirCreate
{from
= ldir
,
347 val rld
= realLogDir user
349 ignore (OS
.Process
.system (Config
.cp
354 if Posix
.FileSys
.access (rld
, []) then
357 Slave
.moveDirCreate
{from
= backupLogs (),
362 (ignore (OS
.Process
.system (Config
.cp
367 if user
<> oldUser
then
369 val old
= realLogDir oldUser
370 val rld
= realLogDir user
375 (ignore (OS
.Process
.system (down ()));
377 ignore (OS
.Process
.system (Config
.rm
379 ^ realLogDir oldUser
));
380 if Posix
.FileSys
.access (rld
, []) then
393 val () = Slave
.registerPostHandler
395 (if !vhostsChanged
then
396 Slave
.shellF ([if !logDeleted
then undown () else reload ()],
397 fn cl
=> "Error reloading Apache with " ^ cl
)
401 val vhostFiles
: (string * TextIO.outstream
) list ref
= ref
[]
402 fun write
' s
= app (fn (node
, file
) => TextIO.output (file
, s node
)) (!vhostFiles
)
403 fun write s
= app (fn (_
, file
) => TextIO.output (file
, s
)) (!vhostFiles
)
405 val rewriteEnabled
= ref
false
406 val localRewriteEnabled
= ref
false
407 val currentVhost
= ref
""
408 val currentVhostId
= ref
""
409 val sslEnabled
= ref
false
411 val pre
= ref (fn _
: {user
: string, nodes
: string list
, id
: string, hostname
: string} => ())
416 pre
:= (fn x
=> (old x
; f x
))
419 val post
= ref (fn () => ())
424 post
:= (fn () => (old (); f ()))
428 fun doPost () = !post ()
430 val aliaser
= ref (fn _
: string => ())
431 fun registerAliaser f
=
435 aliaser
:= (fn x
=> (old x
; f x
))
438 fun vhostPost () = (!post ();
439 write
"</VirtualHost>\n";
440 app (TextIO.closeOut
o #
2) (!vhostFiles
))
442 fun vhostBody (env
, makeFullHost
) =
444 val places
= Env
.env (Env
.list webPlace
) (env
, "WebPlaces")
446 val ssl
= Env
.env
ssl (env
, "SSL")
447 val user
= Env
.env Env
.string (env
, "User")
448 val group
= Env
.env Env
.string (env
, "Group")
449 val docroot
= Env
.env Env
.string (env
, "DocumentRoot")
450 val sadmin
= Env
.env Env
.string (env
, "ServerAdmin")
451 val suexec
= Env
.env Env
.bool (env
, "SuExec")
453 val fullHost
= makeFullHost (Domain
.currentDomain ())
454 val vhostId
= fullHost ^
(if Option
.isSome ssl
then ".ssl" else "")
455 val confFile
= fullHost ^
(if Option
.isSome ssl
then ".vhost_ssl" else ".vhost")
457 currentVhost
:= fullHost
;
458 currentVhostId
:= vhostId
;
459 sslEnabled
:= Option
.isSome ssl
;
461 rewriteEnabled
:= false;
462 localRewriteEnabled
:= false;
463 vhostFiles
:= map (fn (node
, ip
) =>
465 val file
= Domain
.domainFile
{node
= node
,
468 val ld
= logDir
{user
= user
, node
= node
, vhostId
= vhostId
}
470 TextIO.output (file
, "# Owner: ");
471 TextIO.output (file
, user
);
472 TextIO.output (file
, "\n<VirtualHost ");
473 TextIO.output (file
, ip
);
474 TextIO.output (file
, ":");
475 TextIO.output (file
, case ssl
of
478 TextIO.output (file
, ">\n");
479 TextIO.output (file
, "\tErrorLog ");
480 TextIO.output (file
, ld
);
481 TextIO.output (file
, "/error.log\n\tCustomLog ");
482 TextIO.output (file
, ld
);
483 TextIO.output (file
, "/access.log combined\n");
484 TextIO.output (file
, "\tServerName ");
485 TextIO.output (file
, fullHost
);
487 (fn dom
=> (TextIO.output (file
, "\n\tServerAlias ");
488 TextIO.output (file
, makeFullHost dom
)))
489 (Domain
.currentAliasDomains ());
492 if isVersion1 node
then
493 (TextIO.output (file
, "\n\tUser ");
494 TextIO.output (file
, user
);
495 TextIO.output (file
, "\n\tGroup ");
496 TextIO.output (file
, group
))
498 (TextIO.output (file
, "\n\tSuexecUserGroup ");
499 TextIO.output (file
, user
);
500 TextIO.output (file
, " ");
501 TextIO.output (file
, group
))
505 if isWaklog node
then
506 (TextIO.output (file
, "\n\tWaklogEnabled on\n\tWaklogLocationPrincipal ");
507 TextIO.output (file
, user
);
508 TextIO.output (file
, "/daemon@HCOOP.NET /etc/keytabs/user.daemon/");
509 TextIO.output (file
, user
))
513 TextIO.output (file
, "\n\tDAVLockDB /var/lock/apache2/dav/");
514 TextIO.output (file
, user
);
515 TextIO.output (file
, "/DAVLock");
520 write
"\n\tDocumentRoot ";
522 write
"\n\tServerAdmin ";
526 (write
"\n\tSSLEngine on\n\tSSLCertificateFile ";
530 !pre
{user
= user
, nodes
= map #
1 places
, id
= vhostId
, hostname
= fullHost
};
531 app (fn dom
=> !aliaser (makeFullHost dom
)) (Domain
.currentAliasDomains ())
534 val () = Env
.containerV_one
"vhost"
536 (fn (env
, host
) => vhostBody (env
, fn dom
=> host ^
"." ^ dom
),
539 val () = Env
.containerV_none
"vhostDefault"
540 (fn env
=> vhostBody (env
, fn dom
=> dom
),
543 val inLocal
= ref
false
545 val () = Env
.container_one
"location"
546 ("prefix", Env
.string)
548 (write
"\t<Location ";
552 fn () => (write
"\t</Location>\n";
554 localRewriteEnabled
:= false))
556 val () = Env
.container_one
"directory"
557 ("directory", Env
.string)
559 (write
"\t<Directory ";
563 fn () => (write
"\t</Directory>\n";
565 localRewriteEnabled
:= false))
567 fun checkRewrite () =
569 if !localRewriteEnabled
then
572 (write
"\tRewriteEngine on\n";
573 localRewriteEnabled
:= true)
574 else if !rewriteEnabled
then
577 (write
"\tRewriteEngine on\n";
578 rewriteEnabled
:= true)
580 val () = Env
.action_three
"localProxyRewrite"
581 ("from", Env
.string, "to", Env
.string, "port", Env
.int)
582 (fn (from
, to
, port
) =>
584 write
"\tRewriteRule\t";
586 write
"\thttp://localhost:";
587 write (Int.toString port
);
592 val () = Env
.action_two
"proxyPass"
593 ("from", Env
.string, "to", Env
.string)
595 (write
"\tProxyPass\t";
601 val () = Env
.action_two
"proxyPassReverse"
602 ("from", Env
.string, "to", Env
.string)
604 (write
"\tProxyPassReverse\t";
610 val () = Env
.action_three
"rewriteRule"
611 ("from", Env
.string, "to", Env
.string, "flags", Env
.list flag
)
612 (fn (from
, to
, flags
) =>
614 write
"\tRewriteRule\t";
620 | flag
::rest
=> (write
" [";
622 app (fn flag
=> (write
",";
627 val () = Env
.action_three
"rewriteCond"
628 ("test", Env
.string, "pattern", Env
.string, "flags", Env
.list cond_flag
)
629 (fn (from
, to
, flags
) =>
631 write
"\tRewriteCond\t";
637 | flag
::rest
=> (write
" [";
639 app (fn flag
=> (write
",";
644 val () = Env
.action_one
"rewriteBase"
645 ("prefix", Env
.string)
648 write
"\tRewriteBase\t";
652 val () = Env
.action_one
"rewriteLogLevel"
656 write
"\tRewriteLog ";
658 write
"/rewrite.log\n\tRewriteLogLevel ";
659 write (Int.toString level
);
662 val () = Env
.action_two
"alias"
663 ("from", Env
.string, "to", Env
.string)
671 val () = Env
.action_two
"scriptAlias"
672 ("from", Env
.string, "to", Env
.string)
674 (write
"\tScriptAlias\t";
680 val () = Env
.action_two
"errorDocument"
681 ("code", Env
.string, "handler", Env
.string)
682 (fn (code
, handler
) =>
684 val hasSpaces
= CharVector
.exists
Char.isSpace handler
692 write
"\tErrorDocument\t";
701 val () = Env
.action_one
"options"
702 ("options", Env
.list apache_option
)
706 | _
=> (write
"\tOptions";
707 app (fn opt
=> (write
" "; write opt
)) opts
;
710 val () = Env
.action_one
"set_options"
711 ("options", Env
.list apache_option
)
715 | _
=> (write
"\tOptions";
716 app (fn opt
=> (write
" +"; write opt
)) opts
;
719 val () = Env
.action_one
"unset_options"
720 ("options", Env
.list apache_option
)
724 | _
=> (write
"\tOptions";
725 app (fn opt
=> (write
" -"; write opt
)) opts
;
728 val () = Env
.action_one
"cgiExtension"
729 ("extension", Env
.string)
730 (fn ext
=> (write
"\tAddHandler cgi-script ";
734 val () = Env
.action_one
"directoryIndex"
735 ("filenames", Env
.list Env
.string)
737 (write
"\tDirectoryIndex";
738 app (fn opt
=> (write
" "; write opt
)) opts
;
741 val () = Env
.action_one
"serverAliasHost"
744 (write
"\tServerAlias ";
749 val () = Env
.action_one
"serverAlias"
755 val full
= host ^
"." ^ dom
757 write
"\tServerAlias ";
762 (Domain
.currentDomains ())))
764 val () = Env
.action_none
"serverAliasDefault"
768 (write
"\tServerAlias ";
772 (Domain
.currentDomains ())))
774 val authType
= fn (EVar
"basic", _
) => SOME
"basic"
775 |
(EVar
"digest", _
) => SOME
"digest"
776 |
(EVar
"kerberos", _
) => SOME
"kerberos"
779 fun allowAuthType
"kerberos" = !sslEnabled
780 | allowAuthType _
= true
782 val () = Env
.action_one
"authType"
785 if allowAuthType ty
then
786 (write
"\tAuthType ";
791 write
"\tKrbMethodNegotiate off\n\tKrbMethodK5Passwd on\n\tKrbVerifyKDC off\n\tKrbAuthRealms HCOOP.NET\n\tKrbSaveCredentials on\n"
794 print
"WARNING: Skipped Kerberos authType because this isn't an SSL vhost.\n")
796 val () = Env
.action_one
"authName"
799 (write
"\tAuthName \"";
803 val () = Env
.action_one
"authUserFile"
806 (write
"\tAuthUserFile ";
810 val () = Env
.action_none
"requireValidUser"
811 (fn () => write
"\tRequire valid-user\n")
813 val () = Env
.action_one
"requireUser"
814 ("users", Env
.list Env
.string)
818 | _
=> (write
"\tRequire user";
819 app (fn name
=> (write
" "; write name
)) names
;
822 val () = Env
.action_one
"requireGroup"
823 ("groups", Env
.list Env
.string)
827 | _
=> (write
"\tRequire group";
828 app (fn name
=> (write
" "; write name
)) names
;
831 val () = Env
.action_none
"orderAllowDeny"
832 (fn () => write
"\tOrder allow,deny\n")
834 val () = Env
.action_none
"orderDenyAllow"
835 (fn () => write
"\tOrder deny,allow\n")
837 val () = Env
.action_none
"allowFromAll"
838 (fn () => write
"\tAllow from all\n")
840 val () = Env
.action_one
"allowFrom"
841 ("entries", Env
.list Env
.string)
845 | _
=> (write
"\tAllow from";
846 app (fn name
=> (write
" "; write name
)) names
;
849 val () = Env
.action_none
"denyFromAll"
850 (fn () => write
"\tDeny from all\n")
852 val () = Env
.action_one
"denyFrom"
853 ("entries", Env
.list Env
.string)
857 | _
=> (write
"\tDeny from";
858 app (fn name
=> (write
" "; write name
)) names
;
861 val () = Env
.action_none
"satisfyAll"
862 (fn () => write
"\tSatisfy all\n")
864 val () = Env
.action_none
"satisfyAny"
865 (fn () => write
"\tSatisfy any\n")
867 val () = Env
.action_one
"forceType"
869 (fn ty
=> (write
"\tForceType ";
873 val () = Env
.action_none
"forceTypeOff"
874 (fn () => write
"\tForceType None\n")
876 val () = Env
.action_two
"action"
877 ("what", Env
.string, "how", Env
.string)
878 (fn (what
, how
) => (write
"\tAction ";
884 val () = Env
.action_one
"addDefaultCharset"
885 ("charset", Env
.string)
886 (fn ty
=> (write
"\tAddDefaultCharset ";
890 (*val () = Env
.action_one
"davSvn"
892 (fn path
=> (write
"\tDAV svn\n\tSVNPath ";
896 val () = Env
.action_one
"authzSvnAccessFile"
898 (fn path
=> (write
"\tAuthzSVNAccessFile ";
902 val () = Env
.action_none
"davFilesystem"
903 (fn path
=> write
"\tDAV filesystem\n")
905 val () = Env
.action_two
"addDescription"
906 ("description", Env
.string, "patterns", Env
.list Env
.string)
910 | _
=> (write
"\tAddDescription \"";
911 write (String.toString desc
);
913 app (fn pat
=> (write
" "; write pat
)) pats
;
916 val () = Env
.action_one
"indexOptions"
917 ("options", Env
.list autoindex_option
)
921 | _
=> (write
"\tIndexOptions";
922 app (fn (opt
, arg
) =>
925 Option
.app (fn arg
=>
926 (write
"="; write arg
)) arg
)) opts
;
929 val () = Env
.action_one
"set_indexOptions"
930 ("options", Env
.list autoindex_option
)
934 | _
=> (write
"\tIndexOptions";
935 app (fn (opt
, arg
) =>
938 Option
.app (fn arg
=>
939 (write
"="; write arg
)) arg
)) opts
;
942 val () = Env
.action_one
"unset_indexOptions"
943 ("options", Env
.list autoindex_option
)
947 | _
=> (write
"\tIndexOptions";
953 val () = Env
.action_one
"headerName"
955 (fn name
=> (write
"\tHeaderName ";
959 val () = Env
.action_one
"readmeName"
961 (fn name
=> (write
"\tReadmeName ";
965 val () = Env
.action_two
"setEnv"
966 ("key", Env
.string, "value", Env
.string)
967 (fn (key
, value
) => (write
"\tSetEnv \"";
970 write (String.translate (fn #
"\"" => "\\\""
971 | ch
=> str ch
) value
);
974 val () = Env
.action_one
"diskCache"
976 (fn path
=> (write
"\tCacheEnable disk \"";
980 val () = Domain
.registerResetLocal (fn () =>
981 ignore (OS
.Process
.system (Config
.rm ^
" -rf /var/domtool/vhosts/*")))
983 val () = Domain
.registerDescriber (Domain
.considerAll
984 [Domain
.Extension
{extension
= "vhost",
985 heading
= fn host
=> "Web vhost " ^ host ^
":"},
986 Domain
.Extension
{extension
= "vhost_ssl",
987 heading
= fn host
=> "SSL web vhost " ^ host ^
":"}])