From 55d4a2686f9334ccd03602c86e43395acef9537d Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 10 Apr 2007 02:22:51 +0000 Subject: [PATCH] Initial Apache 1.3 support --- configDefault/apache.cfg | 8 +++++-- configDefault/apache.csg | 8 +++++-- scripts/domtool-publish | 11 +++++++++ scripts/domtool-reset-global | 10 ++++---- src/compat_mlton.sml | 3 +-- src/plugins/apache.sml | 45 +++++++++++++++++++++++++----------- 6 files changed, 60 insertions(+), 25 deletions(-) diff --git a/configDefault/apache.cfg b/configDefault/apache.cfg index 4b625bb..33ca610 100644 --- a/configDefault/apache.cfg +++ b/configDefault/apache.cfg @@ -4,10 +4,14 @@ val reload = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache" val down = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache-down" val undown = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache-undown" +val reload1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3" +val down1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3-down" +val undown1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3-undown" + val confDir = "/var/domtool/vhosts" -val webNodes_all = ["mire"] -val webNodes_admin = ["deleuze"] +val webNodes_all = [("mire", true)] +val webNodes_admin = [("deleuze", false)] val webNodes_default = ["mire"] diff --git a/configDefault/apache.csg b/configDefault/apache.csg index 28188ac..0491805 100644 --- a/configDefault/apache.csg +++ b/configDefault/apache.csg @@ -4,10 +4,14 @@ signature APACHE_CONFIG = sig val down : string val undown : string + val reload1 : string + val down1 : string + val undown1 : string + val confDir : string - val webNodes_all : string list - val webNodes_admin : string list + val webNodes_all : (string * bool) list + val webNodes_admin : (string * bool) list val webNodes_default : string list val proxyTargets : string list diff --git a/scripts/domtool-publish b/scripts/domtool-publish index b84f1df..acfbe6d 100755 --- a/scripts/domtool-publish +++ b/scripts/domtool-publish @@ -25,6 +25,17 @@ case $1 in /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/ /etc/init.d/apache2 start ;; + apache1.3) + /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/ + /etc/init.d/apache reload + ;; + apache1.3-down) + /etc/init.d/apache stop + ;; + apache1.3-undown) + /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/ + /etc/init.d/apache start + ;; bind) /usr/bin/rsync -r --delete /var/domtool/zones/ /etc/bind/zones/ /bin/cp /var/domtool/named.conf.local /etc/bind/ diff --git a/scripts/domtool-reset-global b/scripts/domtool-reset-global index d862feb..748f9d9 100644 --- a/scripts/domtool-reset-global +++ b/scripts/domtool-reset-global @@ -11,8 +11,8 @@ mkdir ~domtool/webalizer/output mkdir ~domtool/webalizer/output/deleuze mkdir ~domtool/webalizer/output/mire -for usr in `ls /afs/hcoop/usr` -do - rm -rf /afs/hcoop/usr/$usr/apache/log/mire/* - rm -rf /afs/hcoop/usr/$usr/apache/log/deleuze/* -done +#for usr in `ls /afs/hcoop/usr` +#do +# rm -rf /afs/hcoop/usr/$usr/apache/log/mire/* +# rm -rf /afs/hcoop/usr/$usr/apache/log/deleuze/* +#done diff --git a/src/compat_mlton.sml b/src/compat_mlton.sml index 7b28b7e..9a6b60f 100644 --- a/src/compat_mlton.sml +++ b/src/compat_mlton.sml @@ -26,6 +26,5 @@ end val _ = let open MLton.Signal in - setHandler (Posix.Signal.pipe, Handler.ignore); - setHandler (Posix.Signal.chld, Handler.ignore) + setHandler (Posix.Signal.pipe, Handler.ignore) end diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index 7183bcb..4ea0389 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -25,9 +25,9 @@ open Ast val _ = Env.type_one "web_node" Env.string (fn node => - List.exists (fn x => x = node) Config.Apache.webNodes_all + List.exists (fn (x, _) => x = node) Config.Apache.webNodes_all orelse (Domain.hasPriv "www" - andalso List.exists (fn x => x = node) Config.Apache.webNodes_admin)) + andalso List.exists (fn (x, _) => x = node) Config.Apache.webNodes_admin)) val _ = Env.registerFunction ("web_node_to_node", fn [e] => SOME e @@ -225,6 +225,17 @@ fun findVhostUser fname = before TextIO.closeIn inf end handle _ => NONE +val webNodes_full = Config.Apache.webNodes_all @ Config.Apache.webNodes_admin + +fun isVersion1 node = + List.exists (fn x => x = (node, true)) webNodes_full + +fun imVersion1 () = isVersion1 (Slave.hostname ()) + +fun down () = if imVersion1 () then Config.Apache.down1 else Config.Apache.down +fun undown () = if imVersion1 () then Config.Apache.undown1 else Config.Apache.undown +fun reload () = if imVersion1 () then Config.Apache.reload1 else Config.Apache.reload + val () = Slave.registerFileHandler (fn fs => let val spl = OS.Path.splitDirFile (#file fs) @@ -271,7 +282,7 @@ val () = Slave.registerFileHandler (fn fs => (if !logDeleted then () else - (ignore (OS.Process.system Config.Apache.down); + (ignore (OS.Process.system (down ())); logDeleted := true); ignore (OS.Process.system (Config.rm ^ " -rf " @@ -308,7 +319,7 @@ val () = Slave.registerFileHandler (fn fs => if !logDeleted then () else - (ignore (OS.Process.system Config.Apache.down); + (ignore (OS.Process.system (down ())); logDeleted := true); ignore (OS.Process.system (Config.rm ^ " -rf " @@ -329,7 +340,7 @@ val () = Slave.registerFileHandler (fn fs => val () = Slave.registerPostHandler (fn () => (if !vhostsChanged then - Slave.shellF ([if !logDeleted then Config.Apache.undown else Config.Apache.reload], + Slave.shellF ([if !logDeleted then undown () else reload ()], fn cl => "Error reloading Apache with " ^ cl) else ())) @@ -416,19 +427,25 @@ val () = Env.containerV_one "vhost" TextIO.output (file, "/"); TextIO.output (file, vhostId); TextIO.output (file, "/access.log combined\n"); + TextIO.output (file, "\tServerName "); + TextIO.output (file, fullHost); + if suexec then + if isVersion1 node then + (TextIO.output (file, "\n\tUser "); + TextIO.output (file, user); + TextIO.output (file, "\n\tGroup "); + TextIO.output (file, group)) + else + (TextIO.output (file, "\n\tSuexecUserGroup "); + TextIO.output (file, user); + TextIO.output (file, " "); + TextIO.output (file, group)) + else + (); (Domain.homedirOf user ^ "/apache/log/" ^ node ^ "/" ^ vhostId, file) end) nodes; - write "\tServerName "; - write fullHost; - if suexec then - (write "\n\tSuexecUserGroup "; - write user; - write " "; - write group) - else - (); write "\n\tDocumentRoot "; write docroot; write "\n\tServerAdmin "; -- 2.20.1