client: Also try to load the private rsa-ssh key.
authorAndre Noll <maan@systemlinux.org>
Thu, 25 Nov 2010 07:56:34 +0000 (08:56 +0100)
committerAndre Noll <maan@systemlinux.org>
Tue, 26 Apr 2011 20:34:27 +0000 (22:34 +0200)
If no key file was given and the default key file ~/.paraslash/key.<user> does
not exist, try ~/.ssh/id_rsa.

client_common.c

index d3a9ede..865a179 100644 (file)
@@ -394,9 +394,16 @@ int client_open(int argc, char *argv[], struct client_task **ct_ptr,
        ct->user = ct->conf.user_given?
                para_strdup(ct->conf.user_arg) : para_logname();
 
        ct->user = ct->conf.user_given?
                para_strdup(ct->conf.user_arg) : para_logname();
 
-       ct->key_file = ct->conf.key_file_given?
-               para_strdup(ct->conf.key_file_arg) :
-               make_message("%s/.paraslash/key.%s", home, ct->user);
+       if (ct->conf.key_file_given)
+               ct->key_file = para_strdup(ct->conf.key_file_arg);
+       else {
+               ct->key_file = make_message("%s/.paraslash/key.%s",
+                       home, ct->user);
+               if (!file_exists(ct->key_file)) {
+                       free(ct->key_file);
+                       ct->key_file = make_message("%s/.ssh/id_rsa", home);
+               }
+       }
 
        if (loglevel)
                *loglevel = get_loglevel_by_name(ct->conf.loglevel_arg);
 
        if (loglevel)
                *loglevel = get_loglevel_by_name(ct->conf.loglevel_arg);