diff options
author | Eric <[email protected]> | 2012-12-28 13:00:34 -0500 |
---|---|---|
committer | Eric <[email protected]> | 2012-12-28 13:00:34 -0500 |
commit | 3e295e146c960252af0008f1f13a7e40bcbdb929 (patch) | |
tree | e53dce219844ffb7e5f588d9b7840d650ad0ffb4 | |
parent | 39ff3c87aa0d6444e5c3d9ae03538d0f212d81e6 (diff) | |
download | relx-3e295e146c960252af0008f1f13a7e40bcbdb929.tar.gz relx-3e295e146c960252af0008f1f13a7e40bcbdb929.tar.bz2 relx-3e295e146c960252af0008f1f13a7e40bcbdb929.zip |
make sure file permissions are set correctly in overlay template/copy
-rw-r--r-- | src/rcl_prv_overlay.erl | 4 | ||||
-rw-r--r-- | test/rclt_release_SUITE.erl | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/rcl_prv_overlay.erl b/src/rcl_prv_overlay.erl index 9670138..b854650 100644 --- a/src/rcl_prv_overlay.erl +++ b/src/rcl_prv_overlay.erl @@ -300,6 +300,8 @@ copy_to(State, FromFile0, ToFile0) -> end, case ec_file:copy(FromFile1, ToFile2) of ok -> + {ok, FileInfo} = file:read_file_info(FromFile1), + ok = file:write_file_info(ToFile2, FileInfo), ok; {error, Err} -> ?RCL_ERROR({copy_failed, @@ -340,6 +342,8 @@ write_template(OverlayVars, FromFile, ToFile) -> ok -> case file:write_file(ToFile, IoData) of ok -> + {ok, FileInfo} = file:read_file_info(FromFile), + ok = file:write_file_info(ToFile, FileInfo), ok; {error, Reason} -> ?RCL_ERROR({unable_to_write, ToFile, Reason}) diff --git a/test/rclt_release_SUITE.erl b/test/rclt_release_SUITE.erl index 848c129..593944e 100644 --- a/test/rclt_release_SUITE.erl +++ b/test/rclt_release_SUITE.erl @@ -34,6 +34,7 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). -include_lib("kernel/include/file.hrl"). +-include_lib("kernel/include/file.hrl"). suite() -> [{timetrap,{seconds,30}}]. @@ -317,6 +318,8 @@ overlay_release(Config) -> TemplateFile = filename:join([LibDir1, "test_template"]), ok = file:write_file(TemplateFile, test_template_contents()), + {ok, FileInfo} = file:read_file_info(TemplateFile), + ok = file:write_file_info(TemplateFile, FileInfo#file_info{mode=8#00777}), OutputDir = filename:join([proplists:get_value(data_dir, Config), create_random_name("relcool-output")]), @@ -338,12 +341,14 @@ overlay_release(Config) -> ?assert(ec_file:exists(filename:join([OutputDir, "foodir", "vars.config"]))), ?assert(ec_file:exists(filename:join([OutputDir, "yahoo", "vars.config"]))), - TemplateData = case file:consult(filename:join([OutputDir, test_template_resolved])) of + TemplateData = case file:consult(filename:join([OutputDir, "test_template_resolved"])) of {ok, Details} -> Details; Error -> erlang:throw({failed_to_consult, Error}) end, + {ok, ReadFileInfo} = file:read_file_info(filename:join([OutputDir, "test_template_resolved"])), + ?assertEqual(8#100777, ReadFileInfo#file_info.mode), ?assertEqual(erlang:system_info(version), proplists:get_value(erts_vsn, TemplateData)), |