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 (TBase
"php_version", dl
),
151 (fn () => (EVar
"php4", dl
)))]
153 val () = app Defaults
.registerDefault defaults
155 val redirect_code
= fn (EVar
"temp", _
) => SOME
"temp"
156 |
(EVar
"permanent", _
) => SOME
"permanent"
157 |
(EVar
"seeother", _
) => SOME
"seeother"
158 |
(EVar
"redir300", _
) => SOME
"300"
159 |
(EVar
"redir301", _
) => SOME
"301"
160 |
(EVar
"redir302", _
) => SOME
"302"
161 |
(EVar
"redir303", _
) => SOME
"303"
162 |
(EVar
"redir304", _
) => SOME
"304"
163 |
(EVar
"redir305", _
) => SOME
"305"
164 |
(EVar
"redir307", _
) => SOME
"307"
167 val flag
= fn (EVar
"redirect", _
) => SOME
"R"
168 |
(EVar
"forbidden", _
) => SOME
"F"
169 |
(EVar
"gone", _
) => SOME
"G"
170 |
(EVar
"last", _
) => SOME
"L"
171 |
(EVar
"chain", _
) => SOME
"C"
172 |
(EVar
"nosubreq", _
) => SOME
"NS"
173 |
(EVar
"nocase", _
) => SOME
"NC"
174 |
(EVar
"qsappend", _
) => SOME
"QSA"
175 |
(EVar
"noescape", _
) => SOME
"NE"
176 |
(EVar
"passthrough", _
) => SOME
"PT"
177 |
(EApp ((EVar
"mimeType", _
), e
), _
) =>
178 Option
.map (fn s
=> "T=" ^ s
) (Env
.string e
)
179 |
(EApp ((EVar
"redirectWith", _
), e
), _
) =>
180 Option
.map (fn s
=> "R=" ^ s
) (redirect_code e
)
181 |
(EApp ((EVar
"skip", _
), e
), _
) =>
182 Option
.map (fn n
=> "S=" ^
Int.toString n
) (Env
.int e
)
183 |
(EApp ((EApp ((EVar
"env", _
), e1
), _
), e2
), _
) =>
184 (case Env
.string e1
of
186 | SOME s1
=> Option
.map (fn s2
=> "E=" ^ s1 ^
":" ^ s2
)
191 val cond_flag
= fn (EVar
"cond_nocase", _
) => SOME
"NC"
192 |
(EVar
"ornext", _
) => SOME
"OR"
195 val apache_option
= fn (EVar
"execCGI", _
) => SOME
"ExecCGI"
196 |
(EVar
"includesNOEXEC", _
) => SOME
"IncludesNOEXEC"
197 |
(EVar
"indexes", _
) => SOME
"Indexes"
198 |
(EVar
"followSymLinks", _
) => SOME
"FollowSymLinks"
201 val autoindex_width
= fn (EVar
"autofit", _
) => SOME
"*"
202 |
(EApp ((EVar
"characters", _
), n
), _
) =>
203 Option
.map
Int.toString (Env
.int n
)
206 val autoindex_option
= fn (EApp ((EVar
"descriptionWidth", _
), w
), _
) =>
207 Option
.map (fn w
=> ("DescriptionWidth", SOME w
))
209 |
(EVar
"fancyIndexing", _
) => SOME ("FancyIndexing", NONE
)
210 |
(EVar
"foldersFirst", _
) => SOME ("FoldersFirst", NONE
)
211 |
(EVar
"htmlTable", _
) => SOME ("HTMLTable", NONE
)
212 |
(EVar
"iconsAreLinks", _
) => SOME ("IconsAreLinks", NONE
)
213 |
(EApp ((EVar
"iconHeight", _
), n
), _
) =>
214 Option
.map (fn w
=> ("IconHeight", SOME (Int.toString w
)))
216 |
(EApp ((EVar
"iconWidth", _
), n
), _
) =>
217 Option
.map (fn w
=> ("IconWidth", SOME (Int.toString w
)))
219 |
(EVar
"ignoreCase", _
) => SOME ("IgnoreCase", NONE
)
220 |
(EVar
"ignoreClient", _
) => SOME ("IgnoreClient", NONE
)
221 |
(EApp ((EVar
"nameWidth", _
), w
), _
) =>
222 Option
.map (fn w
=> ("NameWidth", SOME w
))
224 |
(EVar
"scanHtmlTitles", _
) => SOME ("ScanHTMLTitles", NONE
)
225 |
(EVar
"suppressColumnSorting", _
) => SOME ("SuppressColumnSorting", NONE
)
226 |
(EVar
"suppressDescription", _
) => SOME ("SuppressDescription", NONE
)
227 |
(EVar
"suppressHtmlPreamble", _
) => SOME ("SuppressHTMLPreamble", NONE
)
228 |
(EVar
"suppressIcon", _
) => SOME ("SuppressIcon", NONE
)
229 |
(EVar
"suppressLastModified", _
) => SOME ("SuppressLastModified", NONE
)
230 |
(EVar
"suppressRules", _
) => SOME ("SuppressRules", NONE
)
231 |
(EVar
"suppressSize", _
) => SOME ("SuppressSize", NONE
)
232 |
(EVar
"trackModified", _
) => SOME ("TrackModified", NONE
)
233 |
(EVar
"versionSort", _
) => SOME ("VersionSort", NONE
)
234 |
(EVar
"xhtml", _
) => SOME ("XHTML", NONE
)
238 val vhostsChanged
= ref
false
239 val logDeleted
= ref
false
241 val () = Slave
.registerPreHandler
242 (fn () => (vhostsChanged
:= false;
243 logDeleted
:= false))
245 fun findVhostUser fname
=
247 val inf
= TextIO.openIn fname
250 case TextIO.inputLine inf
of
253 if String.isPrefix
"# Owner: " line
then
254 case String.tokens
Char.isSpace line
of
255 [_
, _
, user
] => SOME user
261 before TextIO.closeIn inf
264 val webNodes_full
= Config
.Apache
.webNodes_all @ Config
.Apache
.webNodes_admin
266 fun isVersion1 node
=
267 List.exists (fn (n
, {version
= ConfigTypes
.APACHE_1_3
, ...}) => n
= node
268 | _
=> false) webNodes_full
270 fun imVersion1 () = isVersion1 (Slave
.hostname ())
273 List.exists (fn (n
, {auth
= ConfigTypes
.MOD_WAKLOG
, ...}) => n
= node
274 | _
=> false) webNodes_full
276 fun down () = if imVersion1 () then Config
.Apache
.down1
else Config
.Apache
.down
277 fun undown () = if imVersion1 () then Config
.Apache
.undown1
else Config
.Apache
.undown
278 fun reload () = if imVersion1 () then Config
.Apache
.reload1
else Config
.Apache
.reload
279 fun fixperms () = if imVersion1 () then Config
.Apache
.fixperms1
else Config
.Apache
.fixperms
281 fun logDir
{user
, node
, vhostId
} =
282 String.concat
[Config
.Apache
.logDirOf (isVersion1 node
) user
,
288 fun realLogDir
{user
, node
, vhostId
} =
289 String.concat
[Config
.Apache
.realLogDirOf user
,
295 val () = Slave
.registerFileHandler (fn fs
=>
297 val spl
= OS
.Path
.splitDirFile (#file fs
)
299 if String.isSuffix
".vhost" (#file spl
)
300 orelse String.isSuffix
".vhost_ssl" (#file spl
) then let
301 val realVhostFile
= OS
.Path
.joinDirFile
302 {dir
= Config
.Apache
.confDir
,
305 val user
= findVhostUser (#file fs
)
306 val oldUser
= case #action fs
of
307 Slave
.Delete
false => user
308 | _
=> findVhostUser realVhostFile
310 if (oldUser
= NONE
andalso #action fs
<> Slave
.Add
)
311 orelse (user
= NONE
andalso not (Slave
.isDelete (#action fs
))) then
312 print ("Can't find user in " ^ #file fs ^
" or " ^ realVhostFile ^
"! Taking no action.\n")
315 val vhostId
= if OS
.Path
.ext (#file spl
) = SOME
"vhost_ssl" then
316 OS
.Path
.base (#file spl
) ^
".ssl"
318 OS
.Path
.base (#file spl
)
320 fun realLogDir user
=
321 logDir
{user
= valOf user
,
322 node
= Slave
.hostname (),
327 {dir
= Config
.Apache
.backupLogDirOf
328 (isVersion1 (Slave
.hostname ())),
331 vhostsChanged
:= true;
335 val ldir
= realLogDir oldUser
340 (ignore (OS
.Process
.system (down ()));
341 ignore (OS
.Process
.system (fixperms ()));
343 ignore (OS
.Process
.system (Config
.rm
346 Slave
.moveDirCreate
{from
= ldir
,
351 val rld
= realLogDir user
353 ignore (OS
.Process
.system (Config
.cp
358 if Posix
.FileSys
.access (rld
, []) then
361 Slave
.moveDirCreate
{from
= backupLogs (),
366 (ignore (OS
.Process
.system (Config
.cp
371 if user
<> oldUser
then
373 val old
= realLogDir oldUser
374 val rld
= realLogDir user
379 (ignore (OS
.Process
.system (down ()));
381 ignore (OS
.Process
.system (Config
.rm
383 ^ realLogDir oldUser
));
384 if Posix
.FileSys
.access (rld
, []) then
397 val () = Slave
.registerPostHandler
399 (if !vhostsChanged
then
400 Slave
.shellF ([if !logDeleted
then undown () else reload ()],
401 fn cl
=> "Error reloading Apache with " ^ cl
)
405 val vhostFiles
: (string * TextIO.outstream
) list ref
= ref
[]
406 fun write
' s
= app (fn (node
, file
) => TextIO.output (file
, s node
)) (!vhostFiles
)
407 fun write s
= app (fn (_
, file
) => TextIO.output (file
, s
)) (!vhostFiles
)
409 val rewriteEnabled
= ref
false
410 val localRewriteEnabled
= ref
false
411 val currentVhost
= ref
""
412 val currentVhostId
= ref
""
413 val sslEnabled
= ref
false
415 val pre
= ref (fn _
: {user
: string, nodes
: string list
, id
: string, hostname
: string} => ())
420 pre
:= (fn x
=> (old x
; f x
))
423 val post
= ref (fn () => ())
428 post
:= (fn () => (old (); f ()))
432 fun doPost () = !post ()
434 val aliaser
= ref (fn _
: string => ())
435 fun registerAliaser f
=
439 aliaser
:= (fn x
=> (old x
; f x
))
442 fun vhostPost () = (!post ();
443 write
"</VirtualHost>\n";
444 app (TextIO.closeOut
o #
2) (!vhostFiles
))
446 val php_version
= fn (EVar
"php4", _
) => SOME
4
447 |
(EVar
"php5", _
) => SOME
5
450 fun vhostBody (env
, makeFullHost
) =
452 val places
= Env
.env (Env
.list webPlace
) (env
, "WebPlaces")
454 val ssl
= Env
.env
ssl (env
, "SSL")
455 val user
= Env
.env Env
.string (env
, "User")
456 val group
= Env
.env Env
.string (env
, "Group")
457 val docroot
= Env
.env Env
.string (env
, "DocumentRoot")
458 val sadmin
= Env
.env Env
.string (env
, "ServerAdmin")
459 val suexec
= Env
.env Env
.bool (env
, "SuExec")
460 val php
= Env
.env
php_version (env
, "PhpVersion")
462 val fullHost
= makeFullHost (Domain
.currentDomain ())
463 val vhostId
= fullHost ^
(if Option
.isSome ssl
then ".ssl" else "")
464 val confFile
= fullHost ^
(if Option
.isSome ssl
then ".vhost_ssl" else ".vhost")
466 currentVhost
:= fullHost
;
467 currentVhostId
:= vhostId
;
468 sslEnabled
:= Option
.isSome ssl
;
470 rewriteEnabled
:= false;
471 localRewriteEnabled
:= false;
472 vhostFiles
:= map (fn (node
, ip
) =>
474 val file
= Domain
.domainFile
{node
= node
,
477 val ld
= logDir
{user
= user
, node
= node
, vhostId
= vhostId
}
479 TextIO.output (file
, "# Owner: ");
480 TextIO.output (file
, user
);
481 TextIO.output (file
, "\n<VirtualHost ");
482 TextIO.output (file
, ip
);
483 TextIO.output (file
, ":");
484 TextIO.output (file
, case ssl
of
487 TextIO.output (file
, ">\n");
488 TextIO.output (file
, "\tErrorLog ");
489 TextIO.output (file
, ld
);
490 TextIO.output (file
, "/error.log\n\tCustomLog ");
491 TextIO.output (file
, ld
);
492 TextIO.output (file
, "/access.log combined\n");
493 TextIO.output (file
, "\tServerName ");
494 TextIO.output (file
, fullHost
);
496 (fn dom
=> (TextIO.output (file
, "\n\tServerAlias ");
497 TextIO.output (file
, makeFullHost dom
)))
498 (Domain
.currentAliasDomains ());
501 if isVersion1 node
then
502 (TextIO.output (file
, "\n\tUser ");
503 TextIO.output (file
, user
);
504 TextIO.output (file
, "\n\tGroup ");
505 TextIO.output (file
, group
))
507 (TextIO.output (file
, "\n\tSuexecUserGroup ");
508 TextIO.output (file
, user
);
509 TextIO.output (file
, " ");
510 TextIO.output (file
, group
))
514 if isWaklog node
then
515 (TextIO.output (file
, "\n\tWaklogEnabled on\n\tWaklogLocationPrincipal ");
516 TextIO.output (file
, user
);
517 TextIO.output (file
, "/daemon@HCOOP.NET /etc/keytabs/user.daemon/");
518 TextIO.output (file
, user
))
522 TextIO.output (file
, "\n\tDAVLockDB /var/lock/apache2/dav/");
523 TextIO.output (file
, user
);
524 TextIO.output (file
, "/DAVLock");
526 if php
<> Config
.Apache
.defaultPhpVersion
then
527 (TextIO.output (file
, "\n\tAddHandler x-httpd-php");
528 TextIO.output (file
, Int.toString php
);
529 TextIO.output (file
, " .php .phtml"))
536 write
"\n\tDocumentRoot ";
538 write
"\n\tServerAdmin ";
542 (write
"\n\tSSLEngine on\n\tSSLCertificateFile ";
546 !pre
{user
= user
, nodes
= map #
1 places
, id
= vhostId
, hostname
= fullHost
};
547 app (fn dom
=> !aliaser (makeFullHost dom
)) (Domain
.currentAliasDomains ())
550 val () = Env
.containerV_one
"vhost"
552 (fn (env
, host
) => vhostBody (env
, fn dom
=> host ^
"." ^ dom
),
555 val () = Env
.containerV_none
"vhostDefault"
556 (fn env
=> vhostBody (env
, fn dom
=> dom
),
559 val inLocal
= ref
false
561 val () = Env
.container_one
"location"
562 ("prefix", Env
.string)
564 (write
"\t<Location ";
568 fn () => (write
"\t</Location>\n";
570 localRewriteEnabled
:= false))
572 val () = Env
.container_one
"directory"
573 ("directory", Env
.string)
575 (write
"\t<Directory ";
579 fn () => (write
"\t</Directory>\n";
581 localRewriteEnabled
:= false))
583 fun checkRewrite () =
585 if !localRewriteEnabled
then
588 (write
"\tRewriteEngine on\n";
589 localRewriteEnabled
:= true)
590 else if !rewriteEnabled
then
593 (write
"\tRewriteEngine on\n";
594 rewriteEnabled
:= true)
596 val () = Env
.action_three
"localProxyRewrite"
597 ("from", Env
.string, "to", Env
.string, "port", Env
.int)
598 (fn (from
, to
, port
) =>
600 write
"\tRewriteRule\t\"";
602 write
"\"\thttp://localhost:";
603 write (Int.toString port
);
608 val () = Env
.action_two
"proxyPass"
609 ("from", Env
.string, "to", Env
.string)
611 (write
"\tProxyPass\t";
617 val () = Env
.action_two
"proxyPassReverse"
618 ("from", Env
.string, "to", Env
.string)
620 (write
"\tProxyPassReverse\t";
626 val () = Env
.action_three
"rewriteRule"
627 ("from", Env
.string, "to", Env
.string, "flags", Env
.list flag
)
628 (fn (from
, to
, flags
) =>
630 write
"\tRewriteRule\t\"";
637 | flag
::rest
=> (write
" [";
639 app (fn flag
=> (write
",";
644 val () = Env
.action_three
"rewriteCond"
645 ("test", Env
.string, "pattern", Env
.string, "flags", Env
.list cond_flag
)
646 (fn (from
, to
, flags
) =>
648 write
"\tRewriteCond\t\"";
655 | flag
::rest
=> (write
" [";
657 app (fn flag
=> (write
",";
662 val () = Env
.action_one
"rewriteBase"
663 ("prefix", Env
.string)
666 write
"\tRewriteBase\t\"";
670 val () = Env
.action_one
"rewriteLogLevel"
674 write
"\tRewriteLog ";
676 write
"/rewrite.log\n\tRewriteLogLevel ";
677 write (Int.toString level
);
680 val () = Env
.action_two
"alias"
681 ("from", Env
.string, "to", Env
.string)
689 val () = Env
.action_two
"scriptAlias"
690 ("from", Env
.string, "to", Env
.string)
692 (write
"\tScriptAlias\t";
698 val () = Env
.action_two
"errorDocument"
699 ("code", Env
.string, "handler", Env
.string)
700 (fn (code
, handler
) =>
702 val hasSpaces
= CharVector
.exists
Char.isSpace handler
710 write
"\tErrorDocument\t";
719 val () = Env
.action_one
"options"
720 ("options", Env
.list apache_option
)
724 | _
=> (write
"\tOptions";
725 app (fn opt
=> (write
" "; write opt
)) opts
;
728 val () = Env
.action_one
"set_options"
729 ("options", Env
.list apache_option
)
733 | _
=> (write
"\tOptions";
734 app (fn opt
=> (write
" +"; write opt
)) opts
;
737 val () = Env
.action_one
"unset_options"
738 ("options", Env
.list apache_option
)
742 | _
=> (write
"\tOptions";
743 app (fn opt
=> (write
" -"; write opt
)) opts
;
746 val () = Env
.action_one
"cgiExtension"
747 ("extension", Env
.string)
748 (fn ext
=> (write
"\tAddHandler cgi-script ";
752 val () = Env
.action_one
"directoryIndex"
753 ("filenames", Env
.list Env
.string)
755 (write
"\tDirectoryIndex";
756 app (fn opt
=> (write
" "; write opt
)) opts
;
759 val () = Env
.action_one
"serverAliasHost"
762 (write
"\tServerAlias ";
767 val () = Env
.action_one
"serverAlias"
773 val full
= host ^
"." ^ dom
775 write
"\tServerAlias ";
780 (Domain
.currentDomains ())))
782 val () = Env
.action_none
"serverAliasDefault"
786 (write
"\tServerAlias ";
790 (Domain
.currentDomains ())))
792 val authType
= fn (EVar
"basic", _
) => SOME
"basic"
793 |
(EVar
"digest", _
) => SOME
"digest"
794 |
(EVar
"kerberos", _
) => SOME
"kerberos"
797 fun allowAuthType
"kerberos" = !sslEnabled
798 | allowAuthType _
= true
800 val () = Env
.action_one
"authType"
803 if allowAuthType ty
then
804 (write
"\tAuthType ";
809 write
"\tKrbMethodNegotiate off\n\tKrbMethodK5Passwd on\n\tKrbVerifyKDC off\n\tKrbAuthRealms HCOOP.NET\n\tKrbSaveCredentials on\n"
812 print
"WARNING: Skipped Kerberos authType because this isn't an SSL vhost.\n")
814 val () = Env
.action_one
"authName"
817 (write
"\tAuthName \"";
821 val () = Env
.action_one
"authUserFile"
824 (write
"\tAuthUserFile ";
828 val () = Env
.action_none
"requireValidUser"
829 (fn () => write
"\tRequire valid-user\n")
831 val () = Env
.action_one
"requireUser"
832 ("users", Env
.list Env
.string)
836 | _
=> (write
"\tRequire user";
837 app (fn name
=> (write
" "; write name
)) names
;
840 val () = Env
.action_one
"requireGroup"
841 ("groups", Env
.list Env
.string)
845 | _
=> (write
"\tRequire group";
846 app (fn name
=> (write
" "; write name
)) names
;
849 val () = Env
.action_none
"orderAllowDeny"
850 (fn () => write
"\tOrder allow,deny\n")
852 val () = Env
.action_none
"orderDenyAllow"
853 (fn () => write
"\tOrder deny,allow\n")
855 val () = Env
.action_none
"allowFromAll"
856 (fn () => write
"\tAllow from all\n")
858 val () = Env
.action_one
"allowFrom"
859 ("entries", Env
.list Env
.string)
863 | _
=> (write
"\tAllow from";
864 app (fn name
=> (write
" "; write name
)) names
;
867 val () = Env
.action_none
"denyFromAll"
868 (fn () => write
"\tDeny from all\n")
870 val () = Env
.action_one
"denyFrom"
871 ("entries", Env
.list Env
.string)
875 | _
=> (write
"\tDeny from";
876 app (fn name
=> (write
" "; write name
)) names
;
879 val () = Env
.action_none
"satisfyAll"
880 (fn () => write
"\tSatisfy all\n")
882 val () = Env
.action_none
"satisfyAny"
883 (fn () => write
"\tSatisfy any\n")
885 val () = Env
.action_one
"forceType"
887 (fn ty
=> (write
"\tForceType ";
891 val () = Env
.action_none
"forceTypeOff"
892 (fn () => write
"\tForceType None\n")
894 val () = Env
.action_two
"action"
895 ("what", Env
.string, "how", Env
.string)
896 (fn (what
, how
) => (write
"\tAction ";
902 val () = Env
.action_one
"addDefaultCharset"
903 ("charset", Env
.string)
904 (fn ty
=> (write
"\tAddDefaultCharset ";
908 (*val () = Env
.action_one
"davSvn"
910 (fn path
=> (write
"\tDAV svn\n\tSVNPath ";
914 val () = Env
.action_one
"authzSvnAccessFile"
916 (fn path
=> (write
"\tAuthzSVNAccessFile ";
920 val () = Env
.action_none
"davFilesystem"
921 (fn path
=> write
"\tDAV filesystem\n")
923 val () = Env
.action_two
"addDescription"
924 ("description", Env
.string, "patterns", Env
.list Env
.string)
928 | _
=> (write
"\tAddDescription \"";
929 write (String.toString desc
);
931 app (fn pat
=> (write
" "; write pat
)) pats
;
934 val () = Env
.action_two
"addIcon"
935 ("icon", Env
.string, "patterns", Env
.list Env
.string)
939 | _
=> (write
"\tAddIcon \"";
942 app (fn pat
=> (write
" "; write pat
)) pats
;
945 val () = Env
.action_one
"indexOptions"
946 ("options", Env
.list autoindex_option
)
950 | _
=> (write
"\tIndexOptions";
951 app (fn (opt
, arg
) =>
954 Option
.app (fn arg
=>
955 (write
"="; write arg
)) arg
)) opts
;
958 val () = Env
.action_one
"indexIgnore"
959 ("patterns", Env
.list Env
.string)
963 | _
=> (write
"\tIndexIgnore";
964 app (fn pat
=> (write
" "; write pat
)) pats
;
967 val () = Env
.action_one
"set_indexOptions"
968 ("options", Env
.list autoindex_option
)
972 | _
=> (write
"\tIndexOptions";
973 app (fn (opt
, arg
) =>
976 Option
.app (fn arg
=>
977 (write
"="; write arg
)) arg
)) opts
;
980 val () = Env
.action_one
"unset_indexOptions"
981 ("options", Env
.list autoindex_option
)
985 | _
=> (write
"\tIndexOptions";
991 val () = Env
.action_one
"headerName"
993 (fn name
=> (write
"\tHeaderName ";
997 val () = Env
.action_one
"readmeName"
999 (fn name
=> (write
"\tReadmeName ";
1003 val () = Env
.action_two
"setEnv"
1004 ("key", Env
.string, "value", Env
.string)
1005 (fn (key
, value
) => (write
"\tSetEnv \"";
1008 write (String.translate (fn #
"\"" => "\\\""
1009 | ch
=> str ch
) value
);
1012 val () = Env
.action_one
"diskCache"
1013 ("path", Env
.string)
1014 (fn path
=> (write
"\tCacheEnable disk \"";
1018 val () = Env
.action_one
"phpVersion"
1019 ("version", php_version
)
1020 (fn version
=> (write
"\tAddHandler x-httpd-php";
1021 write (Int.toString version
);
1022 write
" .php .phtml\n"))
1024 val () = Env
.action_two
"addType"
1025 ("mime type", Env
.string, "extension", Env
.string)
1026 (fn (mt
, ext
) => (write
"\tAddType ";
1032 val filter
= fn (EVar
"includes", _
) => SOME
"INCLUDES"
1033 |
(EVar
"deflate", _
) => SOME
"DEFLATE"
1036 val () = Env
.action_two
"addOutputFilter"
1037 ("filters", Env
.list filter
, "extensions", Env
.list Env
.string)
1038 (fn (f
:: fs
, exts
as (_
:: _
)) =>
1039 (write
"\tAddOutputFilter ";
1041 app (fn f
=> (write
";"; write f
)) fs
;
1042 app (fn ext
=> (write
" "; write ext
)) exts
;
1046 val () = Domain
.registerResetLocal (fn () =>
1047 ignore (OS
.Process
.system (Config
.rm ^
" -rf /var/domtool/vhosts/*")))
1049 val () = Domain
.registerDescriber (Domain
.considerAll
1050 [Domain
.Extension
{extension
= "vhost",
1051 heading
= fn host
=> "Web vhost " ^ host ^
":"},
1052 Domain
.Extension
{extension
= "vhost_ssl",
1053 heading
= fn host
=> "SSL web vhost " ^ host ^
":"}])
1055 val () = Env
.action_none
"testNoHtaccess"
1056 (fn path
=> write
"\tAllowOverride None\n")