From: Sapan Bhatia Date: Fri, 14 Sep 2007 19:32:07 +0000 (+0000) Subject: Adding some library functions that'll facilitate the creation of vsys scripts. X-Git-Tag: vsys-0.7-19~19 X-Git-Url: http://git.onelab.eu/?p=vsys.git;a=commitdiff_plain;h=d549a9725e4e1f731a08a147a33d6f3a13c4e648 Adding some library functions that'll facilitate the creation of vsys scripts. --- diff --git a/fifowatcher.ml b/fifowatcher.ml index 646ec31..dc79dad 100644 --- a/fifowatcher.ml +++ b/fifowatcher.ml @@ -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) diff --git a/frontend.ml b/frontend.ml index aca8e7b..7cc0c16 100644 --- a/frontend.ml +++ b/frontend.ml @@ -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 diff --git a/globals.ml b/globals.ml index 0afb155..3ea4a32 100644 --- a/globals.ml +++ b/globals.ml @@ -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 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 --- 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