diff --git a/CHANGES.md b/CHANGES.md index 51aaeb5e35..992abb971e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,6 +24,8 @@ Fixed: the process (#2897) * Fixed `filename` getter being called multiple time in `output.file` (#2842) +* Fixed default directory permissions in `output.*.hls` + operators (#2930) * Space trim in interactive variables set on telnet (#2785) * Fixed internal streaming logic in `max_duration` and `crossfade`. * Make sure that there's at most one metadata at any given diff --git a/src/outputs/hls_output.ml b/src/outputs/hls_output.ml index e18e94100e..cea692c284 100644 --- a/src/outputs/hls_output.ml +++ b/src/outputs/hls_output.ml @@ -93,11 +93,19 @@ let hls_proto kind = Some "Number of segments per playlist." ); ( "perm", Lang.int_t, - Some (Lang.int 0o644), + Some (Lang.int 0o666), Some "Permission of the created files, up to umask. You can and should \ write this number in octal notation: 0oXXX. The default value is \ however displayed in decimal (0o666 = 6*8^2 + 4*8 + 4 = 412)." ); + ( "dir_perm", + Lang.int_t, + Some (Lang.int 0o777), + Some + "Permission of the directories if some have to be created, up to \ + umask. Although you can enter values in octal notation (0oXXX) they \ + will be displayed in decimal (for instance, 0o777 = 7×8^2 + 7×8 + 7 \ + = 511)." ); ( "on_file_change", Lang.fun_t [(false, "state", Lang.string_t); (false, "", Lang.string_t)] @@ -123,10 +131,6 @@ let hls_proto kind = "Location of the configuration file used to restart the output. \ Relative paths are assumed to be with regard to the directory for \ generated file." ); - ( "perms", - Lang.int_t, - Some (Lang.int 0o755), - Some "Default directory rights if created. Default: `0o755`" ); ( "strict_persist", Lang.bool_t, Some (Lang.bool false), @@ -255,10 +259,11 @@ class hls_output p = let prefix = Lang.to_string (List.assoc "prefix" p) in let directory = Lang.to_string (Lang.assoc "" 1 p) in let perm = Lang.to_int (List.assoc "perm" p) in + let dir_perm = Lang.to_int (List.assoc "dir_perm" p) in let () = if (not (Sys.file_exists directory)) || not (Sys.is_directory directory) then ( - try Utils.mkdir ~perm directory + try Utils.mkdir ~perm:dir_perm directory with exn -> let bt = Printexc.get_raw_backtrace () in Lang.raise_as_runtime ~bt ~kind:"file" exn) @@ -273,7 +278,7 @@ class hls_output p = else filename in let dir = Filename.dirname filename in - (try Utils.mkdir ~perm:0o777 dir + (try Utils.mkdir ~perm:dir_perm dir with exn -> raise (Error.Invalid_value @@ -432,7 +437,6 @@ class hls_output p = let max_segments = segments_per_playlist + Lang.to_int (List.assoc "segments_overhead" p) in - let file_perm = Lang.to_int (List.assoc "perm" p) in let kind = Kind.of_kind (Encoder.kind_of_format (List.hd streams).format) in object (self) inherit @@ -456,7 +460,7 @@ class hls_output p = method private open_out filename = let mode = [Open_wronly; Open_creat; Open_trunc] in - let oc = open_out_gen mode file_perm filename in + let oc = open_out_gen mode perm filename in set_binary_mode_out oc true; on_file_change ~state:`Opened filename; oc @@ -511,7 +515,7 @@ class hls_output p = let () = if (not (Sys.file_exists directory)) || not (Sys.is_directory directory) then ( - try Utils.mkdir ~perm directory + try Utils.mkdir ~perm:dir_perm directory with exn -> let bt = Printexc.get_raw_backtrace () in Lang.raise_as_runtime ~bt ~kind:"file" exn) diff --git a/tests/regression/GH2926.liq b/tests/regression/GH2926.liq new file mode 100644 index 0000000000..67babecbcd --- /dev/null +++ b/tests/regression/GH2926.liq @@ -0,0 +1,20 @@ +%include "test.liq" + +tmp_dir = file.temp_dir("tmp", "dir") +on_shutdown({file.rmdir(tmp_dir)}) + +def f() = + enc = %ffmpeg(format="mpegts",%audio(codec="aac")) + streams = [("enc", enc)] + + output.file.hls( + fallible=true, + on_stop=test.pass, + persist_at="./config", + path.concat(tmp_dir, "hls"), + streams, + once(sine(duration=1.)) + ) +end + +test.check(f)