From: Andre Noll Date: Sun, 6 Aug 2017 21:45:38 +0000 (+0200) Subject: server: Don't pass peername to handle_connect(). X-Git-Tag: v0.6.2~53 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=1c8218665d39f212eb7cddaea70c5ab66d7e26c7 server: Don't pass peername to handle_connect(). The only reason we pass it is that handle_connect() can print a log message containing the peer name. However, we already log this information right after the connection was accepted. --- diff --git a/command.c b/command.c index 07add425..9d572317 100644 --- a/command.c +++ b/command.c @@ -804,8 +804,7 @@ out: #define HANDSHAKE_BUFSIZE 4096 -static int run_command(struct command_context *cc, struct iovec *iov, - const char *peername) +static int run_command(struct command_context *cc, struct iovec *iov) { int ret, i, argc; char *p, *end, **argv; @@ -838,8 +837,8 @@ static int run_command(struct command_context *cc, struct iovec *iov, p += strlen(p) + 1; } argv[argc] = NULL; - PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", lls_command_name(lcmd), - cc->u->name, peername); + PARA_NOTICE_LOG("calling com_%s() for user %s\n", + lls_command_name(lcmd), cc->u->name); ret = lls(lls_parse(argc, argv, lcmd, &lpr, &errctx)); if (ret >= 0) { const struct server_cmd_user_data *ud = lls_user_data(lcmd); @@ -860,7 +859,6 @@ static int run_command(struct command_context *cc, struct iovec *iov, * Perform user authentication and execute a command. * * \param fd The file descriptor to send output to. - * \param peername Identifies the connecting peer. * * Whenever para_server accepts an incoming tcp connection on the port it * listens on, it forks and the resulting child calls this function. @@ -881,7 +879,7 @@ static int run_command(struct command_context *cc, struct iovec *iov, * * \sa alarm(2), \ref crypt.c, \ref crypt.h. */ -__noreturn void handle_connect(int fd, const char *peername) +__noreturn void handle_connect(int fd) { int ret; unsigned char rand_buf[CHALLENGE_SIZE + 2 * SESSION_KEY_LEN]; @@ -967,7 +965,7 @@ __noreturn void handle_connect(int fd, const char *peername) ret = recv_sb(&cc->scc, SBD_COMMAND, MAX_COMMAND_LEN, &iov); if (ret < 0) goto net_err; - ret = run_command(cc, &iov, peername); + ret = run_command(cc, &iov); free(iov.iov_base); if (ret < 0) goto err_out; diff --git a/server.c b/server.c index b86137f9..c9605d2f 100644 --- a/server.c +++ b/server.c @@ -392,7 +392,7 @@ static int command_post_select(struct sched *s, void *context) memset(sct->argv[i], 0, strlen(sct->argv[i])); i = sct->argc - 1 - lls_num_inputs(cmdline_lpr); sprintf(sct->argv[i], "para_server (serving %s)", peer_name); - handle_connect(new_fd, peer_name); + handle_connect(new_fd); /* never reached*/ out: if (ret < 0) diff --git a/server.h b/server.h index 079ff5a0..23feadd1 100644 --- a/server.h +++ b/server.h @@ -114,6 +114,6 @@ extern struct lls_parse_result *server_lpr; #define ENUM_STRING_VAL(_name) (lls_enum_string_val(OPT_UINT32_VAL(_name), \ lls_opt(LSG_SERVER_PARA_SERVER_OPT_ ## _name, CMD_PTR))) -__noreturn void handle_connect(int fd, const char *peername); +__noreturn void handle_connect(int fd); void parse_config_or_die(bool reload); char *server_get_tasks(void);