diff options
author | Siri Hansen <[email protected]> | 2011-12-21 14:54:47 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2011-12-21 14:54:47 +0100 |
commit | 01f35546b9dbaac053a80418b38105a1acc35540 (patch) | |
tree | 71849b0c5a0da8838b7bc122e9cdd5cf18fe9366 /lib/sasl/src/systools_make.erl | |
parent | 5acece57ced229dc76ebf3eb7cf7dfec1a24cc19 (diff) | |
parent | 0706cb9c155fcdab4a946ebb7f8cc74aceaa4cb0 (diff) | |
download | otp-01f35546b9dbaac053a80418b38105a1acc35540.tar.gz otp-01f35546b9dbaac053a80418b38105a1acc35540.tar.bz2 otp-01f35546b9dbaac053a80418b38105a1acc35540.zip |
Merge branch 'siri/sasl/check-config-in-tar/OTP-9539' into maint
* siri/sasl/check-config-in-tar/OTP-9539:
Check that sys.config and relup have valid content when added to tar
Diffstat (limited to 'lib/sasl/src/systools_make.erl')
-rw-r--r-- | lib/sasl/src/systools_make.erl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/sasl/src/systools_make.erl b/lib/sasl/src/systools_make.erl index 7be83d4137..12ba2a5476 100644 --- a/lib/sasl/src/systools_make.erl +++ b/lib/sasl/src/systools_make.erl @@ -1682,6 +1682,7 @@ add_system_files(Tar, RelName, Release, Path1) -> false -> ignore; Relup -> + check_relup(Relup), add_to_tar(Tar, Relup, filename:join(RelVsnDir, "relup")) end, @@ -1689,6 +1690,7 @@ add_system_files(Tar, RelName, Release, Path1) -> false -> ignore; Sys -> + check_sys_config(Sys), add_to_tar(Tar, Sys, filename:join(RelVsnDir, "sys.config")) end, @@ -1705,6 +1707,44 @@ lookup_file(Name, [Dir|Path]) -> lookup_file(_Name, []) -> false. +%% Check that relup can be parsed and has expected format +check_relup(File) -> + case file:consult(File) of + {ok,[{Vsn,UpFrom,DownTo}]} when is_list(Vsn), is_integer(hd(Vsn)), + is_list(UpFrom), is_list(DownTo) -> + ok; + {ok,_} -> + throw({error,{tar_error,{add,"relup",[invalid_format]}}}); + Other -> + throw({error,{tar_error,{add,"relup",[Other]}}}) + end. + +%% Check that sys.config can be parsed and has expected format +check_sys_config(File) -> + case file:consult(File) of + {ok,[SysConfig]} -> + case lists:all(fun({App,KeyVals}) when is_atom(App), + is_list(KeyVals)-> + true; + (OtherConfig) when is_list(OtherConfig), + is_integer(hd(OtherConfig)) -> + true; + (_) -> + false + end, + SysConfig) of + true -> + ok; + false -> + throw({error,{tar_error, + {add,"sys.config",[invalid_format]}}}) + end; + {ok,_} -> + throw({error,{tar_error,{add,"sys.config",[invalid_format]}}}); + Other -> + throw({error,{tar_error,{add,"sys.config",[Other]}}}) + end. + %%______________________________________________________________________ %% Add either a application located under a variable dir or all other %% applications to a tar file. |