server: Don't pass peername to handle_connect().
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 6 Aug 2017 21:45:38 +0000 (23:45 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 2 Oct 2017 06:30:51 +0000 (08:30 +0200)
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.

command.c
server.c
server.h

index 07add425d2fc7bbebfe18d028aa8b719d7a86099..9d5723173e043e3d2d882c3c0948da1064011144 100644 (file)
--- a/command.c
+++ b/command.c
@@ -804,8 +804,7 @@ out:
 
 #define HANDSHAKE_BUFSIZE 4096
 
 
 #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;
 {
        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;
                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);
        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.
  * 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.
  *
  * 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.
  */
  *
  * \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];
 {
        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 = 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;
        free(iov.iov_base);
        if (ret < 0)
                goto err_out;
index b86137f9a9e0c32139b50a7fd05b8d7048381f86..c9605d2f7b94e0a7b64372469ce1713154a749d0 100644 (file)
--- 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);
                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)
        /* never reached*/
 out:
        if (ret < 0)
index 079ff5a01cb8c70740aea1012df64014de56cf31..23feadd1eee4016da4cdb124dff807137d166df2 100644 (file)
--- 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)))
 
 #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);
 void parse_config_or_die(bool reload);
 char *server_get_tasks(void);