From 5c0484fc5f8b3fcaa5cab756a18eeb6525cb473c Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 15 May 2019 13:49:20 +0800 Subject: [PATCH] Do not allow actions to create dirs outside of build dir Signed-off-by: Rudi Grinberg --- CHANGES.md | 2 +- src/action_exec.ml | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 828240cce38..b2aa51e989e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,7 +30,7 @@ unreleased - Add a 'cookies' option to ppx_rewriter/deriver flags in library stanzas (#2106, @mlasson @diml). This allow to specify cookie requests from - variables expanded at each invocation of the preprocessor. + variables expanded at each invocation of the preprocessor. - Add more opam metadata and use it to generate `.opam` files. In particular, a `package` field has been added to specify package specific information. diff --git a/src/action_exec.ml b/src/action_exec.ml index 0c591e1fa02..13a9275a507 100644 --- a/src/action_exec.ml +++ b/src/action_exec.ml @@ -108,7 +108,13 @@ let rec exec t ~ectx ~dir ~env ~stdout_to ~stderr_to = Path.rm_rf path; Fiber.return () | Mkdir path -> - Path.mkdir_p path; + begin + if Path.is_in_build_dir path then + Path.mkdir_p path + else + Exn.code_error "Action_exec.exec: mkdir on non build dir" + ["path", Path.to_sexp path] + end; Fiber.return () | Digest_files paths -> let s =