diff options
author | Siri Hansen <[email protected]> | 2011-12-09 16:13:08 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2011-12-20 15:31:38 +0100 |
commit | 0706cb9c155fcdab4a946ebb7f8cc74aceaa4cb0 (patch) | |
tree | e14890a6ae5ed2b592ba9ada44e17b82801c14db /lib/sasl/src/systools_make.erl | |
parent | 58336ee5c613de56f6d69562cd59b651eef734f0 (diff) | |
download | otp-0706cb9c155fcdab4a946ebb7f8cc74aceaa4cb0.tar.gz otp-0706cb9c155fcdab4a946ebb7f8cc74aceaa4cb0.tar.bz2 otp-0706cb9c155fcdab4a946ebb7f8cc74aceaa4cb0.zip |
Check that sys.config and relup have valid content when added to tar
systools:make_tar now does a minor check of the content of sys.config
and relup before adding them to the tar file. If the content is not
readable or in expected format, the function fails.
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 8fd90c50f9..d2c0af9129 100644 --- a/lib/sasl/src/systools_make.erl +++ b/lib/sasl/src/systools_make.erl @@ -1677,6 +1677,7 @@ add_system_files(Tar, RelName, Release, Path1) -> false -> ignore; Relup -> + check_relup(Relup), add_to_tar(Tar, Relup, filename:join(RelVsnDir, "relup")) end, @@ -1684,6 +1685,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, @@ -1700,6 +1702,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. |