diff options
author | Hans Nilsson <[email protected]> | 2015-11-06 13:23:13 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2015-11-13 12:33:44 +0100 |
commit | ae6cec13757195406c65c598ddd9b979a2c4f517 (patch) | |
tree | 3bf85bafb077f27d385c1938796b4867ccb7734c /lib | |
parent | 98e1d3394514181648c64ab9e5f7a1af2573d658 (diff) | |
download | otp-ae6cec13757195406c65c598ddd9b979a2c4f517.tar.gz otp-ae6cec13757195406c65c598ddd9b979a2c4f517.tar.bz2 otp-ae6cec13757195406c65c598ddd9b979a2c4f517.zip |
ssh: ssh_file:default_user_dir/0 - try HOME env var first
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ssh/src/ssh_file.erl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl index 2f16a31cba..3e066c453d 100644 --- a/lib/ssh/src/ssh_file.erl +++ b/lib/ssh/src/ssh_file.erl @@ -336,8 +336,18 @@ is_auth_key(Key, Key) -> is_auth_key(_,_) -> false. -default_user_dir()-> - {ok,[[Home|_]]} = init:get_argument(home), + +default_user_dir() -> + try + default_user_dir(os:getenv("HOME")) + catch + _:_ -> + default_user_dir(init:get_argument(home)) + end. + +default_user_dir({ok,[[Home|_]]}) -> + default_user_dir(Home); +default_user_dir(Home) when is_list(Home) -> UserDir = filename:join(Home, ".ssh"), ok = filelib:ensure_dir(filename:join(UserDir, "dummy")), {ok,Info} = file:read_file_info(UserDir), |