X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=client_common.c;h=f476a1c4ada24ddf4a7c5a825048ab7df9e7d9f5;hb=HEAD;hp=95e59fd29de2015fcc65443a4ffc6442387ec0f8;hpb=fca08641935a5bdf6570a14e0b7aeed536745060;p=paraslash.git diff --git a/client_common.c b/client_common.c index 95e59fd2..fe8234f9 100644 --- a/client_common.c +++ b/client_common.c @@ -262,7 +262,7 @@ static bool has_feature(const char *feature, struct client_task *ct) return false; for (int i = 0; ct->features[i]; i++) if (strcmp(feature, ct->features[i]) == 0) - return i; + return true; return false; } @@ -344,15 +344,18 @@ static int client_post_monitor(struct sched *s, void *context) goto out; ct->challenge_hash = alloc(HASH2_SIZE); if (has_feature("sha256", ct)) { - hash2_function((char *)crypt_buf, APC_CHALLENGE_SIZE, ct->challenge_hash); + hash2_function((char *)crypt_buf, APC_CHALLENGE_SIZE, + ct->challenge_hash); hash2_to_asc(ct->challenge_hash, buf); } else { - hash_function((char *)crypt_buf, APC_CHALLENGE_SIZE, ct->challenge_hash); + hash_function((char *)crypt_buf, APC_CHALLENGE_SIZE, + ct->challenge_hash); hash_to_asc(ct->challenge_hash, buf); } - ct->scc.send = sc_new(crypt_buf + APC_CHALLENGE_SIZE, SESSION_KEY_LEN); - ct->scc.recv = sc_new(crypt_buf + APC_CHALLENGE_SIZE + SESSION_KEY_LEN, - SESSION_KEY_LEN); + ct->scc.send = sc_new(crypt_buf + APC_CHALLENGE_SIZE, + SESSION_KEY_LEN); + ct->scc.recv = sc_new(crypt_buf + APC_CHALLENGE_SIZE + + SESSION_KEY_LEN, SESSION_KEY_LEN); PARA_INFO_LOG("--> %s\n", buf); ct->status = CL_RECEIVED_CHALLENGE; return 0; @@ -398,12 +401,12 @@ static int client_post_monitor(struct sched *s, void *context) char *buf2; size_t sz; ret = btr_node_status(ct->btrn[1], 0, BTR_NT_LEAF); - if (ret == -E_BTR_EOF) { + if (ret == -E_EOF) { /* empty blob data packet indicates EOF */ PARA_INFO_LOG("blob sent\n"); ret = send_sb(ct, 1, NULL, 0, SBD_BLOB_DATA, true); if (ret >= 0) - ret = -E_BTR_EOF; + ret = -E_EOF; } if (ret < 0) goto close1; @@ -578,8 +581,9 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr, if (CLIENT_OPT_GIVEN(KEY_FILE, lpr)) kf = para_strdup(CLIENT_OPT_STRING_VAL(KEY_FILE, lpr)); else { + struct stat statbuf; kf = make_message("%s/.paraslash/key.%s", home, user); - if (!file_exists(kf)) { + if (stat(kf, &statbuf) != 0) { /* assume file does not exist */ free(kf); kf = make_message("%s/.ssh/id_rsa", home); }