[PATCH] ssh: ensure ~/.ssh exists

Tuncer Ayaz tuncer.ayaz@REDACTED
Thu Sep 2 23:26:42 CEST 2010


Make sure that ~/.ssh exists before trying to open files like
~/.ssh/known_hosts.

Reported-By: Daniel Goertzen
---
 lib/ssh/src/ssh_file.erl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl
index 5572349..1e32ae9 100755
--- a/lib/ssh/src/ssh_file.erl
+++ b/lib/ssh/src/ssh_file.erl
@@ -527,4 +527,6 @@ file_name(Type, Name, Opts) ->
 
 default_user_dir()->
     {ok,[[Home|_]]} = init:get_argument(home),
-    filename:join(Home, ".ssh").
+    UserDir = filename:join(Home, ".ssh"),
+    ok = filelib:ensure_dir(filename:join(UserDir, "dummy")),
+    UserDir.


More information about the erlang-patches mailing list