[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#183029: PATCH: put X, XIM, Xfs unix sockets in /var/run/X11



Package: xfree86
Version: unavailable; reported 2003-03-01
Severity: wishlist
Tags: patch

As requested I'm re-transmitting this as a wishlist bug.

I edited the change to debian/xfree86-common.README.Debian so that it
now says "4.3.0-1" instead of "4.2.1-6".  4.2.1-6 is already out the
door, and I'm guessing you'd rather look at this in the 4.3.x timeframe
anyway.

----

This patch moves the UNIX domain sockets created by the X server, the
font server, and XIM input methods from various .subdirs of /tmp to
/var/run/X11, which directory is created at boot time by the existing
xfree86-common init script.

This change naturally has backward compatibility implications.  There
are several cases to consider:

* New client, old server (for any of the above): logic exists in the
  Xtrans client code to try an old location if the socket is not found
  in the new one, so this is not a problem.

* New X server, old libX11: The boot script creates a symbolic link
  from /tmp/.X11-unix to /var/run/X11, which should prevent any
  trouble in this case.  (Users who know they don't need this can
  disable it.)

* New font server or input method, old X server: This is unlikely to
  come up, but the boot script can be edited to create more symlinks
  if necessary.  README.Debian documents this.

I did not move the socket directory for libICE, because those sockets
get created by arbitrary users.  The major point of moving sockets to
/var/run/X11 is that that directory can be mode 755.  I can think of a
couple ways to get around that but they're all messy enough not to be
worth it.

I also did not move /tmp/.X%d-lock as that would break cohabitation of
old and new X servers on the same host.

zw

--- xc/config/cf/linux.cf~	2003-02-06 23:42:21.000000000 -0800
+++ xc/config/cf/linux.cf	2003-02-14 14:17:55.000000000 -0800
@@ -125,7 +125,8 @@
 # define SharedLibGlu		YES
 # define NormalLibGlu		YES
 # define FSUseSyslog		YES
+# define UnixSocketsInVarRun	YES

 /*
  *
--- xc/config/cf/X11.tmpl~	2003-02-06 20:56:37.000000000 -0800
+++ xc/config/cf/X11.tmpl	2003-02-14 14:21:07.000000000 -0800
@@ -562,6 +562,10 @@
 #define InstallMiscManPages	NO
 #endif
 
+#ifndef UnixSocketsInVarRun
+#define UnixSocketsInVarRun	NO
+#endif
+
 #ifndef FSUseSyslog
 #define FSUseSyslog		NO
 #endif
@@ -704,8 +708,11 @@
 #if HasFchown
 FCHOWN_DEFINES = -DHAS_FCHOWN
 #endif
+#if UnixSocketsInVarRun
+USLOC_DEFINES = -DSOCKETS_IN_VAR_RUN
+#endif
 #ifndef ExtraConnectionDefs
-#define ExtraConnectionDefs $(STICKY_DEFINES) $(FCHOWN_DEFINES)
+#define ExtraConnectionDefs $(STICKY_DEFINES) $(FCHOWN_DEFINES) $(USLOC_DEFINES)
 #endif
 #ifndef ProjectThreadsDefines
 #define ProjectThreadsDefines -DXTHREADS
--- xc/lib/xtrans/Xtranssock.c~	2001-12-14 11:57:06.000000000 -0800
+++ xc/lib/xtrans/Xtranssock.c	2003-02-14 14:46:14.000000000 -0800
@@ -228,7 +228,40 @@
 #define UNIX_DIR  "/usr/spool/sockets/X11"
 #endif
 
-#else /* !hpux */
+#elif defined(SOCKETS_IN_VAR_RUN)
+
+#if defined(X11_t)
+#define UNIX_PATH "/var/run/X11/X"
+#define UNIX_DIR "/var/run/X11"
+#define OLD_UNIX_PATH "/tmp/.X11-unix/X"
+#endif /* X11_t */
+#if defined(XIM_t)
+#define UNIX_PATH "/var/run/X11/XIM"
+#define UNIX_DIR "/var/run/X11"
+#define OLD_UNIX_PATH "/tmp/.XIM-unix/XIM"
+#endif /* XIM_t */
+#if defined(FS_t) || defined(FONT_t)
+#define UNIX_PATH "/var/run/X11/fs"
+#define UNIX_DIR "/var/run/X11"
+#define OLD_UNIX_PATH "/tmp/.font-unix/fs"
+#endif /* FS_t || FONT_t */
+#if defined(ICE_t)
+/* ICE sockets stay in /tmp since those are created by clients.  */
+#define UNIX_PATH "/tmp/.ICE-unix/"
+#define UNIX_DIR "/tmp/.ICE-unix"
+#endif /* ICE_t */
+#if defined(TEST_t)
+/* ??? Does not appear to be used for anything.  */
+#define UNIX_PATH "/tmp/.Test-unix/test"
+#define UNIX_DIR "/tmp/.Test-unix"
+#endif
+#if defined(LBXPROXY_t)
+#define UNIX_PATH "/var/run/X11/X"
+#define UNIX_DIR "/var/run/X11"
+#define OLD_UNIX_PATH "/tmp/.X11-unix/X"
+#endif
+
+#else /* not hpux and not /var/run/X11 */
 
 #if defined(X11_t)
 #define UNIX_PATH "/tmp/.X11-unix/X"
@@ -1552,7 +1585,7 @@
     struct sockaddr_un	sockname;
     int			namelen;
 
-#if defined(hpux) && defined(X11_t)
+#ifdef OLD_UNIX_PATH
     struct sockaddr_un	old_sockname;
     int			old_namelen;
 #endif
@@ -1607,9 +1640,9 @@
 #endif
 
 
-#if defined(hpux) && defined(X11_t)
+#ifdef OLD_UNIX_PATH
     /*
-     * This is gross, but it was in Xlib
+     * Support an older location for the socket.
      */
     old_sockname.sun_family = AF_UNIX;
     if (set_sun_path(port, OLD_UNIX_PATH, old_sockname.sun_path) != 0) {
@@ -1620,7 +1653,6 @@
 	sizeof (old_sockname.sun_family);
 #endif
 
-
     /*
      * Do the connect()
      */
@@ -1630,7 +1662,7 @@
 	int olderrno = errno;
 	int connected = 0;
 	
-#if defined(hpux) && defined(X11_t)
+#ifdef OLD_UNIX_PATH
 	if (olderrno == ENOENT)
 	{
 	    if (connect (ciptr->fd,
--- debian/xfree86-common.init~	2003-02-06 20:54:23.000000000 -0800
+++ debian/xfree86-common.init	2003-02-14 14:59:05.000000000 -0800
@@ -4,7 +4,12 @@
 set -e
 
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
-SOCKET_DIR=/tmp/.X11-unix
+
+# By default this script creates symlinks only for /tmp/.X11-unix.
+# .XIM-unix and .font-unix were also moved.  You can edit this list to
+# create symlinks for them too.
+MOVED_SOCKETS=".X11-unix"
+SOCKET_DIR=/var/run/X11
 
 set_up_socket_dir () {
   echo -n "Setting up X server socket directory $SOCKET_DIR..."
@@ -13,17 +18,27 @@
   fi
   mkdir -p $SOCKET_DIR
   chown 0:0 $SOCKET_DIR
-  chmod 1777 $SOCKET_DIR
-  echo "done.";
+  chmod 755 $SOCKET_DIR
+  echo "done."
+}
+
+create_compatibility_symlinks () {
+  echo -n "Creating compatibility links:"
+  for l in $MOVED_SOCKETS; do
+    echo -n " $l"
+    COMPAT_DIR=/tmp/$1
+    if [ -e $COMPAT_DIR -a ! -l $COMPAT_DIR ]; then
+      mv $COMPAT_DIR $COMPAT_DIR.$$
+    fi
+    ln -sf $SOCKET_DIR $COMPAT_DIR
+  done
+  echo " done."
 }
 
 case "$1" in
-  start)
+  start|restart|reload|force-reload)
     set_up_socket_dir
-  ;;
-
-  restart|reload|force-reload)
-    /etc/init.d/xfree86-common start
+    create_compatibility_symlinks
   ;;
 
   stop)
--- debian/xfree86-common.README.Debian~	2003-02-06 20:54:24.000000000 -0800
+++ debian/xfree86-common.README.Debian	2003-02-14 15:12:13.000000000 -0800
@@ -15,6 +15,12 @@
 using the Debian alternatives mechanism.  See update-alternatives(8) for
 more information.
 
+As of version 4.3.0-1, the local domain sockets used by the X server,
+the font server, and various input methods have been moved from /tmp
+to /var/run.  A compatibility symlink is created for the X server's
+socket directory, but not the other two.  If you need more
+compatibility links, edit /etc/init.d/xfree86-common.
+
 Use "dpkg --print-avail <package>" to read the extended descriptions of
 the XFree86 packages and get some idea of their contents.
 






Reply to: