Adding some library functions that'll facilitate the creation of vsys scripts.
authorSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 14 Sep 2007 19:32:07 +0000 (19:32 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 14 Sep 2007 19:32:07 +0000 (19:32 +0000)
fifowatcher.ml
frontend.ml
globals.ml
lib/connect_fd [new file with mode: 0755]
main.ml

index 646ec31..dc79dad 100644 (file)
@@ -146,16 +146,24 @@ and receive_fifo_event eventdescriptor outdescriptor =
 
 
 (** Make a pair of fifo entries *)
-let mkentry fqp abspath perm = 
+let mkentry fqp abspath perm uname 
   printf "Making entry %s->%s\n" fqp abspath;flush Pervasives.stdout;
   let fifoin=sprintf "%s.in" fqp in
   let fifoout=sprintf "%s.out" fqp in
     (try Unix.unlink fifoin with _ -> ());
     (try Unix.unlink fifoout with _ -> ());
     (try 
-       Unix.mkfifo (sprintf "%s.in" fqp) 0o666;
-       Unix.mkfifo (sprintf "%s.out" fqp) 0o666;
-       Success
+       let infname =(sprintf "%s.in" fqp) in
+       let outfname =(sprintf "%s.out" fqp) in
+         Unix.mkfifo infname 0o666;
+         Unix.mkfifo outfname 0o666;
+         ( (* Make the user the owner of the pipes in a non-chroot environment *)
+         if (!Globals.nochroot) then
+           let pwentry = Unix.getpwnam uname in
+             Unix.chown infname pwentry.pw_uid pwentry.pw_gid; 
+             Unix.chown outfname pwentry.pw_uid pwentry.pw_gid
+         );
+         Success
      with 
          e->printf "Error creating FIFO: %s->%s. May be something wrong at the frontend.\n" fqp fifoout;flush Pervasives.stdout;Failed)
 
index aca8e7b..7cc0c16 100644 (file)
@@ -21,7 +21,7 @@ object(this)
             let realperm = perm land (lnot 0o111) in
     match rp with Relpath(rel) ->
       let fqp = String.concat "/" [root_dir;rel] in
-      let res = Fifowatcher.mkentry fqp abspath realperm in
+      let res = Fifowatcher.mkentry fqp abspath realperm slice_name in
         match res with 
           | Success ->
               Fifowatcher.openentry fqp (abspath,slice_name) realperm
index 0afb155..3ea4a32 100644 (file)
@@ -2,6 +2,7 @@
 let backend = ref ""
 let debug = ref true
 let vsys_version = "0.5"
+let nochroot = ref false
 
 type result = Success | Failed
 
diff --git a/lib/connect_fd b/lib/connect_fd
new file mode 100755 (executable)
index 0000000..0882711
Binary files /dev/null and b/lib/connect_fd differ
diff --git a/main.ml b/main.ml
index 91df33a..be96b82 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -13,7 +13,8 @@ let cur_slice = ref ""
 let cmdspeclist =
   [
     ("-backend",Arg.Set_string(Globals.backend), "Backend directory");
-    ("-frontend",Arg.Tuple[Arg.String(fun s->cur_dir:=s);Arg.String(fun s->cur_slice:=s;input_file_list:=(!cur_dir,!cur_slice)::!input_file_list)], "frontendN,slicenameN")
+    ("-frontend",Arg.Tuple[Arg.String(fun s->cur_dir:=s);Arg.String(fun s->cur_slice:=s;input_file_list:=(!cur_dir,!cur_slice)::!input_file_list)], "frontendN,slicenameN");
+    ("-nochroot",Arg.Set(Globals.nochroot), "Run in non-chroot environment")
   ]
 
 let cont = ref true