(* HCoop Domtool (http://hcoop.sourceforge.net/)
- * Copyright (c) 2006, Adam Chlipala
+ * Copyright (c) 2006-2007, Adam Chlipala
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
val your_pths = ref SS.empty
fun your_paths () = !your_pths
+val world_readable = SS.addList (SS.empty, Config.worldReadable)
+val readable_pths = ref SS.empty
+fun readable_paths () = !readable_pths
+
fun setUser user =
- (usr := user;
- your_doms := Acl.class {user = getUser (),
- class = "domain"};
- your_usrs := Acl.class {user = getUser (),
- class = "user"};
- your_grps := Acl.class {user = getUser (),
- class = "group"};
- your_pths := Acl.class {user = getUser (),
- class = "path"})
+ let
+ val () = usr := user
+
+ val your_paths = Acl.class {user = getUser (),
+ class = "path"}
+ in
+ your_doms := Acl.class {user = getUser (),
+ class = "domain"};
+ your_usrs := Acl.class {user = getUser (),
+ class = "user"};
+ your_grps := Acl.class {user = getUser (),
+ class = "group"};
+ your_pths := your_paths;
+ readable_pths := SS.union (your_paths, world_readable)
+ end
fun validIp s =
case map Int.fromString (String.fields (fn ch => ch = #".") s) of
fun yourDomain s = SS.member (your_domains (), s)
fun yourUser s = SS.member (your_users (), s)
fun yourGroup s = SS.member (your_groups (), s)
-fun yourPath path =
+fun checkPath paths path =
List.all (fn s => s <> "..") (String.fields (fn ch => ch = #"/") path)
andalso CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"." orelse ch = #"/"
orelse ch = #"-" orelse ch = #"_") path
- andalso SS.exists (fn s' => path = s' orelse String.isPrefix (s' ^ "/") path) (your_paths ())
+ andalso SS.exists (fn s' => path = s' orelse String.isPrefix (s' ^ "/") path) (paths ())
+val yourPath = checkPath your_paths
+val readablePath = checkPath readable_paths
fun yourDomainHost s =
yourDomain s
val _ = Env.type_one "no_spaces"
Env.string
- (CharVector.all (fn ch => not (Char.isSpace ch)))
+ (CharVector.all (fn ch => Char.isPrint ch andalso not (Char.isSpace ch)
+ andalso ch <> #"\"" andalso ch <> #"'"))
val _ = Env.type_one "no_newlines"
Env.string
- (CharVector.all (fn ch => ch <> #"\n" andalso ch <> #"\r"))
+ (CharVector.all (fn ch => Char.isPrint ch andalso ch <> #"\n" andalso ch <> #"\r"
+ andalso ch <> #"\"" andalso ch <> #"'"))
val _ = Env.type_one "ip"
Env.string
Env.string
yourPath
+val _ = Env.type_one "readable_path"
+ Env.string
+ readablePath
+
val _ = Env.type_one "node"
Env.string
validNode