更新
开发人员Jeremy Huddleston Sequoia 昨天宣布,此问题已在XQuartz 2.7.8_beta2中解决:
XQuartz 2.7.8_beta2可供下载。
您可以查看http://xquartz.macosforge.org/trac/wiki/X112.7.8进行一整套更改,但是最值得注意的是:
1)xauth现在可以正确解析优胜美地启动的$ DISPLAY套接字路径
2)libGL已更新为Mesa 10.4.4
3)xorg-server,freetype和libpng中的各种漏洞已得到修复
4)在某些情况下,阻止自动更新的错误已修复
错误报告已关闭并标记为已修复:
如果您无法(或不想)安装测试版,则仍然可以使用我在下面说明的解决方法。
回答
分析
(向下滚动至解决方法部分)
我的第一个想法是“ DISPLAY
变量错误”。但事实并非如此。
事实证明,在OS X 10.10 Yosemite(并返回10.8 Mountain Lion)上,该DISPLAY
变量存储launchd
套接字路径:
/private/tmp/<socket name>
而不是熟悉的显示名称:
hostname:displaynumber.screennumber
(我在hostname:displaynumber.screennumber
此答案的末尾添加了有关格式的一些信息。)
这意味着xauth
必须知道如何处理DISPLAY
变量的这种特殊形式,从Mavericks开始,它确实如此,但是优胜美地中使用的套接字具有不同的路径(更确切地说:/private/tmp/com.apple.launchd.XXXX
而不是/private/tmp/launch-XXXX
),并且xauth
会中断。
此错误已于2014年11月18日(3个月前)报告给XQuartz团队(http://xquartz.macosforge.org/trac/ticket/2068):
xauth程序在gethost.c和parsedpy.c中都有代码,以查找以“ / tmp / launch”开头的$ DISPLAY名称,并将其视为本地套接字。但是,位置似乎已更改,$ DISPLAY现在以“ /private/tmp/com.apple.launchd”开头,因此寻找/ tmp / launch的代码无法捕获它。(...)
根据错误描述,此问题将在XQuartz 2.7.8中解决,该版本已延迟4个月(请参阅项目路线图页面,网址为http://xquartz.macosforge.org/trac/roadmap)。
修复该问题的补丁已于2014年12月31日提交到freedesktop.org项目(http://cgit.freedesktop.org/xorg/app/xauth/commit/parsedpy.c?id=f990dd936b5fd1a40290bb88cde517a0ac38f823):
diff --git a/parsedpy.c b/parsedpy.c
index c591b77..7365224 100644
--- a/parsedpy.c
+++ b/parsedpy.c
@@ -42,6 +42,9 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xauth.h> /* for FamilyLocal */
#include <X11/Xmu/SysUtil.h>
+#include <sys/stat.h>
+#include <sys/syslimits.h>
+
#if defined(UNIXCONN) || defined(LOCALCONN)
#define UNIX_CONNECTION "unix"
#define UNIX_CONNECTION_LENGTH 4
@@ -158,8 +161,32 @@ parse_displayname (const char *displayname,
if (!host) return False;
- if(strncmp (host, "/tmp/launch", 11) == 0) {
- family = FamilyLocal;
+ {
+ /*
+ * If using launchd socket, remove the screen number from the end
+ * of $DISPLAY and check if it is a path to a socket.
+ */
+ char path[PATH_MAX];
+ struct stat sbuf;
(...)
因此,此修补程序进入下一版XQuartz只是时间问题。
解决方法
(在OS X 10.10.2 Yosemite上测试。)
加:
alias ssh="ln -fs $(echo $DISPLAY | sed 's:\(/private/tmp/com\.apple\.launchd\.[^/]*\)/.*:\1:') $(echo $DISPLAY | sed 's:/private/tmp/com\.apple\.launchd\.\([^/]*\)/.*:/private/tmp/launch-\1:'); ssh"
对~/.bashrc
,要么启动一个新的终端窗口或源它(. ~/.bashrc
在当前的终端会话)。
此别名首先将套接字路径符号链接到/private/tmp/launch-XXX
(例如ln -fs /private/tmp/com.apple.launchd.GuewxwWwKS /private/tmp/launch-GuewxwWwKS
),然后启动ssh
:
出于好奇,传统上,X服务器的显示名称具有以下格式(来自man X
Ubuntu):X服务器的显示名称具有以下格式:
hostname:displaynumber.screennumber
哪里:
hostname
The hostname specifies the name of the machine to which the display is physically
connected. If the hostname is not given, the most efficient way of communicating
to a server on the same machine will be used.
displaynumber
The phrase "display" is usually used to refer to a collection of monitors that
share a common set of input devices (keyboard, mouse, tablet, etc.). Most worksta‐
tions tend to only have one display. Larger, multi-user systems, however, fre‐
quently have several displays so that more than one person can be doing graphics
work at once. To avoid confusion, each display on a machine is assigned a display
number (beginning at 0) when the X server for that display is started. The display
number must always be given in a display name.
screennumber
Some displays share their input devices among two or more monitors. These may be
configured as a single logical screen, which allows windows to move across screens,
or as individual screens, each with their own set of windows. If configured such
that each monitor has its own set of windows, each screen is assigned a screen num‐
ber (beginning at 0) when the X server for that display is started. If the screen
number is not given, screen 0 will be used.
$DISPLAY
错误。应该是这样的:0.0
。你$DISPLAY
是自己~/.bash_profile
还是~/.profile
自己?