First support for new Apache log scheme
authorAdam Chlipala <adamc@hcoop.net>
Sat, 21 Apr 2007 22:23:28 +0000 (22:23 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sat, 21 Apr 2007 22:23:28 +0000 (22:23 +0000)
configDefault/apache.cfg
configDefault/apache.csg
src/plugins/apache.sml
src/slave.sig
src/slave.sml

index 7181b49..4ef970b 100644 (file)
@@ -22,4 +22,16 @@ val proxyTargets = ["http://hcoop.net/cgi-bin/mailman",
 
 val public_html = "public_html"
 
+fun logDirOf user =
+    if size user < 2 then
+       "/bad_username"
+    else
+       String.concat ["/var/log/apache/user/",
+                      String.substring (user, 0, 1),
+                      "/",
+                      String.substring (user, 0, 2),
+                      "/",
+                      user,
+                      "/apache/log"]
+
 end
index b0b8d11..63adf00 100644 (file)
@@ -18,4 +18,6 @@ signature APACHE_CONFIG = sig
 
     val        public_html : string
 
+    val logDirOf : string -> string
+
 end
index 30bc4fd..31fda50 100644 (file)
@@ -242,8 +242,8 @@ fun undown () = if imVersion1 () then Config.Apache.undown1 else Config.Apache.u
 fun reload () = if imVersion1 () then Config.Apache.reload1 else Config.Apache.reload
 
 fun logDir {user, node, vhostId} =
-    String.concat [Domain.homedirOf user,
-                  "/apache/log/",
+    String.concat [Config.Apache.logDirOf user,
+                  "/",
                   node,
                   "/",
                   vhostId]
@@ -302,7 +302,7 @@ val () = Slave.registerFileHandler (fn fs =>
                                                                   if Posix.FileSys.access (rld, []) then
                                                                       ()
                                                                   else
-                                                                      OS.FileSys.mkDir rld
+                                                                      Slave.mkDirAll rld
                                                               end
                                                               
                                                             | _ =>
@@ -327,7 +327,7 @@ val () = Slave.registerFileHandler (fn fs =>
                                                                        if Posix.FileSys.access (rld, []) then
                                                                            ()
                                                                        else
-                                                                           OS.FileSys.mkDir rld
+                                                                           Slave.mkDirAll rld
                                                                    end
                                                                else
                                                                    ())
index 1fed991..c1706bf 100644 (file)
@@ -67,4 +67,7 @@ signature SLAVE = sig
     val inGroup : {user : string, group : string} -> bool
     (* Check membership in a UNIX group. *)
 
+    val mkDirAll : string -> unit
+    (* [mkDirAll p] creates directory "p", creating all parent directories, as
+     * necessary. *)
 end
index af8b606..44af4b3 100644 (file)
@@ -200,4 +200,6 @@ fun inGroup {user, group} =
                (Posix.SysDB.Group.members (Posix.SysDB.getgrnam group))
                handle OS.SysErr _ => false
 
+fun mkDirAll dir = ignore (OS.Process.system ("mkdir -p " ^ dir))
+
 end