Allow faking your_{user,path,group} and homedir
authorClinton Ebadi <clinton@unknownlamer.org>
Wed, 9 Apr 2014 21:26:59 +0000 (17:26 -0400)
committerClinton Ebadi <clinton@unknownlamer.org>
Wed, 9 Apr 2014 21:26:59 +0000 (17:26 -0400)
Autodoc hates the your_FOO refinement types, and I see no reason why
users wouldn't want to fake these values if they are already faking
domain permissions. Additionally, set the homedir to /tmp if the user
is unset and we're faking privs.

src/domain.sml

index 3e212a2..7286b2e 100644 (file)
@@ -134,15 +134,18 @@ fun validDomain s =
 fun validNode s = List.exists (fn s' => s = s') nodes
 
 fun yourDomain s = !fakePrivs orelse SS.member (your_domains (), s)
 fun validNode s = List.exists (fn s' => s = s') nodes
 
 fun yourDomain s = !fakePrivs orelse SS.member (your_domains (), s)
-fun yourUser s = SS.member (your_users (), s)
-fun yourGroup s = SS.member (your_groups (), s)
+fun yourUser s = !fakePrivs orelse SS.member (your_users (), s)
+fun yourGroup s = !fakePrivs orelse SS.member (your_groups (), s)
+
 fun checkPath paths path =
 fun checkPath paths path =
+    !fakePrivs orelse
     (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) (paths ()))
 val yourPath = checkPath your_paths
 val readablePath = checkPath readable_paths
     (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) (paths ()))
 val yourPath = checkPath your_paths
 val readablePath = checkPath readable_paths
+
 fun yourIp s = !fakePrivs orelse SS.member (your_ips (), s)
 
 fun yourDomainHost s =
 fun yourIp s = !fakePrivs orelse SS.member (your_ips (), s)
 
 fun yourDomainHost s =
@@ -866,6 +869,7 @@ fun homedirOf uname =
     Posix.SysDB.Passwd.home (Posix.SysDB.getpwnam uname)
 
 fun homedir () = homedirOf (getUser ())
     Posix.SysDB.Passwd.home (Posix.SysDB.getpwnam uname)
 
 fun homedir () = homedirOf (getUser ())
+                handle e => if !fakePrivs then "/tmp" else raise e
 
 type subject = {node : string, domain : string}
 
 
 type subject = {node : string, domain : string}