Skip to content

Commit ee40ff7

Browse files
committed
Fixed ssh workaround in xauth code, and switched to new xauth handling.
1 parent 9765556 commit ee40ff7

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

Xlib/support/unix_connect.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: unix_connect.py,v 1.3 2003-01-29 23:53:37 petli Exp $
1+
# $Id: unix_connect.py,v 1.4 2003-06-08 23:21:53 petli Exp $
22
#
33
# Xlib.support.unix_connect -- Unix-type display connection functions
44
#
@@ -90,18 +90,29 @@ def new_get_auth(sock, dname, host, dno):
9090
family = xauth.FamilyInternet
9191

9292
# Convert the prettyprinted IP number into 4-octet string.
93-
# Sometimes these modules are to smart...
93+
# Sometimes these modules are too damn smart...
9494
octets = string.split(sock.getpeername()[0], '.')
9595
addr = string.join(map(lambda x: chr(int(x)), octets), '')
9696
else:
9797
family = xauth.FamilyLocal
9898
addr = socket.gethostname()
9999

100100
au = xauth.Xauthority()
101-
try:
102-
return au.get_best_auth(family, addr, dno)
103-
except error.XNoAuthError:
104-
return '', ''
101+
while 1:
102+
try:
103+
return au.get_best_auth(family, addr, dno)
104+
except error.XNoAuthError:
105+
pass
106+
107+
# We need to do this to handle ssh's X forwarding. It sets
108+
# $DISPLAY to localhost:10, but stores the xauth cookie as if
109+
# DISPLAY was :10. Hence, if localhost and not found, try
110+
# again as a Unix socket.
111+
if family == xauth.FamilyInternet and addr == '\x7f\x00\x00\x01':
112+
family = xauth.FamilyLocal
113+
addr = socket.gethostname()
114+
else:
115+
return '', ''
105116

106117

107118
def old_get_auth(sock, dname, host, dno):
@@ -135,4 +146,4 @@ def old_get_auth(sock, dname, host, dno):
135146

136147
return auth_name, auth_data
137148

138-
get_auth = old_get_auth
149+
get_auth = new_get_auth

Xlib/xauth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: xauth.py,v 1.1 2003-01-29 23:53:31 petli Exp $
1+
# $Id: xauth.py,v 1.2 2003-06-08 23:21:53 petli Exp $
22
#
33
# Xlib.xauth -- ~/.Xauthority access
44
#
@@ -35,7 +35,7 @@ def __init__(self, filename = None):
3535

3636
if filename is None:
3737
try:
38-
filename = os.path.join(os.environ['HOME'], '/.Xauthority')
38+
filename = os.path.join(os.environ['HOME'], '.Xauthority')
3939
except KeyError:
4040
raise error.XauthError(
4141
'$HOME not set, cannot find ~/.Xauthority')

0 commit comments

Comments
 (0)