From 6dc612f46d3b237d8da9f09b7984e6aa0ddec433 Mon Sep 17 00:00:00 2001 From: Ferruccio Guidi Date: Sun, 23 Sep 2007 12:27:52 +0000 Subject: [PATCH] fixed some file permissions (anybody can rebuild a published devel) --- components/extlib/hExtlib.ml | 10 +++++++--- components/extlib/hExtlib.mli | 1 + components/extlib/hMarshal.ml | 3 ++- components/xml/xml.ml | 16 ++++++++++------ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/components/extlib/hExtlib.ml b/components/extlib/hExtlib.ml index d9b24c2eb..bf3bb2574 100644 --- a/components/extlib/hExtlib.ml +++ b/components/extlib/hExtlib.ml @@ -244,18 +244,21 @@ let mkdir path = let path = if where = "" then piece else where ^ "/" ^ piece in (try - Unix.mkdir path 0o755 + Unix.mkdir path 0o775 with | Unix.Unix_error (Unix.EEXIST,_,_) -> () | Unix.Unix_error (e,_,_) -> raise (Failure - ("Unix.mkdir " ^ path ^ " 0o755 :" ^ (Unix.error_message e)))); + ("Unix.mkdir " ^ path ^ " 0o775 :" ^ (Unix.error_message e)))); aux path tl in let where = if path.[0] = '/' then "/" else "" in aux where components +let chmod mode filename = + Unix.chmod filename mode + (** {2 Filesystem} *) let input_file fname = @@ -282,7 +285,8 @@ let input_all ic = let output_file ~filename ~text = let oc = open_out filename in output_string oc text; - close_out oc + close_out oc; + chmod 0o664 filename let blank_split s = let len = String.length s in diff --git a/components/extlib/hExtlib.mli b/components/extlib/hExtlib.mli index 815c20526..5f6626b14 100644 --- a/components/extlib/hExtlib.mli +++ b/components/extlib/hExtlib.mli @@ -41,6 +41,7 @@ val safe_remove: string -> unit (** removes a file if it exists *) val safe_rmdir: string -> unit (** removes a dir if it exists and is empty *) val is_dir_empty: string -> bool (** checks if the dir is empty *) val rmdir_descend: string -> unit (** rmdir -p *) +val chmod: int -> string -> unit (** chmod *) (** find all _files_ whose name matches test under a filesystem root. * Test is passed the filename path relative to the given filesystem root *) diff --git a/components/extlib/hMarshal.ml b/components/extlib/hMarshal.ml index c57886819..cb4976e7d 100644 --- a/components/extlib/hMarshal.ml +++ b/components/extlib/hMarshal.ml @@ -42,7 +42,8 @@ let save ~fmt ~version ~fname data = output_string oc (string_of_int version); (* field 4 *) output_binary_int oc (Hashtbl.hash marshalled); (* field 5 *) output_string oc marshalled; (* field 6 *) - close_out oc + close_out oc; + HExtlib.chmod 0o664 fname let expect ic fname s = let len = String.length s in diff --git a/components/xml/xml.ml b/components/xml/xml.ml index f8cc41cbe..0e3a4bcc2 100644 --- a/components/xml/xml.ml +++ b/components/xml/xml.ml @@ -123,23 +123,27 @@ let pp ?(gzip=false) strm fn = match fn with | Some filename -> let outchan = Gzip.open_out filename in - (try + begin try pp_to_gzipchan strm outchan; with e -> Gzip.close_out outchan; - raise e); - Gzip.close_out outchan + raise e + end; + Gzip.close_out outchan; + HExtlib.chmod 0o664 filename; | None -> failwith "Can't sent gzipped output to stdout" else match fn with | Some filename -> let outchan = open_out filename in - (try + begin try pp_to_outchan strm outchan; with e -> close_out outchan; - raise e); - close_out outchan + raise e + end; + close_out outchan; + HExtlib.chmod 0o664 filename | None -> pp_to_outchan strm stdout ;; -- 2.39.2