X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=client_common.c;h=eb9f9e1fcda2a49ba960582ba67be9c882897a20;hp=c7ea3b4cb0dde32a36c1a50ebdb72658b9ec47e2;hb=c0abcee0da53a6b399c3d16a62830aaa9ae21349;hpb=e7593d7c153bfca2131b18621fb24ae18c1c0cb3 diff --git a/client_common.c b/client_common.c index c7ea3b4c..eb9f9e1f 100644 --- a/client_common.c +++ b/client_common.c @@ -8,7 +8,6 @@ #include #include -#include #include "para.h" #include "error.h" @@ -22,6 +21,7 @@ #include "client.cmdline.h" #include "client.h" #include "buffer_tree.h" +#include "version.h" /** The size of the receiving buffer. */ #define CLIENT_BUFSIZE 4000 @@ -44,6 +44,7 @@ void client_close(struct client_task *ct) free(ct->user); free(ct->config_file); free(ct->key_file); + btr_free_node(ct->btrn); client_cmdline_parser_free(&ct->conf); free(ct); } @@ -394,9 +395,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->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); @@ -411,7 +419,6 @@ out: if (ret < 0) { PARA_ERROR_LOG("%s\n", para_strerror(-ret)); btr_remove_node(ct->btrn); - btr_free_node(ct->btrn); client_close(ct); *ct_ptr = NULL; }