File python-xlib-0.14-xauthlocalhostname.patch of Package python-xlib
diff -urN python-xlib-0.14.orig/Xlib/support/unix_connect.py python-xlib-0.14/Xlib/support/unix_connect.py
--- python-xlib-0.14.orig/Xlib/support/unix_connect.py 2010-08-16 17:21:08.000000000 +0200
+++ python-xlib-0.14/Xlib/support/unix_connect.py 2010-08-19 11:30:49.000000000 +0200
@@ -100,21 +100,31 @@
addr = socket.gethostname()
au = xauth.Xauthority()
- while 1:
+ try:
+ return au.get_best_auth(family, addr, dno)
+ except error.XNoAuthError:
+ pass
+
+ # fall back to hostname specified by the XAUTHLOCALHOSTNAME environment
+ # variable in case of a Unix socket
+ if "XAUTHLOCALHOSTNAME" in os.environ and family == xauth.FamilyLocal:
+ try:
+ return au.get_best_auth(family, os.environ["XAUTHLOCALHOSTNAME"], dno)
+ except error.XNoAuthError:
+ pass
+
+ # We need to do this to handle ssh's X forwarding. It sets
+ # $DISPLAY to localhost:10, but stores the xauth cookie as if
+ # DISPLAY was :10. Hence, if localhost and not found, try
+ # again as a Unix socket.
+ if family == xauth.FamilyInternet and addr == '\x7f\x00\x00\x01':
try:
- return au.get_best_auth(family, addr, dno)
+ return au.get_best_auth(xauth.FamilyLocal, socket.gethostname(),
+ dno)
except error.XNoAuthError:
pass
- # We need to do this to handle ssh's X forwarding. It sets
- # $DISPLAY to localhost:10, but stores the xauth cookie as if
- # DISPLAY was :10. Hence, if localhost and not found, try
- # again as a Unix socket.
- if family == xauth.FamilyInternet and addr == '\x7f\x00\x00\x01':
- family = xauth.FamilyLocal
- addr = socket.gethostname()
- else:
- return '', ''
+ return '', ''
def old_get_auth(sock, dname, host, dno):