X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command.c;h=69bbbb74dd2831791e0f24378d7a4c4451bb6524;hp=34e6494f972e4fad90ea1dbdeeb2f878e3264ced;hb=1d54a5412ef39590022e6dd4448881f267e96d0b;hpb=e4db7671a91a7552c642acc979f0eb278f8d467f diff --git a/command.c b/command.c index 34e6494f..69bbbb74 100644 --- a/command.c +++ b/command.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -26,7 +25,6 @@ #include "list.h" #include "send.h" #include "vss.h" -#include "rc4.h" #include "net.h" #include "daemon.h" #include "fd.h" @@ -36,6 +34,7 @@ #include "afs_command_list.h" #include "sched.h" #include "signal.h" +#include "version.h" /** Commands including options must be shorter than this. */ #define MAX_COMMAND_LEN 32768 @@ -123,16 +122,22 @@ static char *get_status(struct misc_meta_data *nmmd, int parser_friendly) strftime(mtime, 29, "%b %d %Y", &mtime_tm); } gettimeofday(¤t_time, NULL); - WRITE_STATUS_ITEM(&b, SI_FILE_SIZE, "%zu\n", nmmd->size / 1024); - WRITE_STATUS_ITEM(&b, SI_MTIME, "%s\n", mtime); - WRITE_STATUS_ITEM(&b, SI_STATUS, "%s\n", status); - WRITE_STATUS_ITEM(&b, SI_STATUS_FLAGS, "%s\n", flags); - WRITE_STATUS_ITEM(&b, SI_OFFSET, "%li\n", offset); - WRITE_STATUS_ITEM(&b, SI_AFS_MODE, "%s\n", mmd->afs_mode_string); - WRITE_STATUS_ITEM(&b, SI_STREAM_START, "%lu.%lu\n", + /* + * The calls to WRITE_STATUS_ITEM() below never fail because + * b->max_size is zero (unlimited), see para_printf(). However, clang + * is not smart enough to prove this and complains nevertheless. + * Casting the return value to void silences solves this. + */ + (void)WRITE_STATUS_ITEM(&b, SI_FILE_SIZE, "%zu\n", nmmd->size / 1024); + (void)WRITE_STATUS_ITEM(&b, SI_MTIME, "%s\n", mtime); + (void)WRITE_STATUS_ITEM(&b, SI_STATUS, "%s\n", status); + (void)WRITE_STATUS_ITEM(&b, SI_STATUS_FLAGS, "%s\n", flags); + (void)WRITE_STATUS_ITEM(&b, SI_OFFSET, "%li\n", offset); + (void)WRITE_STATUS_ITEM(&b, SI_AFS_MODE, "%s\n", mmd->afs_mode_string); + (void)WRITE_STATUS_ITEM(&b, SI_STREAM_START, "%lu.%lu\n", (long unsigned)nmmd->stream_start.tv_sec, (long unsigned)nmmd->stream_start.tv_usec); - WRITE_STATUS_ITEM(&b, SI_CURRENT_TIME, "%lu.%lu\n", + (void)WRITE_STATUS_ITEM(&b, SI_CURRENT_TIME, "%lu.%lu\n", (long unsigned)current_time.tv_sec, (long unsigned)current_time.tv_usec); free(flags); @@ -710,7 +715,7 @@ static void reset_signals(void) * calls this function. * * An RSA-based challenge/response is used to authenticate - * the peer. It that authentication succeeds, a random RC4 + * the peer. It that authentication succeeds, a random * session key is generated and sent back to the peer, * encrypted with its RSA public key. From this point on, * all transfers are crypted with this session key. @@ -730,8 +735,8 @@ __noreturn void handle_connect(int fd, const char *peername) { int ret, argc; char buf[4096]; - unsigned char rand_buf[CHALLENGE_SIZE + 2 * RC4_KEY_LEN]; - unsigned char challenge_sha1[HASH_SIZE]; + unsigned char rand_buf[CHALLENGE_SIZE + 2 * SESSION_KEY_LEN]; + unsigned char challenge_hash[HASH_SIZE]; struct user *u; struct server_command *cmd = NULL; char **argv = NULL; @@ -796,21 +801,21 @@ __noreturn void handle_connect(int fd, const char *peername) if (!u) goto net_err; /* - * The correct response is the sha1 of the first CHALLENGE_SIZE bytes + * The correct response is the hash of the first CHALLENGE_SIZE bytes * of the random data. */ ret = -E_BAD_AUTH; if (numbytes != HASH_SIZE) goto net_err; - sha1_hash((char *)rand_buf, CHALLENGE_SIZE, challenge_sha1); - if (memcmp(challenge_sha1, buf, HASH_SIZE)) + hash_function((char *)rand_buf, CHALLENGE_SIZE, challenge_hash); + if (memcmp(challenge_hash, buf, HASH_SIZE)) goto net_err; /* auth successful */ alarm(0); PARA_INFO_LOG("good auth for %s\n", u->name); /* init stream cipher keys with the second part of the random buffer */ - scc.recv = sc_new(rand_buf + CHALLENGE_SIZE, RC4_KEY_LEN); - scc.send = sc_new(rand_buf + CHALLENGE_SIZE + RC4_KEY_LEN, RC4_KEY_LEN); + scc.recv = sc_new(rand_buf + CHALLENGE_SIZE, SESSION_KEY_LEN); + scc.send = sc_new(rand_buf + CHALLENGE_SIZE + SESSION_KEY_LEN, SESSION_KEY_LEN); ret = sc_send_buffer(&scc, PROCEED_MSG); if (ret < 0) goto net_err;