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
102 val _
= Env
.type_one
"location"
106 fun validCert s
= Acl
.query
{user
= Domain
.getUser (),
110 val _
= Env
.type_one
"ssl_cert_path"
114 fun ssl e
= case e
of
115 (EVar
"no_ssl", _
) => SOME NONE
116 |
(EApp ((EVar
"use_cert", _
), s
), _
) => Option
.map
SOME (Env
.string s
)
119 fun validExtension s
=
122 andalso CharVector
.all (fn ch
=> Char.isAlphaNum ch
orelse ch
= #
"_") s
124 val _
= Env
.type_one
"file_extension"
128 val defaults
= [("WebPlaces",
129 (TList (TBase
"web_place", dl
), dl
),
130 (fn () => (EList (map webPlaceDefault Config
.Apache
.webNodes_default
), dl
))),
133 (fn () => (EVar
"no_ssl", dl
))),
135 (TBase
"your_user", dl
),
136 (fn () => (EString (Domain
.getUser ()), dl
))),
138 (TBase
"your_group", dl
),
139 (fn () => (EString
"nogroup", dl
))),
141 (TBase
"your_path", dl
),
142 (fn () => (EString (Domain
.homedir () ^
"/" ^ Config
.Apache
.public_html
), dl
))),
145 (fn () => (EString (Domain
.getUser () ^
"@" ^ Config
.defaultDomain
), dl
))),
147 (TBase
"suexec_flag", dl
),
148 (fn () => (EVar
"true", dl
)))]
150 val () = app Defaults
.registerDefault defaults
152 val redirect_code
= fn (EVar
"temp", _
) => SOME
"temp"
153 |
(EVar
"permanent", _
) => SOME
"permanent"
154 |
(EVar
"seeother", _
) => SOME
"seeother"
155 |
(EVar
"redir300", _
) => SOME
"300"
156 |
(EVar
"redir301", _
) => SOME
"301"
157 |
(EVar
"redir302", _
) => SOME
"302"
158 |
(EVar
"redir303", _
) => SOME
"303"
159 |
(EVar
"redir304", _
) => SOME
"304"
160 |
(EVar
"redir305", _
) => SOME
"305"
161 |
(EVar
"redir307", _
) => SOME
"307"
164 val flag
= fn (EVar
"redirect", _
) => SOME
"R"
165 |
(EVar
"forbidden", _
) => SOME
"F"
166 |
(EVar
"gone", _
) => SOME
"G"
167 |
(EVar
"last", _
) => SOME
"L"
168 |
(EVar
"chain", _
) => SOME
"C"
169 |
(EVar
"nosubreq", _
) => SOME
"NS"
170 |
(EVar
"nocase", _
) => SOME
"NC"
171 |
(EVar
"qsappend", _
) => SOME
"QSA"
172 |
(EVar
"noescape", _
) => SOME
"NE"
173 |
(EVar
"passthrough", _
) => SOME
"PT"
174 |
(EApp ((EVar
"mimeType", _
), e
), _
) =>
175 Option
.map (fn s
=> "T=" ^ s
) (Env
.string e
)
176 |
(EApp ((EVar
"redirectWith", _
), e
), _
) =>
177 Option
.map (fn s
=> "R=" ^ s
) (redirect_code e
)
178 |
(EApp ((EVar
"skip", _
), e
), _
) =>
179 Option
.map (fn n
=> "S=" ^
Int.toString n
) (Env
.int e
)
180 |
(EApp ((EApp ((EVar
"env", _
), e1
), _
), e2
), _
) =>
181 (case Env
.string e1
of
183 | SOME s1
=> Option
.map (fn s2
=> "E=" ^ s1 ^
":" ^ s2
)
188 val cond_flag
= fn (EVar
"cond_nocase", _
) => SOME
"NC"
189 |
(EVar
"ornext", _
) => SOME
"OR"
192 val apache_option
= fn (EVar
"execCGI", _
) => SOME
"ExecCGI"
193 |
(EVar
"includesNOEXEC", _
) => SOME
"IncludesNOEXEC"
194 |
(EVar
"indexes", _
) => SOME
"Indexes"
195 |
(EVar
"followSymLinks", _
) => SOME
"FollowSymLinks"
198 val autoindex_width
= fn (EVar
"autofit", _
) => SOME
"*"
199 |
(EApp ((EVar
"characters", _
), n
), _
) =>
200 Option
.map
Int.toString (Env
.int n
)
203 val autoindex_option
= fn (EApp ((EVar
"descriptionWidth", _
), w
), _
) =>
204 Option
.map (fn w
=> ("DescriptionWidth", SOME w
))
206 |
(EVar
"fancyIndexing", _
) => SOME ("FancyIndexing", NONE
)
207 |
(EVar
"foldersFirst", _
) => SOME ("FoldersFirst", NONE
)
208 |
(EVar
"htmlTable", _
) => SOME ("HTMLTable", NONE
)
209 |
(EVar
"iconsAreLinks", _
) => SOME ("IconsAreLinks", NONE
)
210 |
(EApp ((EVar
"iconHeight", _
), n
), _
) =>
211 Option
.map (fn w
=> ("IconHeight", SOME (Int.toString w
)))
213 |
(EApp ((EVar
"iconWidth", _
), n
), _
) =>
214 Option
.map (fn w
=> ("IconWidth", SOME (Int.toString w
)))
216 |
(EVar
"ignoreCase", _
) => SOME ("IgnoreCase", NONE
)
217 |
(EVar
"ignoreClient", _
) => SOME ("IgnoreClient", NONE
)
218 |
(EApp ((EVar
"nameWidth", _
), w
), _
) =>
219 Option
.map (fn w
=> ("NameWidth", SOME w
))
221 |
(EVar
"scanHtmlTitles", _
) => SOME ("ScanHTMLTitles", NONE
)
222 |
(EVar
"suppressColumnSorting", _
) => SOME ("SuppressColumnSorting", NONE
)
223 |
(EVar
"suppressDescription", _
) => SOME ("SuppressDescription", NONE
)
224 |
(EVar
"suppressHtmlPreamble", _
) => SOME ("SuppressHTMLPreamble", NONE
)
225 |
(EVar
"suppressIcon", _
) => SOME ("SuppressIcon", NONE
)
226 |
(EVar
"suppressLastModified", _
) => SOME ("SuppressLastModified", NONE
)
227 |
(EVar
"suppressRules", _
) => SOME ("SuppressRules", NONE
)
228 |
(EVar
"suppressSize", _
) => SOME ("SuppressSize", NONE
)
229 |
(EVar
"trackModified", _
) => SOME ("TrackModified", NONE
)
230 |
(EVar
"versionSort", _
) => SOME ("VersionSort", NONE
)
231 |
(EVar
"xhtml", _
) => SOME ("XHTML", NONE
)
235 val vhostsChanged
= ref
false
236 val logDeleted
= ref
false
238 val () = Slave
.registerPreHandler
239 (fn () => (vhostsChanged
:= false;
240 logDeleted
:= false))
242 fun findVhostUser fname
=
244 val inf
= TextIO.openIn fname
247 case TextIO.inputLine inf
of
250 if String.isPrefix
"# Owner: " line
then
251 case String.tokens
Char.isSpace line
of
252 [_
, _
, user
] => SOME user
258 before TextIO.closeIn inf
261 val webNodes_full
= Config
.Apache
.webNodes_all @ Config
.Apache
.webNodes_admin
263 fun isVersion1 node
=
264 List.exists (fn (n
, {version
= ConfigTypes
.APACHE_1_3
, ...}) => n
= node
265 | _
=> false) webNodes_full
267 fun imVersion1 () = isVersion1 (Slave
.hostname ())
270 List.exists (fn (n
, {auth
= ConfigTypes
.MOD_WAKLOG
, ...}) => n
= node
271 | _
=> false) webNodes_full
273 fun down () = if imVersion1 () then Config
.Apache
.down1
else Config
.Apache
.down
274 fun undown () = if imVersion1 () then Config
.Apache
.undown1
else Config
.Apache
.undown
275 fun reload () = if imVersion1 () then Config
.Apache
.reload1
else Config
.Apache
.reload
276 fun fixperms () = if imVersion1 () then Config
.Apache
.fixperms1
else Config
.Apache
.fixperms
278 fun logDir
{user
, node
, vhostId
} =
279 String.concat
[Config
.Apache
.logDirOf (isVersion1 node
) user
,
285 fun realLogDir
{user
, node
, vhostId
} =
286 String.concat
[Config
.Apache
.realLogDirOf user
,
292 val () = Slave
.registerFileHandler (fn fs
=>
294 val spl
= OS
.Path
.splitDirFile (#file fs
)
296 if String.isSuffix
".vhost" (#file spl
)
297 orelse String.isSuffix
".vhost_ssl" (#file spl
) then let
298 val realVhostFile
= OS
.Path
.joinDirFile
299 {dir
= Config
.Apache
.confDir
,
302 val user
= findVhostUser (#file fs
)
303 val oldUser
= case #action fs
of
304 Slave
.Delete
false => user
305 | _
=> findVhostUser realVhostFile
307 if (oldUser
= NONE
andalso #action fs
<> Slave
.Add
)
308 orelse (user
= NONE
andalso not (Slave
.isDelete (#action fs
))) then
309 print ("Can't find user in " ^ #file fs ^
" or " ^ realVhostFile ^
"! Taking no action.\n")
312 val vhostId
= if OS
.Path
.ext (#file spl
) = SOME
"vhost_ssl" then
313 OS
.Path
.base (#file spl
) ^
".ssl"
315 OS
.Path
.base (#file spl
)
317 fun realLogDir user
=
318 logDir
{user
= valOf user
,
319 node
= Slave
.hostname (),
324 {dir
= Config
.Apache
.backupLogDirOf
325 (isVersion1 (Slave
.hostname ())),
328 vhostsChanged
:= true;
332 val ldir
= realLogDir oldUser
337 (ignore (OS
.Process
.system (down ()));
338 ignore (OS
.Process
.system (fixperms ()));
340 ignore (OS
.Process
.system (Config
.rm
343 Slave
.moveDirCreate
{from
= ldir
,
348 val rld
= realLogDir user
350 ignore (OS
.Process
.system (Config
.cp
355 if Posix
.FileSys
.access (rld
, []) then
358 Slave
.moveDirCreate
{from
= backupLogs (),
363 (ignore (OS
.Process
.system (Config
.cp
368 if user
<> oldUser
then
370 val old
= realLogDir oldUser
371 val rld
= realLogDir user
376 (ignore (OS
.Process
.system (down ()));
378 ignore (OS
.Process
.system (Config
.rm
380 ^ realLogDir oldUser
));
381 if Posix
.FileSys
.access (rld
, []) then
394 val () = Slave
.registerPostHandler
396 (if !vhostsChanged
then
397 Slave
.shellF ([if !logDeleted
then undown () else reload ()],
398 fn cl
=> "Error reloading Apache with " ^ cl
)
402 val vhostFiles
: (string * TextIO.outstream
) list ref
= ref
[]
403 fun write
' s
= app (fn (node
, file
) => TextIO.output (file
, s node
)) (!vhostFiles
)
404 fun write s
= app (fn (_
, file
) => TextIO.output (file
, s
)) (!vhostFiles
)
406 val rewriteEnabled
= ref
false
407 val localRewriteEnabled
= ref
false
408 val currentVhost
= ref
""
409 val currentVhostId
= ref
""
410 val sslEnabled
= ref
false
412 val pre
= ref (fn _
: {user
: string, nodes
: string list
, id
: string, hostname
: string} => ())
417 pre
:= (fn x
=> (old x
; f x
))
420 val post
= ref (fn () => ())
425 post
:= (fn () => (old (); f ()))
429 fun doPost () = !post ()
431 val aliaser
= ref (fn _
: string => ())
432 fun registerAliaser f
=
436 aliaser
:= (fn x
=> (old x
; f x
))
439 fun vhostPost () = (!post ();
440 write
"</VirtualHost>\n";
441 app (TextIO.closeOut
o #
2) (!vhostFiles
))
443 fun vhostBody (env
, makeFullHost
) =
445 val places
= Env
.env (Env
.list webPlace
) (env
, "WebPlaces")
447 val ssl
= Env
.env
ssl (env
, "SSL")
448 val user
= Env
.env Env
.string (env
, "User")
449 val group
= Env
.env Env
.string (env
, "Group")
450 val docroot
= Env
.env Env
.string (env
, "DocumentRoot")
451 val sadmin
= Env
.env Env
.string (env
, "ServerAdmin")
452 val suexec
= Env
.env Env
.bool (env
, "SuExec")
454 val fullHost
= makeFullHost (Domain
.currentDomain ())
455 val vhostId
= fullHost ^
(if Option
.isSome ssl
then ".ssl" else "")
456 val confFile
= fullHost ^
(if Option
.isSome ssl
then ".vhost_ssl" else ".vhost")
458 currentVhost
:= fullHost
;
459 currentVhostId
:= vhostId
;
460 sslEnabled
:= Option
.isSome ssl
;
462 rewriteEnabled
:= false;
463 localRewriteEnabled
:= false;
464 vhostFiles
:= map (fn (node
, ip
) =>
466 val file
= Domain
.domainFile
{node
= node
,
469 val ld
= logDir
{user
= user
, node
= node
, vhostId
= vhostId
}
471 TextIO.output (file
, "# Owner: ");
472 TextIO.output (file
, user
);
473 TextIO.output (file
, "\n<VirtualHost ");
474 TextIO.output (file
, ip
);
475 TextIO.output (file
, ":");
476 TextIO.output (file
, case ssl
of
479 TextIO.output (file
, ">\n");
480 TextIO.output (file
, "\tErrorLog ");
481 TextIO.output (file
, ld
);
482 TextIO.output (file
, "/error.log\n\tCustomLog ");
483 TextIO.output (file
, ld
);
484 TextIO.output (file
, "/access.log combined\n");
485 TextIO.output (file
, "\tServerName ");
486 TextIO.output (file
, fullHost
);
488 (fn dom
=> (TextIO.output (file
, "\n\tServerAlias ");
489 TextIO.output (file
, makeFullHost dom
)))
490 (Domain
.currentAliasDomains ());
493 if isVersion1 node
then
494 (TextIO.output (file
, "\n\tUser ");
495 TextIO.output (file
, user
);
496 TextIO.output (file
, "\n\tGroup ");
497 TextIO.output (file
, group
))
499 (TextIO.output (file
, "\n\tSuexecUserGroup ");
500 TextIO.output (file
, user
);
501 TextIO.output (file
, " ");
502 TextIO.output (file
, group
))
506 if isWaklog node
then
507 (TextIO.output (file
, "\n\tWaklogEnabled on\n\tWaklogLocationPrincipal ");
508 TextIO.output (file
, user
);
509 TextIO.output (file
, "/daemon@HCOOP.NET /etc/keytabs/user.daemon/");
510 TextIO.output (file
, user
))
514 TextIO.output (file
, "\n\tDAVLockDB /var/lock/apache2/dav/");
515 TextIO.output (file
, user
);
516 TextIO.output (file
, "/DAVLock");
521 write
"\n\tDocumentRoot ";
523 write
"\n\tServerAdmin ";
527 (write
"\n\tSSLEngine on\n\tSSLCertificateFile ";
531 !pre
{user
= user
, nodes
= map #
1 places
, id
= vhostId
, hostname
= fullHost
};
532 app (fn dom
=> !aliaser (makeFullHost dom
)) (Domain
.currentAliasDomains ())
535 val () = Env
.containerV_one
"vhost"
537 (fn (env
, host
) => vhostBody (env
, fn dom
=> host ^
"." ^ dom
),
540 val () = Env
.containerV_none
"vhostDefault"
541 (fn env
=> vhostBody (env
, fn dom
=> dom
),
544 val inLocal
= ref
false
546 val () = Env
.container_one
"location"
547 ("prefix", Env
.string)
549 (write
"\t<Location ";
553 fn () => (write
"\t</Location>\n";
555 localRewriteEnabled
:= false))
557 val () = Env
.container_one
"directory"
558 ("directory", Env
.string)
560 (write
"\t<Directory ";
564 fn () => (write
"\t</Directory>\n";
566 localRewriteEnabled
:= false))
568 fun checkRewrite () =
570 if !localRewriteEnabled
then
573 (write
"\tRewriteEngine on\n";
574 localRewriteEnabled
:= true)
575 else if !rewriteEnabled
then
578 (write
"\tRewriteEngine on\n";
579 rewriteEnabled
:= true)
581 val () = Env
.action_three
"localProxyRewrite"
582 ("from", Env
.string, "to", Env
.string, "port", Env
.int)
583 (fn (from
, to
, port
) =>
585 write
"\tRewriteRule\t";
587 write
"\thttp://localhost:";
588 write (Int.toString port
);
593 val () = Env
.action_two
"proxyPass"
594 ("from", Env
.string, "to", Env
.string)
596 (write
"\tProxyPass\t";
602 val () = Env
.action_two
"proxyPassReverse"
603 ("from", Env
.string, "to", Env
.string)
605 (write
"\tProxyPassReverse\t";
611 val () = Env
.action_three
"rewriteRule"
612 ("from", Env
.string, "to", Env
.string, "flags", Env
.list flag
)
613 (fn (from
, to
, flags
) =>
615 write
"\tRewriteRule\t";
621 | flag
::rest
=> (write
" [";
623 app (fn flag
=> (write
",";
628 val () = Env
.action_three
"rewriteCond"
629 ("test", Env
.string, "pattern", Env
.string, "flags", Env
.list cond_flag
)
630 (fn (from
, to
, flags
) =>
632 write
"\tRewriteCond\t";
638 | flag
::rest
=> (write
" [";
640 app (fn flag
=> (write
",";
645 val () = Env
.action_one
"rewriteBase"
646 ("prefix", Env
.string)
649 write
"\tRewriteBase\t";
653 val () = Env
.action_one
"rewriteLogLevel"
657 write
"\tRewriteLog ";
659 write
"/rewrite.log\n\tRewriteLogLevel ";
660 write (Int.toString level
);
663 val () = Env
.action_two
"alias"
664 ("from", Env
.string, "to", Env
.string)
672 val () = Env
.action_two
"scriptAlias"
673 ("from", Env
.string, "to", Env
.string)
675 (write
"\tScriptAlias\t";
681 val () = Env
.action_two
"errorDocument"
682 ("code", Env
.string, "handler", Env
.string)
683 (fn (code
, handler
) =>
685 val hasSpaces
= CharVector
.exists
Char.isSpace handler
693 write
"\tErrorDocument\t";
702 val () = Env
.action_one
"options"
703 ("options", Env
.list apache_option
)
707 | _
=> (write
"\tOptions";
708 app (fn opt
=> (write
" "; write opt
)) opts
;
711 val () = Env
.action_one
"set_options"
712 ("options", Env
.list apache_option
)
716 | _
=> (write
"\tOptions";
717 app (fn opt
=> (write
" +"; write opt
)) opts
;
720 val () = Env
.action_one
"unset_options"
721 ("options", Env
.list apache_option
)
725 | _
=> (write
"\tOptions";
726 app (fn opt
=> (write
" -"; write opt
)) opts
;
729 val () = Env
.action_one
"cgiExtension"
730 ("extension", Env
.string)
731 (fn ext
=> (write
"\tAddHandler cgi-script ";
735 val () = Env
.action_one
"directoryIndex"
736 ("filenames", Env
.list Env
.string)
738 (write
"\tDirectoryIndex";
739 app (fn opt
=> (write
" "; write opt
)) opts
;
742 val () = Env
.action_one
"serverAliasHost"
745 (write
"\tServerAlias ";
750 val () = Env
.action_one
"serverAlias"
756 val full
= host ^
"." ^ dom
758 write
"\tServerAlias ";
763 (Domain
.currentDomains ())))
765 val () = Env
.action_none
"serverAliasDefault"
769 (write
"\tServerAlias ";
773 (Domain
.currentDomains ())))
775 val authType
= fn (EVar
"basic", _
) => SOME
"basic"
776 |
(EVar
"digest", _
) => SOME
"digest"
777 |
(EVar
"kerberos", _
) => SOME
"kerberos"
780 fun allowAuthType
"kerberos" = !sslEnabled
781 | allowAuthType _
= true
783 val () = Env
.action_one
"authType"
786 if allowAuthType ty
then
787 (write
"\tAuthType ";
792 write
"\tKrbMethodNegotiate off\n\tKrbMethodK5Passwd on\n\tKrbVerifyKDC off\n\tKrbAuthRealms HCOOP.NET\n\tKrbSaveCredentials on\n"
795 print
"WARNING: Skipped Kerberos authType because this isn't an SSL vhost.\n")
797 val () = Env
.action_one
"authName"
800 (write
"\tAuthName \"";
804 val () = Env
.action_one
"authUserFile"
807 (write
"\tAuthUserFile ";
811 val () = Env
.action_none
"requireValidUser"
812 (fn () => write
"\tRequire valid-user\n")
814 val () = Env
.action_one
"requireUser"
815 ("users", Env
.list Env
.string)
819 | _
=> (write
"\tRequire user";
820 app (fn name
=> (write
" "; write name
)) names
;
823 val () = Env
.action_one
"requireGroup"
824 ("groups", Env
.list Env
.string)
828 | _
=> (write
"\tRequire group";
829 app (fn name
=> (write
" "; write name
)) names
;
832 val () = Env
.action_none
"orderAllowDeny"
833 (fn () => write
"\tOrder allow,deny\n")
835 val () = Env
.action_none
"orderDenyAllow"
836 (fn () => write
"\tOrder deny,allow\n")
838 val () = Env
.action_none
"allowFromAll"
839 (fn () => write
"\tAllow from all\n")
841 val () = Env
.action_one
"allowFrom"
842 ("entries", Env
.list Env
.string)
846 | _
=> (write
"\tAllow from";
847 app (fn name
=> (write
" "; write name
)) names
;
850 val () = Env
.action_none
"denyFromAll"
851 (fn () => write
"\tDeny from all\n")
853 val () = Env
.action_one
"denyFrom"
854 ("entries", Env
.list Env
.string)
858 | _
=> (write
"\tDeny from";
859 app (fn name
=> (write
" "; write name
)) names
;
862 val () = Env
.action_none
"satisfyAll"
863 (fn () => write
"\tSatisfy all\n")
865 val () = Env
.action_none
"satisfyAny"
866 (fn () => write
"\tSatisfy any\n")
868 val () = Env
.action_one
"forceType"
870 (fn ty
=> (write
"\tForceType ";
874 val () = Env
.action_none
"forceTypeOff"
875 (fn () => write
"\tForceType None\n")
877 val () = Env
.action_two
"action"
878 ("what", Env
.string, "how", Env
.string)
879 (fn (what
, how
) => (write
"\tAction ";
885 val () = Env
.action_one
"addDefaultCharset"
886 ("charset", Env
.string)
887 (fn ty
=> (write
"\tAddDefaultCharset ";
891 (*val () = Env
.action_one
"davSvn"
893 (fn path
=> (write
"\tDAV svn\n\tSVNPath ";
897 val () = Env
.action_one
"authzSvnAccessFile"
899 (fn path
=> (write
"\tAuthzSVNAccessFile ";
903 val () = Env
.action_none
"davFilesystem"
904 (fn path
=> write
"\tDAV filesystem\n")
906 val () = Env
.action_two
"addDescription"
907 ("description", Env
.string, "patterns", Env
.list Env
.string)
911 | _
=> (write
"\tAddDescription \"";
912 write (String.toString desc
);
914 app (fn pat
=> (write
" "; write pat
)) pats
;
917 val () = Env
.action_one
"indexOptions"
918 ("options", Env
.list autoindex_option
)
922 | _
=> (write
"\tIndexOptions";
923 app (fn (opt
, arg
) =>
926 Option
.app (fn arg
=>
927 (write
"="; write arg
)) arg
)) opts
;
930 val () = Env
.action_one
"set_indexOptions"
931 ("options", Env
.list autoindex_option
)
935 | _
=> (write
"\tIndexOptions";
936 app (fn (opt
, arg
) =>
939 Option
.app (fn arg
=>
940 (write
"="; write arg
)) arg
)) opts
;
943 val () = Env
.action_one
"unset_indexOptions"
944 ("options", Env
.list autoindex_option
)
948 | _
=> (write
"\tIndexOptions";
954 val () = Env
.action_one
"headerName"
956 (fn name
=> (write
"\tHeaderName ";
960 val () = Env
.action_one
"readmeName"
962 (fn name
=> (write
"\tReadmeName ";
966 val () = Env
.action_two
"setEnv"
967 ("key", Env
.string, "value", Env
.string)
968 (fn (key
, value
) => (write
"\tSetEnv \"";
971 write (String.translate (fn #
"\"" => "\\\""
972 | ch
=> str ch
) value
);
975 val () = Env
.action_one
"diskCache"
977 (fn path
=> (write
"\tCacheEnable disk \"";
981 val php_version
= fn (EVar
"php4", _
) => SOME
4
982 |
(EVar
"php5", _
) => SOME
5
985 val () = Env
.action_one
"phpVersion"
986 ("version", php_version
)
987 (fn version
=> (write
"\tAddHandler x-httpd-php";
988 write (Int.toString version
);
989 write
" .php .phtml\n"))
991 val () = Env
.action_two
"addType"
992 ("mime type", Env
.string, "extension", Env
.string)
993 (fn (mt
, ext
) => (write
"\tAddType ";
999 val filter
= fn (EVar
"includes", _
) => SOME
"INCLUDES"
1000 |
(EVar
"deflate", _
) => SOME
"DEFLATE"
1003 val () = Env
.action_two
"addOutputFilter"
1004 ("filters", Env
.list filter
, "extensions", Env
.list Env
.string)
1005 (fn (f
:: fs
, exts
as (_
:: _
)) =>
1006 (write
"\tAddOutputFilter ";
1008 app (fn f
=> (write
";"; write f
)) fs
;
1009 app (fn ext
=> (write
" "; write ext
)) exts
;
1013 val () = Domain
.registerResetLocal (fn () =>
1014 ignore (OS
.Process
.system (Config
.rm ^
" -rf /var/domtool/vhosts/*")))
1016 val () = Domain
.registerDescriber (Domain
.considerAll
1017 [Domain
.Extension
{extension
= "vhost",
1018 heading
= fn host
=> "Web vhost " ^ host ^
":"},
1019 Domain
.Extension
{extension
= "vhost_ssl",
1020 heading
= fn host
=> "SSL web vhost " ^ host ^
":"}])