xdm/xdm-tolerant-hostname-changes.diff
Stefan Dirsch ab86098dd1 - Update to release 1.1.15
* This release fixes a failure to build with the upcoming gcc 14, 
    cleans up several other compiler warnings, fixes a bug in the
    generation of the xdm.service file for systemd, and removes a
    lot of dead code checks for platforms & features that have not
    been supported since the conversion from Imake to autoconf in
    2005.
-  supersedes u_gcc14-fix.patch

OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/xdm?expand=0&rev=271
2024-03-24 08:46:34 +00:00

118 lines
3.4 KiB
Diff

Index: xdm/auth.c
===================================================================
--- xdm.orig/auth.c
+++ xdm/auth.c
@@ -744,7 +744,7 @@ writeAddr (
}
static void
-DefineLocal (FILE *file, Xauth *auth)
+DefineLocal (FILE *file, Xauth *auth, char **pLocalAddress)
{
char displayname[100];
int len = _XGetHostname (displayname, sizeof(displayname));
@@ -759,6 +759,9 @@ DefineLocal (FILE *file, Xauth *auth)
writeAddr (FamilyLocal, len, displayname, file, auth);
+
+ if (pLocalAddress)
+ *pLocalAddress = strdup(displayname);
}
#ifdef HAVE_GETIFADDRS
@@ -1019,7 +1022,7 @@ setAuthNumber (Xauth *auth, char *name)
}
static void
-writeLocalAuth (FILE *file, Xauth *auth, char *name)
+writeLocalAuth (FILE *file, Xauth *auth, char *name, char **pLocalAddress)
{
int fd;
@@ -1034,13 +1037,13 @@ writeLocalAuth (FILE *file, Xauth *auth,
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;
@@ -1059,7 +1062,7 @@ writeRemoteAuth (FILE *file, Xauth *auth
}
else
{
- writeLocalAuth (file, auth, name);
+ writeLocalAuth (file, auth, name, pLocalAddress);
}
}
@@ -1083,6 +1086,7 @@ SetUserAuthorization (struct display *d,
#ifdef HAVE_MKSTEMP
int fd;
#endif
+ char *localAddress = NULL;
Debug ("SetUserAuthorization\n");
auths = d->authorizations;
@@ -1175,10 +1179,10 @@ SetUserAuthorization (struct display *d,
{
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;
}
@@ -1196,10 +1200,10 @@ SetUserAuthorization (struct display *d,
!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;
}
@@ -1244,6 +1248,12 @@ SetUserAuthorization (struct display *d,
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);
@@ -1282,10 +1292,10 @@ RemoveUserAuthorization (struct display
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;