diff options
| author | Daniil Fedotov <hairyhum@gmail.com> | 2018-08-13 15:17:44 +0100 |
|---|---|---|
| committer | Daniil Fedotov <hairyhum@gmail.com> | 2018-08-14 14:19:42 +0100 |
| commit | 56a372cf045975426a13bc7e52d9ff00079af2a2 (patch) | |
| tree | cc098ab97cb41c62096c573991ed3006ab200038 | |
| parent | 61f7e9c9c3eb32441b102dbd12beb7e49a49ad0c (diff) | |
| download | rabbitmq-server-git-56a372cf045975426a13bc7e52d9ff00079af2a2.tar.gz | |
Use file:consult to check if .conf is of the old format. Add more errors to the .config check
| -rw-r--r-- | src/rabbit_config.erl | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/rabbit_config.erl b/src/rabbit_config.erl index 41e25d27a8..cef75f1179 100644 --- a/src/rabbit_config.erl +++ b/src/rabbit_config.erl @@ -257,7 +257,9 @@ assert_config(Filename, Env) -> case filelib:is_regular(Filename) of true -> case file:consult(Filename) of - {ok, _} -> ok; + {ok, []} -> {error, "ERROR: Config file ~s should not be empty: ~s"}; + {ok, [_]} -> ok; + {ok, [_|_]} -> {error, "ERROR: Config file ~s must contain ONE list ended by <dot>: ~s"}; {error, {1, erl_parse, Err}} -> {error, {"ERROR: Unable to parse erlang terms from ~s file: ~s~n" "ERROR: Reason: ~p~n" @@ -283,8 +285,9 @@ assert_conf(Filename, Env) -> ".conf" = filename:extension(Filename), case filelib:is_regular(Filename) of true -> - case file:read_file(Filename) of - {ok, <<"[", _/binary>>} -> + case file:consult(Filename) of + {ok, []} -> ok; + {ok, _} -> {error, {"ERROR: Wrong format of the config file ~s: ~s~n" "ERROR: Check that the file is in the new ini-style config format " "If you are using the old format the file extension should " |
