File p_xauth.diff of Package xorg-x11

Index: lib/X11/ConnDis.c
===================================================================
RCS file: /home/eich/cvs/xc/lib/X11/ConnDis.c,v
retrieving revision 1.1.1.13
diff -w -u -r1.1.1.13 ConnDis.c
Index: programs/xdm/auth.c
===================================================================
RCS file: /home/eich/cvs/xc/programs/xdm/auth.c,v
retrieving revision 1.1.1.11
diff -w -u -r1.1.1.11 auth.c
Index: programs/xinit/startx.cpp
===================================================================
RCS file: /home/eich/cvs/xc/programs/xinit/startx.cpp,v
retrieving revision 1.1.1.13
diff -w -u -r1.1.1.13 startx.cpp
Index: programs/xauth/gethost.c
===================================================================
RCS file: /home/eich/cvs/xc/programs/xauth/gethost.c,v
retrieving revision 1.1.1.7
diff -w -u -r1.1.1.7 gethost.c
--- programs/xauth/gethost.c	8 Sep 2003 09:32:24 -0000	1.1.1.7
+++ xauth-1.0.3/gethost.c	26 Jul 2005 14:48:29 -0000
@@ -249,7 +249,8 @@
     int family,
     char *fulldpyname,
     int prefix,
-    char *host)
+    char *host,
+    char *localhostname)
 {
     struct addrlist *retval = NULL;
     int len = 0;
@@ -279,7 +280,7 @@
 	if (prefix == 0 && (strncmp (fulldpyname, "unix:", 5) == 0 ||
 			    fulldpyname[0] == ':')) {
 
-	    if (!get_local_hostname (buf, sizeof buf)) {
+	    if (!get_local_hostname (buf, sizeof buf, localhostname)) {
 		len = 0;
 	    } else {
 		src = buf;
Index: programs/xauth/parsedpy.c
===================================================================
RCS file: /home/eich/cvs/xc/programs/xauth/parsedpy.c,v
retrieving revision 1.1.1.6
diff -w -u -r1.1.1.6 parsedpy.c
--- programs/xauth/parsedpy.c	8 Sep 2003 09:32:24 -0000	1.1.1.6
+++ xauth-1.0.3/parsedpy.c	26 Jul 2005 14:48:29 -0000
@@ -69,20 +69,24 @@
 
 
 char *
-get_local_hostname (char *buf, int maxlen)
+get_local_hostname (char *buf, int maxlen, char *localhostname)
 {
     buf[0] = '\0';
+    if (localhostname)
+	strncpy(buf, localhostname, maxlen);
+    else
     (void) XmuGetHostname (buf, maxlen);
+    
     return (buf[0] ? buf : NULL);
 }
 
 #ifndef UNIXCONN
 static char *
-copyhostname (void)
+copyhostname (char *localhostname)
 {
     char buf[256];
 
-    return (get_local_hostname (buf, sizeof buf) ? 
+    return (get_local_hostname (buf, sizeof buf, localhostname) ? 
 	    copystring (buf, strlen (buf)) : NULL);
 }
 #endif
@@ -92,6 +96,7 @@
  */
 Bool 
 parse_displayname (char *displayname, 
+		   char *localhostname,
 		   int *familyp,	/* return */
 		   char **hostp,	/* return */
 		   int *dpynump,	/* return */
@@ -133,7 +138,7 @@
 	    host = copystring ("0", 1);
 	    family = FamilyDECnet;
 	} else {
-	    host = copyhostname ();
+	    host = copyhostname (localhostname);
 	    family = FamilyInternet;
 	}
 #endif
Index: programs/xauth/process.c
===================================================================
RCS file: /home/eich/cvs/xc/programs/xauth/process.c,v
retrieving revision 1.1.1.17
diff -w -u -r1.1.1.17 process.c
--- programs/xauth/process.c	6 Jul 2004 15:11:16 -0000	1.1.1.17
+++ xauth-1.0.3/process.c	26 Jul 2005 14:48:29 -0000
@@ -462,7 +462,7 @@
 }
 
 static Bool 
-get_displayname_auth(char *displayname, AuthList **authl)
+get_displayname_auth(char *displayname, AuthList **authl, char *localhostname)
 {
     int family;
     char *host = NULL, *rest = NULL;
@@ -482,11 +482,13 @@
       prelen = (cp - displayname);
 
     if (!parse_displayname (displayname + ((prelen > 0) ? prelen + 1 : 0),
+			    localhostname,
 			    &family, &host, &dpynum, &scrnum, &rest)) {
 	return False;
     }
 
-    addrlist_head = get_address_info(family, displayname, prelen, host);
+    addrlist_head = get_address_info(family, displayname, prelen, host,
+				     localhostname);
     if (addrlist_head) {
 	char buf[40];			/* want to hold largest display num */
 	unsigned short dpylen;
@@ -1221,13 +1223,19 @@
     Xauth *tmp_auth;
     AuthList *proto_head, *proto;
     AuthList *l, *next;
+    /*
+     * get saved local address from environment in case the host
+     * name has changed after the credential was added.
+     */
+    char *xlocalhostname = getenv("XAUTHLOCALHOSTNAME");
+    
 
     /*
      * iterate
      */
     for (i = start; i < argc; i++) {
 	char *displayname = argv[i];
-	if (!get_displayname_auth (displayname, &proto_head)) {
+	if (!get_displayname_auth (displayname, &proto_head, xlocalhostname)) {
 	    prefix (inputfilename, lineno);
 	    baddisplayname (displayname, argv[0]);
 	    errors++;
@@ -1566,7 +1574,7 @@
 	}
     }
 
-    if (!get_displayname_auth (dpyname, &list)) {
+    if (!get_displayname_auth (dpyname, &list, NULL)) {
 	prefix (inputfilename, lineno);
 	baddisplayname (dpyname, argv[0]);
 	free (key);
Index: programs/xauth/xauth.h
===================================================================
RCS file: /home/eich/cvs/xc/programs/xauth/xauth.h,v
retrieving revision 1.1.1.6
diff -w -u -r1.1.1.6 xauth.h
--- programs/xauth/xauth.h	8 Sep 2003 09:32:24 -0000	1.1.1.6
+++ xauth-1.0.3/xauth.h	26 Jul 2005 14:48:29 -0000
@@ -51,10 +51,10 @@
 };
 
 extern char *get_hostname ( Xauth *auth );
-extern struct addrlist *get_address_info ( int family, char *fulldpyname, int prefix, char *host);
+extern struct addrlist *get_address_info ( int family, char *fulldpyname, int prefix, char *host, char *localhostname);
 extern char *copystring ( char *src, int len );
-extern char *get_local_hostname ( char *buf, int maxlen );
-extern Bool parse_displayname ( char *displayname, int *familyp, char **hostp, int *dpynump, int *scrnump, char **restp );
+extern char *get_local_hostname ( char *buf, int maxlen , char *localhostname);
+extern Bool parse_displayname ( char *displayname, char *localhostname, int *familyp, char **hostp, int *dpynump, int *scrnump, char **restp );
 extern int auth_initialize ( char *authfilename );
 extern int auth_finalize ( void );
 extern int process_command ( char *inputfilename, int lineno, int argc, char **argv );
--- programs/xdm/auth.c.orig	2005-11-09 10:41:27.000000000 +0100
+++ xdm-1.1.8/auth.c	2005-11-11 11:33:00.000000000 +0100
@@ -680,7 +680,7 @@
 }
 
 static void
-DefineLocal (FILE *file, Xauth *auth)
+DefineLocal (FILE *file, Xauth *auth, char **pLocalAddress)
 {
 	char	displayname[100];
 	int	len = _XGetHostname (displayname, sizeof(displayname));
@@ -716,6 +716,9 @@
 #endif
 
 	writeAddr (FamilyLocal, len, displayname, file, auth);
+
+        if (pLocalAddress && displayname)
+           *pLocalAddress = strdup(displayname);
 }
 
 #ifdef HAS_GETIFADDRS
@@ -1148,7 +1151,7 @@
 }
 
 static void
-writeLocalAuth (FILE *file, Xauth *auth, char *name)
+writeLocalAuth (FILE *file, Xauth *auth, char *name, char **pLocalAddress)
 {
     int	fd;
 
@@ -1175,13 +1178,13 @@
     DefineSelf (fd, file, auth);
     close (fd);
 #endif
-    DefineLocal (file, auth);
+    DefineLocal (file, auth, pLocalAddress);
 }
 
 #ifdef XDMCP
 
 static void
-writeRemoteAuth (FILE *file, Xauth *auth, XdmcpNetaddr peer, int peerlen, char *name)
+writeRemoteAuth (FILE *file, Xauth *auth, XdmcpNetaddr peer, int peerlen, char *name, char **pLocalAddress)
 {
     int	    family = FamilyLocal;
     char    *addr;
@@ -1200,7 +1203,7 @@
     }
     else
     {
-	writeLocalAuth (file, auth, name);
+	writeLocalAuth (file, auth, name, pLocalAddress);
     }
 }
 
@@ -1224,6 +1227,7 @@
 #ifdef HAS_MKSTEMP
     int		fd;
 #endif
+    char	*localAddress = NULL;
 
     Debug ("SetUserAuthorization\n");
     auths = d->authorizations;
@@ -1316,10 +1320,10 @@
 	    {
 		magicCookie = i;
 	    	if (d->displayType.location == Local)
-	    	    writeLocalAuth (new, auths[i], d->name);
+	    	    writeLocalAuth (new, auths[i], d->name,&localAddress);
 #ifdef XDMCP
 	    	else
-	    	    writeRemoteAuth (new, auths[i], d->peer, d->peerlen, d->name);
+	    	    writeRemoteAuth (new, auths[i], d->peer, d->peerlen, d->name, &localAddress);
 #endif
 		break;
 	    }
@@ -1337,10 +1341,10 @@
 		    !strncmp (auths[i]->name, "MIT-KERBEROS-5", 14))
 		    auths[i]->data_length = 0;
 	    	if (d->displayType.location == Local)
-	    	    writeLocalAuth (new, auths[i], d->name);
+	    	    writeLocalAuth (new, auths[i], d->name, &localAddress);
 #ifdef XDMCP
 	    	else
-	    	    writeRemoteAuth (new, auths[i], d->peer, d->peerlen, d->name);
+	    	    writeRemoteAuth (new, auths[i], d->peer, d->peerlen, d->name, &localAddress);
 #endif
 		auths[i]->data_length = data_len;
 	    }
@@ -1379,6 +1383,12 @@
 	    verify->systemEnviron = setEnv (verify->systemEnviron,
 				    "XAUTHORITY", envname);
 	}
+	if (localAddress) {
+	    verify->userEnviron = setEnv (verify->userEnviron,
+				    "XAUTHLOCALHOSTNAME",localAddress);
+	    free(localAddress);
+	}
+	
 	XauUnlockAuth (name);
 	if (envname)
 	    chown (envname, verify->uid, verify->gid);
@@ -1417,10 +1427,10 @@
 	for (i = 0; i < d->authNum; i++)
 	{
 	    if (d->displayType.location == Local)
-	    	writeLocalAuth (new, auths[i], d->name);
+	    	writeLocalAuth (new, auths[i], d->name, NULL);
 #ifdef XDMCP
 	    else
-	    	writeRemoteAuth (new, auths[i], d->peer, d->peerlen, d->name);
+	    	writeRemoteAuth (new, auths[i], d->peer, d->peerlen, d->name,NULL);
 #endif
 	}
 	doWrite = 1;
--- programs/xinit/startx.cpp.orig	2005-11-11 11:16:53.000000000 +0100
+++ xinit-1.1.0/startx.cpp	2005-11-11 11:35:19.000000000 +0100
@@ -328,6 +328,7 @@
 . /etc/sysconfig/displaymanager
 test "$DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN" != "yes" && \
   serverargs="$serverargs -nolisten tcp"
+export XAUTHLOCALHOSTNAME=`hostname`
 XINIT $client $clientargs -- $server $display $serverargs
 #endif
 
openSUSE Build Service is sponsored by