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 zcmZ9G%S!@L6o=2f>NFDxmZ?Y&5+4M$Y2BtsiGrX-JBi7Xa>(rAM6{A9qCp0N+kerf zu-ZjMEv+a5SAn$Zu@WMJg6UkmQh8wJyT9|@GiQpPJ@3IQQSAAceD`VCL+p!$S&B}$ zjc7>D$C?nou0$h^CxB(1;fq-`?btQ-2(T{N>v{gREX(NNdh;q2pERRDE*Y_p7Y=P% zLIN!82$J{0h+~M5b7o3GX-5V~6Luqc3q>hJNQzY&e7Q&d1yL^K8$M+Mu!U>^0u;}+ z;@)4EdoV9ifO&NM{&1Zi!(2u`D7^aLvpM)TEA32E0?jp% zNG63blwfC8U!7KKO3P?E{0(ehSKgIhvzajeDg2%k?2e_!_KDg%x94K*t120tp6+tI1r)>akBwz3Y Dq=9F} delta 471 zcmXwzyGsK>5XNWsa_0pj7|p{cNODOE1s{KaASR-vU?&pJK*-^#!JOz-5v)Q?wHB5l zmV&}H78ZhvO%MX2g%)C^cEJ=DLY#qhVEOHQ^X)f#7^#OZzF1JNX7qcXkzfFgpGw;B ziEow=Bg)tis&Q05e%tMKWf-vbZ;j=ZS{m4m=;KR+XfV)#j{?<906|$Yq|B4tNs4oB z3sVVud&((eqavZk*_pSX&N6l^YFbdA-f+`A zvIiKnkP{r>K=z$D`!Djxu)oIn8s5o2EnNL2RdP!?)3zaJuG`tXY1uoLQ-G4Qy_&T) zHXSSPA}vR3`NxIlkBOGQSiZs}-V1PtWL*HyL=E7T^bo+O)SHqa+)DldB>AU^3c!r) t=OlNLJPL3`ME{A@JtF2`k{*IdXvo2nq>5p@A0UXN1u-H%NRf^o`U94;SuX$p 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.43.0