From patchwork Mon Jan 14 00:02:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 10761449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DA11159A for ; Mon, 14 Jan 2019 00:06:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DCEB28893 for ; Mon, 14 Jan 2019 00:06:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71A2A289A5; Mon, 14 Jan 2019 00:06:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E3AB028893 for ; Mon, 14 Jan 2019 00:06:28 +0000 (UTC) Received: from localhost ([127.0.0.1]:38018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gipls-0004O7-5R for patchwork-qemu-devel@patchwork.kernel.org; Sun, 13 Jan 2019 19:06:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gipjz-0002uu-Ie for qemu-devel@nongnu.org; Sun, 13 Jan 2019 19:04:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gipjt-0006FZ-SC for qemu-devel@nongnu.org; Sun, 13 Jan 2019 19:04:29 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:60064) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gipjm-0006AT-Lh for qemu-devel@nongnu.org; Sun, 13 Jan 2019 19:04:21 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 4A6931B8D; Mon, 14 Jan 2019 01:04:14 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id viWYWKhvoueY; Mon, 14 Jan 2019 01:04:13 +0100 (CET) Received: from function.home (lfbn-1-11161-124.w86-213.abo.wanadoo.fr [86.213.235.124]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 0FF861B8E; Mon, 14 Jan 2019 01:04:06 +0100 (CET) Received: from samy by function.home with local (Exim 4.92-RC4) (envelope-from ) id 1gipjY-0007nD-KR; Mon, 14 Jan 2019 01:04:04 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org Date: Mon, 14 Jan 2019 01:02:23 +0100 Message-Id: <20190114000326.29847-3-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114000326.29847-1-samuel.thibault@ens-lyon.org> References: <20190114000326.29847-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 185.233.100.1 Subject: [Qemu-devel] [PULL 02/65] slirp: remove do_pty from fork_exec() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau QEMU uses fork_exec() with do_pty values 0 or 3. Let's clean up some unused code. Signed-off-by: Marc-André Lureau Signed-off-by: Samuel Thibault --- slirp/misc.c | 55 ++++++++++++++---------------------------------- slirp/misc.h | 2 +- slirp/tcp_subr.c | 4 +--- 3 files changed, 18 insertions(+), 43 deletions(-) diff --git a/slirp/misc.c b/slirp/misc.c index 57bdd808e2..e69d5f42c3 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -63,7 +63,7 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, #ifdef _WIN32 int -fork_exec(struct socket *so, const char *ex, int do_pty) +fork_exec(struct socket *so, const char *ex) { /* not implemented */ return 0; @@ -77,13 +77,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty) * process, which connects to this socket, after which we * exec the wanted program. If something (strange) happens, * the accept() call could block us forever. - * - * do_pty = 0 Fork/exec inetd style - * do_pty = 1 Fork/exec using slirp.telnetd - * do_ptr = 2 Fork/exec using pty */ int -fork_exec(struct socket *so, const char *ex, int do_pty) +fork_exec(struct socket *so, const char *ex) { int s, cs; struct sockaddr_in addr, csaddr; @@ -100,26 +96,20 @@ fork_exec(struct socket *so, const char *ex, int do_pty) DEBUG_CALL("fork_exec"); DEBUG_ARG("so = %p", so); DEBUG_ARG("ex = %p", ex); - DEBUG_ARG("do_pty = %x", do_pty); - - if (do_pty == 2) { - return 0; - } else { - addr.sin_family = AF_INET; - addr.sin_port = 0; - addr.sin_addr.s_addr = INADDR_ANY; - if ((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0 || - bind(s, (struct sockaddr *)&addr, addrlen) < 0 || - listen(s, 1) < 0) { - error_report("Error: inet socket: %s", strerror(errno)); - if (s >= 0) { - closesocket(s); - } + addr.sin_family = AF_INET; + addr.sin_port = 0; + addr.sin_addr.s_addr = INADDR_ANY; - return 0; - } - } + s = qemu_socket(AF_INET, SOCK_STREAM, 0); + if (s < 0 || bind(s, (struct sockaddr *)&addr, addrlen) < 0 || + listen(s, 1) < 0) { + error_report("Error: inet socket: %s", strerror(errno)); + if (s >= 0) { + closesocket(s); + } + return 0; + } if (getsockname(s, (struct sockaddr *)&csaddr, &csaddrlen) < 0) { closesocket(s); @@ -166,13 +156,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty) i = 0; bptr = g_strdup(ex); /* No need to free() this */ - if (do_pty == 1) { - /* Setup "slirp.telnetd -x" */ - argv[i++] = "slirp.telnetd"; - argv[i++] = "-x"; - argv[i++] = bptr; - } else - do { + do { /* Change the string into argv[] */ curarg = bptr; while (*bptr != ' ' && *bptr != (char)0) @@ -180,7 +164,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty) c = *bptr; *bptr++ = (char)0; argv[i++] = g_strdup(curarg); - } while (c); + } while (c); argv[i] = NULL; execvp(argv[0], (char **)argv); @@ -206,13 +190,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty) opt = 1; qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int)); qemu_set_nonblock(so->s); - - /* Append the telnet options now */ - if (so->so_m != NULL && do_pty == 1) { - sbappend(so, so->so_m); - so->so_m = NULL; - } - return 1; } } diff --git a/slirp/misc.h b/slirp/misc.h index 5211bbd30a..897650aea1 100644 --- a/slirp/misc.h +++ b/slirp/misc.h @@ -53,6 +53,6 @@ struct slirp_quehead { void slirp_insque(void *, void *); void slirp_remque(void *); int add_exec(struct ex_list **, int, char *, struct in_addr, int); -int fork_exec(struct socket *so, const char *ex, int do_pty); +int fork_exec(struct socket *so, const char *ex); #endif diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index fa61349cbb..0ccd8e1a96 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -951,7 +951,6 @@ int tcp_ctl(struct socket *so) Slirp *slirp = so->slirp; struct sbuf *sb = &so->so_snd; struct ex_list *ex_ptr; - int do_pty; DEBUG_CALL("tcp_ctl"); DEBUG_ARG("so = %p", so); @@ -966,9 +965,8 @@ int tcp_ctl(struct socket *so) so->extra = (void *)ex_ptr->ex_exec; return 1; } - do_pty = ex_ptr->ex_pty; DEBUG_MISC((dfd, " executing %s\n", ex_ptr->ex_exec)); - return fork_exec(so, ex_ptr->ex_exec, do_pty); + return fork_exec(so, ex_ptr->ex_exec); } } }