xdm/xdm-tolerant-hostname-changes.diff
Stefan Dirsch 2c6883d173 - Split out displaymanager-sycconfig package: The central
configuration part that is used by all display managers. This is
  needed in order to progress towards 'xdm' not acting as wrapper
  around DMs, but only be used as Dislplay Manager when XDM is
  supposed to be used, or use the real systemd services of the
  various DMs (e.g gdm.service, sddm.service).

Part of https://en.opensuse.org/openSUSE:DisplayManagerRework

GDM for example can allready fully be used without XDM (and xorg-x11-server) installed
The sysconfig split out is needed for the GDM Autoconfiguration, which does not rely
on XDM being the wrapper - but having that part common for all DMs is a good thing

OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/xdm?expand=0&rev=279
2024-11-27 14:40:15 +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;