summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-04-20 21:42:20 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-04-20 21:42:20 +0200
commitcbe11fc1c24c75a41aa0f79b2974915dbff5ee00 (patch)
tree8ccbd3d8d07762f8dd4783851e1473586a6cf849
parent4198bb566e442f4bcca2e9625e669dc6a2d17385 (diff)
aux/listen: do not redirect stderr (fd 2) of the listener to the network connection
Charles Forsyth described the problem below in: http://9fans.net/archive/2013/04/190 In a few cases, the kernel will use pprint to put a diagnostic on the standard error (file descriptor 2). One of those is a warning that the process has used more than 100 file descriptors. That message is possibly obsolete and could be removed, but there are others, such as notifying an uncaught trap that are probably helpful to make visible. In any case, as things stand, a busy exportfs might have many file descriptors open, provoking the diagnostic. Unfortunately, aux/listen and aux/listen1 connect file descriptor 2 to the incoming network connection. If the connection's protocol is not a simple, unstructured, textual one, diagnostics on the standard error will cause confusion, in particular to devmnt.c if 9p is used. /rc/bin/service files that start applications that run special protocols might want to redirect file descriptor 2; alternatively, perhaps aux/listen shouldn't redirect fd 2 by default: the few commands that do connect the remote user to shells, or equivalent, including telnetd and sshd could dup 1 to 2 when that was sensible.
-rw-r--r--sys/src/cmd/aux/listen.c2
-rw-r--r--sys/src/cmd/aux/listen1.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/sys/src/cmd/aux/listen.c b/sys/src/cmd/aux/listen.c
index fd236c6d6..fe4d11f92 100644
--- a/sys/src/cmd/aux/listen.c
+++ b/sys/src/cmd/aux/listen.c
@@ -592,7 +592,7 @@ newcall(int fd, char *proto, char *dir, Service *s)
bind(data, "/dev/cons", MREPL);
dup(fd, 0);
dup(fd, 1);
- dup(fd, 2);
+ /* dup(fd, 2); keep stderr */
close(fd);
/*
diff --git a/sys/src/cmd/aux/listen1.c b/sys/src/cmd/aux/listen1.c
index cc22bb14a..c7504fe29 100644
--- a/sys/src/cmd/aux/listen1.c
+++ b/sys/src/cmd/aux/listen1.c
@@ -142,7 +142,7 @@ main(int argc, char **argv)
bind(data, "/dev/cons", MREPL);
dup(fd, 0);
dup(fd, 1);
- dup(fd, 2);
+ /* dup(fd, 2); keep stderr */
close(fd);
exec(argv[1], argv+1);
if(argv[1][0] != '/')