aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/ssh_file.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2015-11-06 13:23:13 +0100
committerHans Nilsson <[email protected]>2015-11-13 12:33:44 +0100
commitae6cec13757195406c65c598ddd9b979a2c4f517 (patch)
tree3bf85bafb077f27d385c1938796b4867ccb7734c /lib/ssh/src/ssh_file.erl
parent98e1d3394514181648c64ab9e5f7a1af2573d658 (diff)
downloadotp-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/ssh/src/ssh_file.erl')
-rw-r--r--lib/ssh/src/ssh_file.erl14
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),