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
=>
73 val rest
= String.concatWith
":" rest
75 CharVector
.all (fn ch
=> Char.isPrint ch
andalso not (Char.isSpace ch
)
76 andalso ch
<> #
"\"" andalso ch
<> #
"'") rest
77 andalso case String.fields (fn ch
=> ch
= #
"/") rest
of
79 (case Int.fromString port
of
81 | SOME n
=> n
> 1024 orelse default ())
87 val _
= Env
.type_one
"rewrite_arg"
89 (CharVector
.all
Char.isAlphaNum
)
91 val _
= Env
.type_one
"suexec_flag"
93 (fn b
=> b
orelse Domain
.hasPriv
"www")
95 val _
= Env
.type_one
"regexp"
100 size s
> 0 andalso size s
< 1000 andalso CharVector
.all
101 (fn ch
=> Char.isAlphaNum ch
108 val _
= Env
.type_one
"location"
112 fun validCert s
= Acl
.query
{user
= Domain
.getUser (),
116 val _
= Env
.type_one
"ssl_cert_path"
120 fun ssl e
= case e
of
121 (EVar
"no_ssl", _
) => SOME NONE
122 |
(EApp ((EVar
"use_cert", _
), s
), _
) => Option
.map
SOME (Env
.string s
)
125 fun validExtension s
=
128 andalso CharVector
.all (fn ch
=> Char.isAlphaNum ch
orelse ch
= #
"_") s
130 val _
= Env
.type_one
"file_extension"
134 val defaults
= [("WebPlaces",
135 (TList (TBase
"web_place", dl
), dl
),
136 (fn () => (EList (map webPlaceDefault Config
.Apache
.webNodes_default
), dl
))),
139 (fn () => (EVar
"no_ssl", dl
))),
141 (TBase
"your_user", dl
),
142 (fn () => (EString (Domain
.getUser ()), dl
))),
144 (TBase
"your_group", dl
),
145 (fn () => (EString
"nogroup", dl
))),
147 (TBase
"your_path", dl
),
148 (fn () => (EString (Domain
.homedir () ^
"/" ^ Config
.Apache
.public_html
), dl
))),
151 (fn () => (EString (Domain
.getUser () ^
"@" ^ Config
.defaultDomain
), dl
))),
153 (TBase
"suexec_flag", dl
),
154 (fn () => (EVar
"true", dl
))),
156 (TBase
"php_version", dl
),
157 (fn () => (EVar
"php4", dl
)))]
159 val () = app Defaults
.registerDefault defaults
161 val redirect_code
= fn (EVar
"temp", _
) => SOME
"temp"
162 |
(EVar
"permanent", _
) => SOME
"permanent"
163 |
(EVar
"seeother", _
) => SOME
"seeother"
164 |
(EVar
"redir300", _
) => SOME
"300"
165 |
(EVar
"redir301", _
) => SOME
"301"
166 |
(EVar
"redir302", _
) => SOME
"302"
167 |
(EVar
"redir303", _
) => SOME
"303"
168 |
(EVar
"redir304", _
) => SOME
"304"
169 |
(EVar
"redir305", _
) => SOME
"305"
170 |
(EVar
"redir307", _
) => SOME
"307"
173 val flag
= fn (EVar
"redirect", _
) => SOME
"R"
174 |
(EVar
"forbidden", _
) => SOME
"F"
175 |
(EVar
"gone", _
) => SOME
"G"
176 |
(EVar
"last", _
) => SOME
"L"
177 |
(EVar
"chain", _
) => SOME
"C"
178 |
(EVar
"nosubreq", _
) => SOME
"NS"
179 |
(EVar
"nocase", _
) => SOME
"NC"
180 |
(EVar
"qsappend", _
) => SOME
"QSA"
181 |
(EVar
"noescape", _
) => SOME
"NE"
182 |
(EVar
"passthrough", _
) => SOME
"PT"
183 |
(EApp ((EVar
"mimeType", _
), e
), _
) =>
184 Option
.map (fn s
=> "T=" ^ s
) (Env
.string e
)
185 |
(EApp ((EVar
"redirectWith", _
), e
), _
) =>
186 Option
.map (fn s
=> "R=" ^ s
) (redirect_code e
)
187 |
(EApp ((EVar
"skip", _
), e
), _
) =>
188 Option
.map (fn n
=> "S=" ^
Int.toString n
) (Env
.int e
)
189 |
(EApp ((EApp ((EVar
"env", _
), e1
), _
), e2
), _
) =>
190 (case Env
.string e1
of
192 | SOME s1
=> Option
.map (fn s2
=> "E=" ^ s1 ^
":" ^ s2
)
197 val cond_flag
= fn (EVar
"cond_nocase", _
) => SOME
"NC"
198 |
(EVar
"ornext", _
) => SOME
"OR"
201 val apache_option
= fn (EVar
"execCGI", _
) => SOME
"ExecCGI"
202 |
(EVar
"includesNOEXEC", _
) => SOME
"IncludesNOEXEC"
203 |
(EVar
"indexes", _
) => SOME
"Indexes"
204 |
(EVar
"followSymLinks", _
) => SOME
"FollowSymLinks"
207 val autoindex_width
= fn (EVar
"autofit", _
) => SOME
"*"
208 |
(EApp ((EVar
"characters", _
), n
), _
) =>
209 Option
.map
Int.toString (Env
.int n
)
212 val autoindex_option
= fn (EApp ((EVar
"descriptionWidth", _
), w
), _
) =>
213 Option
.map (fn w
=> ("DescriptionWidth", SOME w
))
215 |
(EVar
"fancyIndexing", _
) => SOME ("FancyIndexing", NONE
)
216 |
(EVar
"foldersFirst", _
) => SOME ("FoldersFirst", NONE
)
217 |
(EVar
"htmlTable", _
) => SOME ("HTMLTable", NONE
)
218 |
(EVar
"iconsAreLinks", _
) => SOME ("IconsAreLinks", NONE
)
219 |
(EApp ((EVar
"iconHeight", _
), n
), _
) =>
220 Option
.map (fn w
=> ("IconHeight", SOME (Int.toString w
)))
222 |
(EApp ((EVar
"iconWidth", _
), n
), _
) =>
223 Option
.map (fn w
=> ("IconWidth", SOME (Int.toString w
)))
225 |
(EVar
"ignoreCase", _
) => SOME ("IgnoreCase", NONE
)
226 |
(EVar
"ignoreClient", _
) => SOME ("IgnoreClient", NONE
)
227 |
(EApp ((EVar
"nameWidth", _
), w
), _
) =>
228 Option
.map (fn w
=> ("NameWidth", SOME w
))
230 |
(EVar
"scanHtmlTitles", _
) => SOME ("ScanHTMLTitles", NONE
)
231 |
(EVar
"suppressColumnSorting", _
) => SOME ("SuppressColumnSorting", NONE
)
232 |
(EVar
"suppressDescription", _
) => SOME ("SuppressDescription", NONE
)
233 |
(EVar
"suppressHtmlPreamble", _
) => SOME ("SuppressHTMLPreamble", NONE
)
234 |
(EVar
"suppressIcon", _
) => SOME ("SuppressIcon", NONE
)
235 |
(EVar
"suppressLastModified", _
) => SOME ("SuppressLastModified", NONE
)
236 |
(EVar
"suppressRules", _
) => SOME ("SuppressRules", NONE
)
237 |
(EVar
"suppressSize", _
) => SOME ("SuppressSize", NONE
)
238 |
(EVar
"trackModified", _
) => SOME ("TrackModified", NONE
)
239 |
(EVar
"versionSort", _
) => SOME ("VersionSort", NONE
)
240 |
(EVar
"xhtml", _
) => SOME ("XHTML", NONE
)
244 val vhostsChanged
= ref
false
245 val logDeleted
= ref
false
246 val delayedLogMoves
= ref (fn () => ())
248 val () = Slave
.registerPreHandler
249 (fn () => (vhostsChanged
:= false;
251 delayedLogMoves
:= (fn () => print
"Executing delayed log moves/deletes.\n")))
253 fun findVhostUser fname
=
255 val inf
= TextIO.openIn fname
258 case TextIO.inputLine inf
of
261 if String.isPrefix
"# Owner: " line
then
262 case String.tokens
Char.isSpace line
of
263 [_
, _
, user
] => SOME user
269 before TextIO.closeIn inf
272 val webNodes_full
= Config
.Apache
.webNodes_all @ Config
.Apache
.webNodes_admin
274 fun isVersion1 node
=
275 List.exists (fn (n
, {version
= ConfigTypes
.APACHE_1_3
, ...}) => n
= node
276 | _
=> false) webNodes_full
278 fun imVersion1 () = isVersion1 (Slave
.hostname ())
281 List.exists (fn (n
, {auth
= ConfigTypes
.MOD_WAKLOG
, ...}) => n
= node
282 | _
=> false) webNodes_full
284 fun down () = if imVersion1 () then Config
.Apache
.down1
else Config
.Apache
.down
285 fun undown () = if imVersion1 () then Config
.Apache
.undown1
else Config
.Apache
.undown
286 fun reload () = if imVersion1 () then Config
.Apache
.reload1
else Config
.Apache
.reload
287 fun fixperms () = if imVersion1 () then Config
.Apache
.fixperms1
else Config
.Apache
.fixperms
289 fun logDir
{user
, node
, vhostId
} =
290 String.concat
[Config
.Apache
.logDirOf (isVersion1 node
) user
,
296 fun realLogDir
{user
, node
, vhostId
} =
297 String.concat
[Config
.Apache
.realLogDirOf user
,
303 val () = Slave
.registerFileHandler (fn fs
=>
305 val spl
= OS
.Path
.splitDirFile (#file fs
)
307 if String.isSuffix
".vhost" (#file spl
)
308 orelse String.isSuffix
".vhost_ssl" (#file spl
) then let
309 val realVhostFile
= OS
.Path
.joinDirFile
310 {dir
= Config
.Apache
.confDir
,
313 val user
= findVhostUser (#file fs
)
314 val oldUser
= case #action fs
of
315 Slave
.Delete
false => user
316 | _
=> findVhostUser realVhostFile
318 if (oldUser
= NONE
andalso #action fs
<> Slave
.Add
)
319 orelse (user
= NONE
andalso not (Slave
.isDelete (#action fs
))) then
320 print ("Can't find user in " ^ #file fs ^
" or " ^ realVhostFile ^
"! Taking no action.\n")
323 val vhostId
= if OS
.Path
.ext (#file spl
) = SOME
"vhost_ssl" then
324 OS
.Path
.base (#file spl
) ^
".ssl"
326 OS
.Path
.base (#file spl
)
328 fun realLogDir user
=
329 logDir
{user
= valOf user
,
330 node
= Slave
.hostname (),
335 {dir
= Config
.Apache
.backupLogDirOf
336 (isVersion1 (Slave
.hostname ())),
339 vhostsChanged
:= true;
343 val ldir
= realLogDir oldUser
344 val dlm
= !delayedLogMoves
349 ((*ignore (OS
.Process
.system (down ()));*)
350 ignore (OS
.Process
.system (fixperms ()));
352 ignore (OS
.Process
.system (Config
.rm
355 delayedLogMoves
:= (fn () => (dlm ();
356 Slave
.moveDirCreate
{from
= ldir
,
357 to
= backupLogs ()}))
361 val rld
= realLogDir user
363 ignore (OS
.Process
.system (Config
.cp
368 if Posix
.FileSys
.access (rld
, []) then
371 Slave
.moveDirCreate
{from
= backupLogs (),
376 (ignore (OS
.Process
.system (Config
.cp
381 if user
<> oldUser
then
383 val old
= realLogDir oldUser
384 val rld
= realLogDir user
386 val dlm
= !delayedLogMoves
391 ((*ignore (OS
.Process
.system (down ()));*)
393 delayedLogMoves
:= (fn () => (dlm ();
394 ignore (OS
.Process
.system (Config
.rm
396 ^ realLogDir oldUser
))));
397 if Posix
.FileSys
.access (rld
, []) then
410 val () = Slave
.registerPostHandler
412 (if !vhostsChanged
then
413 (Slave
.shellF ([reload ()],
414 fn cl
=> "Error reloading Apache with " ^ cl
);
415 if !logDeleted
then !delayedLogMoves () else ())
419 val vhostFiles
: (string * TextIO.outstream
) list ref
= ref
[]
420 fun write
' s
= app (fn (node
, file
) => TextIO.output (file
, s node
)) (!vhostFiles
)
421 fun write s
= app (fn (_
, file
) => TextIO.output (file
, s
)) (!vhostFiles
)
423 val rewriteEnabled
= ref
false
424 val localRewriteEnabled
= ref
false
425 val currentVhost
= ref
""
426 val currentVhostId
= ref
""
427 val sslEnabled
= ref
false
429 val pre
= ref (fn _
: {user
: string, nodes
: string list
, id
: string, hostname
: string} => ())
434 pre
:= (fn x
=> (old x
; f x
))
437 val post
= ref (fn () => ())
442 post
:= (fn () => (old (); f ()))
446 fun doPost () = !post ()
448 val aliaser
= ref (fn _
: string => ())
449 fun registerAliaser f
=
453 aliaser
:= (fn x
=> (old x
; f x
))
456 fun vhostPost () = (!post ();
457 write
"</VirtualHost>\n";
458 app (TextIO.closeOut
o #
2) (!vhostFiles
))
460 val php_version
= fn (EVar
"php4", _
) => SOME
4
461 |
(EVar
"php5", _
) => SOME
5
464 fun vhostBody (env
, makeFullHost
) =
466 val places
= Env
.env (Env
.list webPlace
) (env
, "WebPlaces")
468 val ssl
= Env
.env
ssl (env
, "SSL")
469 val user
= Env
.env Env
.string (env
, "User")
470 val group
= Env
.env Env
.string (env
, "Group")
471 val docroot
= Env
.env Env
.string (env
, "DocumentRoot")
472 val sadmin
= Env
.env Env
.string (env
, "ServerAdmin")
473 val suexec
= Env
.env Env
.bool (env
, "SuExec")
474 val php
= Env
.env
php_version (env
, "PhpVersion")
476 val fullHost
= makeFullHost (Domain
.currentDomain ())
477 val vhostId
= fullHost ^
(if Option
.isSome ssl
then ".ssl" else "")
478 val confFile
= fullHost ^
(if Option
.isSome ssl
then ".vhost_ssl" else ".vhost")
480 currentVhost
:= fullHost
;
481 currentVhostId
:= vhostId
;
482 sslEnabled
:= Option
.isSome ssl
;
484 rewriteEnabled
:= false;
485 localRewriteEnabled
:= false;
486 vhostFiles
:= map (fn (node
, ip
) =>
488 val file
= Domain
.domainFile
{node
= node
,
491 val ld
= logDir
{user
= user
, node
= node
, vhostId
= vhostId
}
493 TextIO.output (file
, "# Owner: ");
494 TextIO.output (file
, user
);
495 TextIO.output (file
, "\n<VirtualHost ");
496 TextIO.output (file
, ip
);
497 TextIO.output (file
, ":");
498 TextIO.output (file
, case ssl
of
501 TextIO.output (file
, ">\n");
502 TextIO.output (file
, "\tErrorLog ");
503 TextIO.output (file
, ld
);
504 TextIO.output (file
, "/error.log\n\tCustomLog ");
505 TextIO.output (file
, ld
);
506 TextIO.output (file
, "/access.log combined\n");
507 TextIO.output (file
, "\tServerName ");
508 TextIO.output (file
, fullHost
);
510 (fn dom
=> (TextIO.output (file
, "\n\tServerAlias ");
511 TextIO.output (file
, makeFullHost dom
)))
512 (Domain
.currentAliasDomains ());
515 if isVersion1 node
then
516 (TextIO.output (file
, "\n\tUser ");
517 TextIO.output (file
, user
);
518 TextIO.output (file
, "\n\tGroup ");
519 TextIO.output (file
, group
))
521 (TextIO.output (file
, "\n\tSuexecUserGroup ");
522 TextIO.output (file
, user
);
523 TextIO.output (file
, " ");
524 TextIO.output (file
, group
);
525 TextIO.output (file
, "\n\tsuPHP_UserGroup ");
526 TextIO.output (file
, user
);
527 TextIO.output (file
, " ");
528 TextIO.output (file
, group
))
532 if isWaklog node
then
533 (TextIO.output (file
, "\n\tWaklogEnabled on\n\tWaklogLocationPrincipal ");
534 TextIO.output (file
, user
);
535 TextIO.output (file
, "/daemon@HCOOP.NET /etc/keytabs/user.daemon/");
536 TextIO.output (file
, user
))
540 TextIO.output (file
, "\n\tDAVLockDB /var/lock/apache2/dav/");
541 TextIO.output (file
, user
);
542 TextIO.output (file
, "/DAVLock");
544 if php
<> Config
.Apache
.defaultPhpVersion
then
545 (TextIO.output (file
, "\n\tAddHandler x-httpd-php");
546 TextIO.output (file
, Int.toString php
);
547 TextIO.output (file
, " .php .phtml"))
554 write
"\n\tDocumentRoot ";
556 write
"\n\tServerAdmin ";
560 (write
"\n\tSSLEngine on\n\tSSLCertificateFile ";
564 !pre
{user
= user
, nodes
= map #
1 places
, id
= vhostId
, hostname
= fullHost
};
565 app (fn dom
=> !aliaser (makeFullHost dom
)) (Domain
.currentAliasDomains ())
568 val () = Env
.containerV_one
"vhost"
570 (fn (env
, host
) => vhostBody (env
, fn dom
=> host ^
"." ^ dom
),
573 val () = Env
.containerV_none
"vhostDefault"
574 (fn env
=> vhostBody (env
, fn dom
=> dom
),
577 val inLocal
= ref
false
579 val () = Env
.container_one
"location"
580 ("prefix", Env
.string)
582 (write
"\t<Location ";
586 fn () => (write
"\t</Location>\n";
588 localRewriteEnabled
:= false))
590 val () = Env
.container_one
"directory"
591 ("directory", Env
.string)
593 (write
"\t<Directory ";
597 fn () => (write
"\t</Directory>\n";
599 localRewriteEnabled
:= false))
601 val () = Env
.container_one
"filesMatch"
602 ("regexp", Env
.string)
604 (write
"\t<FilesMatch \"";
607 fn () => (write
"\t</FilesMatch>\n";
608 localRewriteEnabled
:= false))
610 fun checkRewrite () =
612 if !localRewriteEnabled
then
615 (write
"\tRewriteEngine on\n";
616 localRewriteEnabled
:= true)
617 else if !rewriteEnabled
then
620 (write
"\tRewriteEngine on\n";
621 rewriteEnabled
:= true)
623 val () = Env
.action_three
"localProxyRewrite"
624 ("from", Env
.string, "to", Env
.string, "port", Env
.int)
625 (fn (from
, to
, port
) =>
627 write
"\tRewriteRule\t\"";
629 write
"\"\thttp://localhost:";
630 write (Int.toString port
);
635 val () = Env
.action_two
"proxyPass"
636 ("from", Env
.string, "to", Env
.string)
638 (write
"\tProxyPass\t";
644 val () = Env
.action_two
"proxyPassReverse"
645 ("from", Env
.string, "to", Env
.string)
647 (write
"\tProxyPassReverse\t";
653 val () = Env
.action_three
"rewriteRule"
654 ("from", Env
.string, "to", Env
.string, "flags", Env
.list flag
)
655 (fn (from
, to
, flags
) =>
657 write
"\tRewriteRule\t\"";
664 | flag
::rest
=> (write
" [";
666 app (fn flag
=> (write
",";
671 val () = Env
.action_three
"rewriteCond"
672 ("test", Env
.string, "pattern", Env
.string, "flags", Env
.list cond_flag
)
673 (fn (from
, to
, flags
) =>
675 write
"\tRewriteCond\t\"";
682 | flag
::rest
=> (write
" [";
684 app (fn flag
=> (write
",";
689 val () = Env
.action_one
"rewriteBase"
690 ("prefix", Env
.string)
693 write
"\tRewriteBase\t\"";
697 val () = Env
.action_one
"rewriteLogLevel"
701 write
"\tRewriteLog ";
703 write
"/rewrite.log\n\tRewriteLogLevel ";
704 write (Int.toString level
);
707 val () = Env
.action_two
"alias"
708 ("from", Env
.string, "to", Env
.string)
716 val () = Env
.action_two
"scriptAlias"
717 ("from", Env
.string, "to", Env
.string)
719 (write
"\tScriptAlias\t";
725 val () = Env
.action_two
"errorDocument"
726 ("code", Env
.string, "handler", Env
.string)
727 (fn (code
, handler
) =>
729 val hasSpaces
= CharVector
.exists
Char.isSpace handler
737 write
"\tErrorDocument\t";
746 val () = Env
.action_one
"options"
747 ("options", Env
.list apache_option
)
751 | _
=> (write
"\tOptions";
752 app (fn opt
=> (write
" "; write opt
)) opts
;
755 val () = Env
.action_one
"set_options"
756 ("options", Env
.list apache_option
)
760 | _
=> (write
"\tOptions";
761 app (fn opt
=> (write
" +"; write opt
)) opts
;
764 val () = Env
.action_one
"unset_options"
765 ("options", Env
.list apache_option
)
769 | _
=> (write
"\tOptions";
770 app (fn opt
=> (write
" -"; write opt
)) opts
;
773 val () = Env
.action_one
"cgiExtension"
774 ("extension", Env
.string)
775 (fn ext
=> (write
"\tAddHandler cgi-script ";
779 val () = Env
.action_one
"directoryIndex"
780 ("filenames", Env
.list Env
.string)
782 (write
"\tDirectoryIndex";
783 app (fn opt
=> (write
" "; write opt
)) opts
;
786 val () = Env
.action_one
"serverAliasHost"
789 (write
"\tServerAlias ";
794 val () = Env
.action_one
"serverAlias"
800 val full
= host ^
"." ^ dom
802 write
"\tServerAlias ";
807 (Domain
.currentDomains ())))
809 val () = Env
.action_none
"serverAliasDefault"
813 (write
"\tServerAlias ";
817 (Domain
.currentDomains ())))
819 val authType
= fn (EVar
"basic", _
) => SOME
"basic"
820 |
(EVar
"digest", _
) => SOME
"digest"
821 |
(EVar
"kerberos", _
) => SOME
"kerberos"
824 fun allowAuthType
"kerberos" = !sslEnabled
825 | allowAuthType _
= true
827 val () = Env
.action_one
"authType"
830 if allowAuthType ty
then
831 (write
"\tAuthType ";
836 write
"\tKrbMethodNegotiate off\n\tKrbMethodK5Passwd on\n\tKrbVerifyKDC off\n\tKrbAuthRealms HCOOP.NET\n\tKrbSaveCredentials on\n"
839 print
"WARNING: Skipped Kerberos authType because this isn't an SSL vhost.\n")
841 val () = Env
.action_one
"authName"
844 (write
"\tAuthName \"";
848 val () = Env
.action_one
"authUserFile"
851 (write
"\tAuthUserFile ";
855 val () = Env
.action_none
"requireValidUser"
856 (fn () => write
"\tRequire valid-user\n")
858 val () = Env
.action_one
"requireUser"
859 ("users", Env
.list Env
.string)
863 | _
=> (write
"\tRequire user";
864 app (fn name
=> (write
" "; write name
)) names
;
867 val () = Env
.action_one
"requireGroup"
868 ("groups", Env
.list Env
.string)
872 | _
=> (write
"\tRequire group";
873 app (fn name
=> (write
" "; write name
)) names
;
876 val () = Env
.action_none
"orderAllowDeny"
877 (fn () => write
"\tOrder allow,deny\n")
879 val () = Env
.action_none
"orderDenyAllow"
880 (fn () => write
"\tOrder deny,allow\n")
882 val () = Env
.action_none
"allowFromAll"
883 (fn () => write
"\tAllow from all\n")
885 val () = Env
.action_one
"allowFrom"
886 ("entries", Env
.list Env
.string)
890 | _
=> (write
"\tAllow from";
891 app (fn name
=> (write
" "; write name
)) names
;
894 val () = Env
.action_none
"denyFromAll"
895 (fn () => write
"\tDeny from all\n")
897 val () = Env
.action_one
"denyFrom"
898 ("entries", Env
.list Env
.string)
902 | _
=> (write
"\tDeny from";
903 app (fn name
=> (write
" "; write name
)) names
;
906 val () = Env
.action_none
"satisfyAll"
907 (fn () => write
"\tSatisfy all\n")
909 val () = Env
.action_none
"satisfyAny"
910 (fn () => write
"\tSatisfy any\n")
912 val () = Env
.action_one
"forceType"
914 (fn ty
=> (write
"\tForceType ";
918 val () = Env
.action_none
"forceTypeOff"
919 (fn () => write
"\tForceType None\n")
921 val () = Env
.action_two
"action"
922 ("what", Env
.string, "how", Env
.string)
923 (fn (what
, how
) => (write
"\tAction ";
929 val () = Env
.action_one
"addDefaultCharset"
930 ("charset", Env
.string)
931 (fn ty
=> (write
"\tAddDefaultCharset ";
935 (*val () = Env
.action_one
"davSvn"
937 (fn path
=> (write
"\tDAV svn\n\tSVNPath ";
941 val () = Env
.action_one
"authzSvnAccessFile"
943 (fn path
=> (write
"\tAuthzSVNAccessFile ";
947 val () = Env
.action_none
"davFilesystem"
948 (fn path
=> write
"\tDAV filesystem\n")
950 val () = Env
.action_two
"addDescription"
951 ("description", Env
.string, "patterns", Env
.list Env
.string)
955 | _
=> (write
"\tAddDescription \"";
956 write (String.toString desc
);
958 app (fn pat
=> (write
" "; write pat
)) pats
;
961 val () = Env
.action_two
"addIcon"
962 ("icon", Env
.string, "patterns", Env
.list Env
.string)
966 | _
=> (write
"\tAddIcon \"";
969 app (fn pat
=> (write
" "; write pat
)) pats
;
972 val () = Env
.action_one
"indexOptions"
973 ("options", Env
.list autoindex_option
)
977 | _
=> (write
"\tIndexOptions";
978 app (fn (opt
, arg
) =>
981 Option
.app (fn arg
=>
982 (write
"="; write arg
)) arg
)) opts
;
985 val () = Env
.action_one
"indexIgnore"
986 ("patterns", Env
.list Env
.string)
990 | _
=> (write
"\tIndexIgnore";
991 app (fn pat
=> (write
" "; write pat
)) pats
;
994 val () = Env
.action_one
"set_indexOptions"
995 ("options", Env
.list autoindex_option
)
999 | _
=> (write
"\tIndexOptions";
1000 app (fn (opt
, arg
) =>
1003 Option
.app (fn arg
=>
1004 (write
"="; write arg
)) arg
)) opts
;
1007 val () = Env
.action_one
"unset_indexOptions"
1008 ("options", Env
.list autoindex_option
)
1012 | _
=> (write
"\tIndexOptions";
1018 val () = Env
.action_one
"headerName"
1019 ("name", Env
.string)
1020 (fn name
=> (write
"\tHeaderName ";
1024 val () = Env
.action_one
"readmeName"
1025 ("name", Env
.string)
1026 (fn name
=> (write
"\tReadmeName ";
1030 val () = Env
.action_two
"setEnv"
1031 ("key", Env
.string, "value", Env
.string)
1032 (fn (key
, value
) => (write
"\tSetEnv \"";
1035 write (String.translate (fn #
"\"" => "\\\""
1036 | ch
=> str ch
) value
);
1039 val () = Env
.action_one
"diskCache"
1040 ("path", Env
.string)
1041 (fn path
=> (write
"\tCacheEnable disk \"";
1045 val () = Env
.action_one
"phpVersion"
1046 ("version", php_version
)
1047 (fn version
=> (write
"\tAddHandler x-httpd-php";
1048 write (Int.toString version
);
1049 write
" .php .phtml\n"))
1051 val () = Env
.action_two
"addType"
1052 ("mime type", Env
.string, "extension", Env
.string)
1053 (fn (mt
, ext
) => (write
"\tAddType ";
1059 val filter
= fn (EVar
"includes", _
) => SOME
"INCLUDES"
1060 |
(EVar
"deflate", _
) => SOME
"DEFLATE"
1063 val () = Env
.action_two
"addOutputFilter"
1064 ("filters", Env
.list filter
, "extensions", Env
.list Env
.string)
1065 (fn (f
:: fs
, exts
as (_
:: _
)) =>
1066 (write
"\tAddOutputFilter ";
1068 app (fn f
=> (write
";"; write f
)) fs
;
1069 app (fn ext
=> (write
" "; write ext
)) exts
;
1073 val () = Domain
.registerResetLocal (fn () =>
1074 ignore (OS
.Process
.system (Config
.rm ^
" -rf /var/domtool/vhosts/*")))
1076 val () = Domain
.registerDescriber (Domain
.considerAll
1077 [Domain
.Extension
{extension
= "vhost",
1078 heading
= fn host
=> "Web vhost " ^ host ^
":"},
1079 Domain
.Extension
{extension
= "vhost_ssl",
1080 heading
= fn host
=> "SSL web vhost " ^ host ^
":"}])
1082 val () = Env
.action_none
"testNoHtaccess"
1083 (fn path
=> write
"\tAllowOverride None\n")