Remove Xau support.
authorAuke Kok <auke-jan.h.kok@intel.com>
Tue, 17 Apr 2012 18:08:37 +0000 (11:08 -0700)
committerAuke Kok <auke-jan.h.kok@intel.com>
Tue, 17 Apr 2012 18:08:37 +0000 (11:08 -0700)
After looking through this, I don't see any other way that Xauth
support is providing functionality other than to remote displays,
which exclude ssh X forwarding. Remote displays are in the form
where DISPLAY=some-other-machine:0.

We really don't care for those at all at this time, so let's
remove all this legacy support that we don't need as it just
complicates things.

configure.ac
src/main.c
src/user-session.h
src/user.c
src/xserver.c

index de6b026..4169b0d 100644 (file)
@@ -12,9 +12,6 @@ AC_CONFIG_HEADERS([config.h])
 AC_PROG_CC
 AC_PROG_INSTALL
 
-# FIXME: Replace `main' with a function in `-lXau':
-AC_CHECK_LIB([Xau], [main], ,
-            AC_MSG_ERROR([libXau is required but was not found]))
 # FIXME: Replace `main' with a function in `-lpam':
 AC_CHECK_LIB([pam], [main], ,
             AC_MSG_ERROR([libpam is required but was not found]))
index 9471653..383782e 100644 (file)
@@ -133,8 +133,6 @@ int main(int argc, char **argv)
        // close_consolekit_session();
        close_pam_session();
 
-       unlink(xauth_cookie_file);
-
        /* Make sure that we clean up after ourselves */
        sleep(1);
 
index a130865..b47d008 100644 (file)
@@ -14,9 +14,6 @@ extern struct passwd *pass;
 
 extern char displaydev[];
 extern char displayname[];
-extern char xauth_cookie_file[];
-extern Xauth x_auth;
-extern char user_xauth_path[];
 
 extern int tty;
 extern char session[];
@@ -36,7 +33,6 @@ extern void close_pam_session(void);
 extern void switch_to_user(void);
 extern void setup_user_environment(void);
 extern void set_tty(void);
-extern void setup_xauth(void);
 extern void start_X_server(void);
 extern void wait_for_X_signal(void);
 extern void wait_for_session_exit(void);
index 8d06414..640c03e 100644 (file)
@@ -33,8 +33,6 @@
 static int uid;
 struct passwd *pass;
 
-char user_xauth_path[PATH_MAX];
-
 static void do_env(void)
 {
        char buf[PATH_MAX];
@@ -54,8 +52,6 @@ static void do_env(void)
        setenv("DISPLAY", displayname, 1);
        snprintf(buf, PATH_MAX, "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:%s/bin", pass->pw_dir);
        setenv("PATH", buf, 1);
-       snprintf(user_xauth_path, PATH_MAX, "%s/.Xauthority", pass->pw_dir);
-       setenv("XAUTHORITY", user_xauth_path, 1);
 
        file = popen("/bin/bash -l -c export", "r");
        if (!file)
@@ -143,15 +139,6 @@ void switch_to_user(void)
 
        ret = chdir(pass->pw_dir);
 
-       setup_xauth();
-
-       fp = fopen(user_xauth_path, "w");
-       if (fp) {
-               if (XauWriteAuth(fp, &x_auth) != 1)
-                       lprintf("Unable to write .Xauthority");
-               fclose(fp);
-       }
-
        d_out();
 }
 
index 32b7fe5..41702a4 100644 (file)
 
 #include "user-session.h"
 
-#include <X11/Xauth.h>
-
 char displaydev[PATH_MAX];     /* "/dev/tty1" */
 char displayname[256] = ":0";  /* ":0" */
-char xauth_cookie_file[PATH_MAX];
-Xauth x_auth;
 
 static pthread_mutex_t notify_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t notify_condition = PTHREAD_COND_INITIALIZER;
@@ -87,72 +83,6 @@ void set_tty(void)
        d_out();
 }
 
-void setup_xauth(void)
-{
-       FILE *fp;
-       int fd;
-       static char cookie[16];
-       struct utsname uts;
-
-       static char xau_address[80];
-       static char xau_number[] = "0"; // FIXME, detect correct displaynum
-       static char xau_name[] = "MIT-MAGIC-COOKIE-1";
-
-       d_in();
-
-       fp = fopen("/dev/urandom", "r");
-       if (!fp)
-               return;
-       if (fgets(cookie, sizeof(cookie), fp) == NULL) {
-               fclose(fp);
-               return;
-       }
-       fclose(fp);
-
-       /* construct xauth data */
-       if (uname(&uts) < 0) {
-               lprintf("uname failed");
-               return;
-       }
-
-       sprintf(xau_address, "%s", uts.nodename);
-       x_auth.family = FamilyLocal;
-       x_auth.address = xau_address;
-       x_auth.number = xau_number;
-       x_auth.name = xau_name;
-       x_auth.address_length = strlen(xau_address);
-       x_auth.number_length = strlen(xau_number);
-       x_auth.name_length = strlen(xau_name);
-       x_auth.data = (char *) cookie;
-       x_auth.data_length = sizeof(cookie);
-
-       snprintf(xauth_cookie_file, PATH_MAX, "/run/user/%s/Xauth-XXXXXX",
-                pass->pw_name);
-
-       fd = mkstemp(xauth_cookie_file);
-       if (fd < 0) {
-               lprintf("unable to make tmp file for xauth");
-               return;
-       }
-
-       lprintf("Xauth cookie file: %s", xauth_cookie_file);
-
-       fp = fdopen(fd, "a");
-       if (!fp) {
-               lprintf("unable to open xauth fp");
-               close(fd);
-               return;
-       }
-
-       /* write it out to disk */
-       if (XauWriteAuth(fp, &x_auth) != 1)
-               lprintf("unable to write xauth data to disk");
-
-       fclose(fp);
-
-       d_out();
-}
-
 static void usr1handler(int foo)
 {
        /* Got the signal from the X server that it's ready */
@@ -286,9 +216,6 @@ void start_X_server(void)
 
        ptrs[++count] = strdup("-noreset");
 
-       ptrs[++count] = strdup("-auth");
-       ptrs[++count] = user_xauth_path;
-
        opt = strtok(addn_xopts, " ");
        while (opt) {
          dprintf("adding xopt: \"%s\"", opt);