xdm/xdm-tolerant-hostname-changes.diff

118 lines
3.5 KiB
Diff
Raw Normal View History

Index: xdm-1.1.10/auth.c
===================================================================
--- xdm-1.1.10.orig/auth.c
+++ xdm-1.1.10/auth.c
@@ -769,7 +769,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));
@@ -805,6 +805,9 @@ DefineLocal (FILE *file, Xauth *auth)
#endif
writeAddr (FamilyLocal, len, displayname, file, auth);
+
+ if (pLocalAddress && displayname)
+ *pLocalAddress = strdup(displayname);
}
#ifdef HAS_GETIFADDRS
@@ -1238,7 +1241,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;
@@ -1265,13 +1268,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;
@@ -1290,7 +1293,7 @@ writeRemoteAuth (FILE *file, Xauth *auth
}
else
{
- writeLocalAuth (file, auth, name);
+ writeLocalAuth (file, auth, name, pLocalAddress);
}
}
@@ -1314,6 +1317,7 @@ SetUserAuthorization (struct display *d,
#ifdef HAS_MKSTEMP
int fd;
#endif
+ char *localAddress = NULL;
Debug ("SetUserAuthorization\n");
auths = d->authorizations;
@@ -1406,10 +1410,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;
}
@@ -1427,10 +1431,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;
}
@@ -1475,6 +1479,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);
@@ -1513,10 +1523,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;