From 39ee4dca062889e79557899673fba5336471c7cd Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Fri, 13 Jun 2008 20:47:38 +0000 Subject: [PATCH] vsys won't fail if the frontend is not set up. --- conffile.ml | 12 +++++++++++- globals.ml | 1 + inotify_stubs.o | Bin 2764 -> 2836 bytes main.ml | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/conffile.ml b/conffile.ml index d9fe129..6279d16 100644 --- a/conffile.ml +++ b/conffile.ml @@ -5,6 +5,15 @@ open Scanf let split_conf_line s = sscanf s "%s %s" (fun s1 s2->(s1,s2)) +let check_dir fe = + let (vsysdir,slice) = fe in + let verdict = try Some(Unix.stat vsysdir) with + _ -> fprintf logfd "vsys directory not setup for slice %s\n" slice;flush logfd;None + in + match verdict with + | None->false + | Some(_) -> true + let rec in_list elt lst = match lst with | car::cdr -> @@ -12,6 +21,7 @@ let rec in_list elt lst = | [] -> false let read_frontends f = + let setup_ok = if (!Globals.failsafe) then check_dir else fun _ -> true in let f_file = try open_in f with e -> fprintf logfd "Could not open config file\n";flush logfd;raise e in let rec read_conf_file cur_list = @@ -19,7 +29,7 @@ let read_frontends f = match next_line with | Some(inp_line) -> let fe = split_conf_line inp_line in - let new_list = if (not (in_list fe cur_list)) then (fe::cur_list) else cur_list + let new_list = if (not (in_list fe cur_list) && (setup_ok(fe))) then (fe::cur_list) else cur_list in read_conf_file new_list | None -> cur_list diff --git a/globals.ml b/globals.ml index e8dca75..2dd7fe9 100644 --- a/globals.ml +++ b/globals.ml @@ -6,6 +6,7 @@ let nochroot = ref false let conffile = ref "" let pid_filepath = ref "/var/run/vsys.pid" let log_filepath = ref "/var/log/vsys" +let failsafe = ref false let logfd = open_out_gen [Open_append;Open_creat] 0o644 !log_filepath type result = Success | Failed diff --git a/inotify_stubs.o b/inotify_stubs.o index 82c7c60326f8edc07ccb5264d5fd88d340ecd2d1..714490f7146451eac7b875264806dbb148c5b635 100644 GIT binary patch delta 538 zcmZ9FOG{f(6h_xRNp5qcf;J{1wW8!Ig?7@h6QvPR5IS%sC0a#u@zvH_N=G6s;w1zM z$A95ON$X5hbf}gV!I2;x^)U*F2nvy7PVjLii|<=|@3WU&PObhEH=6H>|2z+)p1zQF zol}E}FyqDZJrBc-cjJy!N6k7wVH410H5L0>2s+TM>Ur|dWw~4qpBVjl*Bg3W$RImf zqOXc;kvWkz-5yKJX|XT%Qe;aPoV2qPhbhqqPO7-)cp^DndeAt3Y%bVW2mA+41ik=| z5R_Cc*S_gqekSl%!K9tK6xlOs^F{><{J z0+oU;!$#;=mHi<@2Zl}G01LKXwES-RCfKgz7yPmdM|R<_9V}VaMnFA=M5OY;6{LY@ A#Q*>R delta 471 zcmXwyy-QnR6o;Sl-sCnx1#RP3Z9$SZI#lrE4=6~lqGO?(l#mMIrMD{06`M)HDX7!y z;8?^_XyGm$912ykh#-g^bSO@?o7BNUNO_yrvpk&Nc{soAuH(+Hf21R`F_EdKbWz~+ zt`_K&`71@!?+rbxr*uK!`o7U<)Sd&ZAL^O6TLJRJ^r$y|^_12EwLrISOtjVlZGX8Z zt7<^S1Llj0Oxf#9*1SED7p9ml$bK@NekJnRZ21L$J_CW66Td4t_O-~8xp~z6`plNO zX$P)=UjkFWV}x5^M8T%pTjas!zn>TQuHe19zckg%#bBjcnJq^Vv*iy_X|5bbD`7lO zC0>443KtgRaIRVk7sA+l%nq9*n>V-FrPTug^#qOtqz!&r`fzFU9Q=0qjblzV{imww wk6C&!?)FK?PuA;(9p~@5JhAlQo6U2Ka_SD}j%g26FLZd#g1n^KbEsuF8}}l diff --git a/main.ml b/main.ml index bbc9b06..58e13b6 100644 --- a/main.ml +++ b/main.ml @@ -17,7 +17,8 @@ let cmdspeclist = ("-conffile",Arg.Set_string(Globals.conffile), "Config file"); ("-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"); - ("-nochroot",Arg.Set(Globals.nochroot), "Run in non-chroot environment") + ("-nochroot",Arg.Set(Globals.nochroot), "Run in non-chroot environment"); + ("-failsafe",Arg.Set(Globals.failsafe), "Never crash. Be stupid, but never crash. Use at your own risk."); ] let cont = ref true -- 2.47.0