[PATCH] Remove /usr/adm/Xnmsgs

Jon TURNEY jon.turney at dronecode.org.uk
Wed Apr 4 09:21:05 PDT 2012


In OsInit(), we check if fd 2 is writeable, and if not, assume stderr has
been closed, and open /usr/adm/X0msgs for writing, and dup it on to fd 2.
Unfortunately, this happens after CreateWellknownSockets() has opened the
listener sockets, and that may use fd 2

Specifically, this can easily triggered by running the X server with stderr
closed (e.g. 'X 2>&-')

So, as it stands, this code could prevent us from listening on one of our
well-known listener sockets, if it happened to get assigned fd 2

Also, if a file fd shows as ready for reading (which apparently SuS requires),
we will constantly try to accept a connection on it, which is always going to
fail, leading to the process spinning.

I can't see what purpose this code serves, we write log output to the logfile,
I don't really see why we need to write it all to another file as well.  The
code itself is unclear ('Never happens' vs. 'if run from init').

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 man/Xserver.man |    3 ---
 os/osinit.c     |   37 -------------------------------------
 2 files changed, 0 insertions(+), 40 deletions(-)

diff --git a/man/Xserver.man b/man/Xserver.man
index 0cd9b94..2f0bf1c 100644
--- a/man/Xserver.man
+++ b/man/Xserver.man
@@ -556,9 +556,6 @@ Outline font directories
 .I /tmp/.X11-unix/X\fBn\fP
 Unix domain socket for display number \fBn\fP
 .TP 30
-.I /usr/adm/X\fBn\fPmsgs
-Error log file for display number \fBn\fP if run from \fIinit\fP(__adminmansuffix__)
-.TP 30
 .I __projectroot__/lib/X11/xdm/xdm-errors
 Default error log file if the server is run from \fIxdm\fP(1)
 .SH "SEE ALSO"
diff --git a/os/osinit.c b/os/osinit.c
index e2a2208..cf7574f 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -70,10 +70,6 @@ SOFTWARE.
 #include <sys/resource.h>
 #endif
 
-#ifndef ADMPATH
-#define ADMPATH "/usr/adm/X%smsgs"
-#endif
-
 extern char *display;
 
 #ifdef RLIMIT_DATA
@@ -207,39 +203,6 @@ OsInit(void)
         fclose(stdin);
         fclose(stdout);
 #endif
-        /* 
-         * If a write of zero bytes to stderr returns non-zero, i.e. -1, 
-         * then writing to stderr failed, and we'll write somewhere else 
-         * instead. (Apparently this never happens in the Real World.)
-         */
-        if (write(2, fname, 0) == -1) {
-            FILE *err;
-
-            if (strlen(display) + strlen(ADMPATH) + 1 < sizeof fname)
-                snprintf(fname, sizeof(fname), ADMPATH, display);
-            else
-                strcpy(fname, devnull);
-            /*
-             * uses stdio to avoid os dependencies here,
-             * a real os would use
-             *  open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666)
-             */
-            if (!(err = fopen(fname, "a+")))
-                err = fopen(devnull, "w");
-            if (err && (fileno(err) != 2)) {
-                dup2(fileno(err), 2);
-                fclose(err);
-            }
-#if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN__)
-            {
-                static char buf[BUFSIZ];
-
-                setvbuf(stderr, buf, _IOLBF, BUFSIZ);
-            }
-#else
-            setlinebuf(stderr);
-#endif
-        }
 
         if (getpgrp() == 0)
             setpgid(0, 0);
-- 
1.7.9



More information about the xorg-devel mailing list