mirror of https://github.com/xqemu/xqemu.git
slirp: remove do_pty from fork_exec()
QEMU uses fork_exec() with do_pty values 0 or 3. Let's clean up some unused code. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
This commit is contained in:
parent
62c1d2c483
commit
43bc7340b5
31
slirp/misc.c
31
slirp/misc.c
|
@ -63,7 +63,7 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec,
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
int
|
int
|
||||||
fork_exec(struct socket *so, const char *ex, int do_pty)
|
fork_exec(struct socket *so, const char *ex)
|
||||||
{
|
{
|
||||||
/* not implemented */
|
/* not implemented */
|
||||||
return 0;
|
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
|
* process, which connects to this socket, after which we
|
||||||
* exec the wanted program. If something (strange) happens,
|
* exec the wanted program. If something (strange) happens,
|
||||||
* the accept() call could block us forever.
|
* 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
|
int
|
||||||
fork_exec(struct socket *so, const char *ex, int do_pty)
|
fork_exec(struct socket *so, const char *ex)
|
||||||
{
|
{
|
||||||
int s, cs;
|
int s, cs;
|
||||||
struct sockaddr_in addr, csaddr;
|
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_CALL("fork_exec");
|
||||||
DEBUG_ARG("so = %p", so);
|
DEBUG_ARG("so = %p", so);
|
||||||
DEBUG_ARG("ex = %p", ex);
|
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_family = AF_INET;
|
||||||
addr.sin_port = 0;
|
addr.sin_port = 0;
|
||||||
addr.sin_addr.s_addr = INADDR_ANY;
|
addr.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
||||||
if ((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0 ||
|
s = qemu_socket(AF_INET, SOCK_STREAM, 0);
|
||||||
bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
|
if (s < 0 || bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
|
||||||
listen(s, 1) < 0) {
|
listen(s, 1) < 0) {
|
||||||
error_report("Error: inet socket: %s", strerror(errno));
|
error_report("Error: inet socket: %s", strerror(errno));
|
||||||
if (s >= 0) {
|
if (s >= 0) {
|
||||||
closesocket(s);
|
closesocket(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (getsockname(s, (struct sockaddr *)&csaddr, &csaddrlen) < 0) {
|
if (getsockname(s, (struct sockaddr *)&csaddr, &csaddrlen) < 0) {
|
||||||
closesocket(s);
|
closesocket(s);
|
||||||
|
@ -166,12 +156,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
bptr = g_strdup(ex); /* No need to free() this */
|
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[] */
|
/* Change the string into argv[] */
|
||||||
curarg = bptr;
|
curarg = bptr;
|
||||||
|
@ -206,13 +190,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
|
||||||
opt = 1;
|
opt = 1;
|
||||||
qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
|
qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
|
||||||
qemu_set_nonblock(so->s);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,6 @@ struct slirp_quehead {
|
||||||
void slirp_insque(void *, void *);
|
void slirp_insque(void *, void *);
|
||||||
void slirp_remque(void *);
|
void slirp_remque(void *);
|
||||||
int add_exec(struct ex_list **, int, char *, struct in_addr, int);
|
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
|
#endif
|
||||||
|
|
|
@ -951,7 +951,6 @@ int tcp_ctl(struct socket *so)
|
||||||
Slirp *slirp = so->slirp;
|
Slirp *slirp = so->slirp;
|
||||||
struct sbuf *sb = &so->so_snd;
|
struct sbuf *sb = &so->so_snd;
|
||||||
struct ex_list *ex_ptr;
|
struct ex_list *ex_ptr;
|
||||||
int do_pty;
|
|
||||||
|
|
||||||
DEBUG_CALL("tcp_ctl");
|
DEBUG_CALL("tcp_ctl");
|
||||||
DEBUG_ARG("so = %p", so);
|
DEBUG_ARG("so = %p", so);
|
||||||
|
@ -966,9 +965,8 @@ int tcp_ctl(struct socket *so)
|
||||||
so->extra = (void *)ex_ptr->ex_exec;
|
so->extra = (void *)ex_ptr->ex_exec;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
do_pty = ex_ptr->ex_pty;
|
|
||||||
DEBUG_MISC((dfd, " executing %s\n", ex_ptr->ex_exec));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue