0

I want to silently test whether X11 is working, from a script.

I keep getting "connect /tmp/.X11-unix/X1: No such file or directory", even if I redirect stdout and stderr to /dev/null with (for example) xset q > /dev/null 2>&1

I strace'd, and it doesn't appear to be getting written by xset. I also strace'd the relevant sshd and it doesn't seem to be writing it either.

xset, xdpyinfo and the test program at How to check if X server is running? all output this useless error message. In fact, so does vim. But "ls" does not.

I also tried: script -e -c 'xset q' /dev/null > /dev/null 2>&1 ...but even that outputs the error message.

What do I need to do to silence this overaggressive error message?

Thanks!

PS: Here's an strace of xset q:

20878 execve("/usr/bin/xset", ["xset", "q"], 0x7ffe3e91cfe0 /* 33 vars */) = 0
20878 brk(NULL)                         = 0x563d8a664000
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=141841, ...}) = 0
20878 mmap(NULL, 141841, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f19ac118000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXmuu.so.1", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\23\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=14528, ...}) = 0
20878 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac144000
20878 mmap(NULL, 2109592, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19abd10000
20878 mprotect(0x7f19abd13000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19abf12000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f19abf12000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXext.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\2205\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=73640, ...}) = 0
20878 mmap(NULL, 2169496, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19abaf8000
20878 mprotect(0x7f19abb09000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19abd08000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10000) = 0x7f19abd08000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libX11.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\207\1\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=1277384, ...}) = 0
20878 mmap(NULL, 3374392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19ab7c0000
20878 mprotect(0x7f19ab8f3000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19abaf3000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x133000) = 0x7f19abaf3000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\34\2\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
20878 mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19ab3c8000
20878 mprotect(0x7f19ab5af000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19ab7af000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f19ab7af000
20878 mmap(0x7f19ab7b5000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19ab7b5000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libxcb.so.1", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\261\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=162232, ...}) = 0
20878 mmap(NULL, 2257576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19ab1a0000
20878 mprotect(0x7f19ab1c6000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19ab3c6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26000) = 0x7f19ab3c6000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=14560, ...}) = 0
20878 mmap(NULL, 2109712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aaf98000
20878 mprotect(0x7f19aaf9b000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19ab19a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f19ab19a000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXau.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=14456, ...}) = 0
20878 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac142000
20878 mmap(NULL, 2109720, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aad90000
20878 mprotect(0x7f19aad92000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19aaf92000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f19aaf92000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXdmcp.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\21\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=22616, ...}) = 0
20878 mmap(NULL, 2117760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aab88000
20878 mprotect(0x7f19aab8d000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aad8c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7f19aad8c000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libbsd.so.0", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P4\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=80104, ...}) = 0
20878 mmap(NULL, 2179152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa970000
20878 mprotect(0x7f19aa983000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aab82000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0x7f19aab82000
20878 mmap(0x7f19aab84000, 80, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19aab84000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\"\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=31680, ...}) = 0
20878 mmap(NULL, 2128864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa768000
20878 mprotect(0x7f19aa76f000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aa96e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f19aa96e000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000b\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
20878 mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa548000
20878 mprotect(0x7f19aa562000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aa761000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f19aa761000
20878 mmap(0x7f19aa763000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19aa763000
20878 close(3)                          = 0
20878 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac13d000
20878 mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac115000
20878 arch_prctl(ARCH_SET_FS, 0x7f19ac115740) = 0
20878 mprotect(0x7f19ab7af000, 16384, PROT_READ) = 0
20878 mprotect(0x7f19aa761000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aa96e000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aab82000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aad8c000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aaf92000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19ab19a000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19ab3c6000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19abaf3000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19abd08000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19abf12000, 4096, PROT_READ) = 0
20878 mprotect(0x563d8872f000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19ac13f000, 4096, PROT_READ) = 0
20878 munmap(0x7f19ac118000, 141841)    = 0
20878 set_tid_address(0x7f19ac115a10)   = 20878
20878 set_robust_list(0x7f19ac115a20, 24) = 0
20878 rt_sigaction(SIGRTMIN, {sa_handler=0x7f19aa54dcb0, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f19aa55a890}, NULL, 8) = 0
20878 rt_sigaction(SIGRT_1, {sa_handler=0x7f19aa54dd50, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f19aa55a890}, NULL, 8) = 0
20878 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
20878 prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
20878 brk(NULL)                         = 0x563d8a664000
20878 brk(0x563d8a685000)               = 0x563d8a685000
20878 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
20878 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
20878 close(3)                          = 0
20878 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
20878 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
20878 close(3)                          = 0
20878 openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=529, ...}) = 0
20878 read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 529
20878 read(3, "", 4096)                 = 0
20878 close(3)                          = 0
20878 stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=304, ...}) = 0
20878 openat(AT_FDCWD, "/etc/host.conf", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
20878 read(3, "# The \"order\" line is only used "..., 4096) = 92
20878 read(3, "", 4096)                 = 0
20878 close(3)                          = 0
20878 futex(0x7f19ab7b7ba4, FUTEX_WAKE_PRIVATE, 2147483647) = 0
20878 openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=304, ...}) = 0
20878 read(3, "# Dynamic resolv.conf(5) file fo"..., 4096) = 304
20878 read(3, "", 4096)                 = 0
20878 close(3)                          = 0
20878 uname({sysname="Linux", nodename="zareason-limbo", ...}) = 0
20878 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=141841, ...}) = 0
20878 mmap(NULL, 141841, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f19ac0f0000
20878 close(3)                          = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P#\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=47568, ...}) = 0
20878 mmap(NULL, 2168632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa330000
20878 mprotect(0x7f19aa33b000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aa53a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa000) = 0x7f19aa53a000
20878 mmap(0x7f19aa53c000, 22328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19aa53c000
20878 close(3)                          = 0
20878 mprotect(0x7f19aa53a000, 4096, PROT_READ) = 0
20878 munmap(0x7f19ac0f0000, 141841)    = 0
20878 openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=403, ...}) = 0
20878 read(3, "127.0.0.1\tlocalhost\n127.0.1.1\tza"..., 4096) = 403
20878 read(3, "", 4096)                 = 0
20878 close(3)                          = 0
20878 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 3
20878 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0
20878 setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
20878 connect(3, {sa_family=AF_INET, sin_port=htons(6013), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
20878 getpeername(3, {sa_family=AF_INET, sin_port=htons(6013), sin_addr=inet_addr("127.0.0.1")}, [124->16]) = 0
20878 uname({sysname="Linux", nodename="zareason-limbo", ...}) = 0
20878 access("/home/dstromberg/.Xauthority", R_OK) = 0
20878 openat(AT_FDCWD, "/home/dstromberg/.Xauthority", O_RDONLY) = 4
20878 fstat(4, {st_mode=S_IFREG|0600, st_size=827, ...}) = 0
20878 read(4, "\1\0\0\16zareason-limbo\0\0010\0\22MIT-MAGIC"..., 4096) = 827
20878 read(4, "", 4096)                 = 0
20878 close(4)                          = 0
20878 getsockname(3, {sa_family=AF_INET, sin_port=htons(37214), sin_addr=inet_addr("127.0.0.1")}, [124->16]) = 0
20878 fcntl(3, F_GETFL)                 = 0x2 (flags O_RDWR)
20878 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
20878 fcntl(3, F_SETFD, FD_CLOEXEC)     = 0
20878 poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
20878 writev(3, [{iov_base="l\0\v\0\0\0\22\0\20\0\0\0", iov_len=12}, {iov_base="", iov_len=0}, {iov_base="MIT-MAGIC-COOKIE-1", iov_len=18}, {iov_base="\0\0", iov_len=2}, {iov_base="\256b\245\317f\262\25\254\27\365!H\212\3316J", iov_len=16}, {iov_base="", iov_len=0}], 6) = 48
20878 recvfrom(3, 0x563d8a6660e0, 8, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
20878 poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN|POLLERR|POLLHUP}])
20878 recvfrom(3, 0x563d8a6660e0, 8, 0, NULL, NULL) = -1 ECONNRESET (Connection reset by peer)
20878 shutdown(3, SHUT_RDWR)            = -1 ENOTCONN (Transport endpoint is not connected)
20878 close(3)                          = 0
20878 write(2, "xset:  unable to open display \"l"..., 47) = 47
20878 exit_group(1)                     = ?
20878 +++ exited with 1 +++

And here's a type -a xset:

$ type -a xset
below cmd output started 2019 Sun Jun 30 07:49:33 AM PDT
xset is /usr/bin/xset

Running without redirection, to show the order of the messages:

$ xset q
below cmd output started 2019 Sun Jun 30 08:03:24 AM PDT
connect /tmp/.X11-unix/X1: No such file or directory
xset:  unable to open display "localhost:13.0"

In response to a comment from melpomene, I set up a test account with no startup files at all. I then ssh -Y'd to it, sudo'd, and got the same error message as described above.

I had been testing in gnome-terminal exclusively. I just tried konsole and again got the offending error message.

I just tried strace'ing the openssh client; it produced a single occurrence of the string "connect", which did not look relevant (other than connecting to the ssh server).

I had been testing exclusively on a Linux Mint 19.1 system. I just tried it on a freshly-installed Debian 9.9 system, and got the same result.

Steps to replicate:

  1. ssh -Y remote.host.example.com
  2. sudo bash
  3. xset -q > /dev/null 2>&1

You may see the offending error message after these 3 simple steps.

xpt
  • 20,363
  • 37
  • 127
  • 216
dstromberg
  • 6,954
  • 1
  • 26
  • 27
  • What's in your strace log? Also, what does `type -a xset` report? – melpomene Jun 30 '19 at 14:41
  • 1
    "*below cmd output started 2019 Sun Jun 30 07:49:33 AM PDT*"? Where did that come from? – melpomene Jun 30 '19 at 14:55
  • The strace log shows that `xset` is producing the error message `xset: unable to open display ...`. Does that happen before or after the *connect* thing? – melpomene Jun 30 '19 at 14:57
  • "below cmd output" is from bash $PS0. – dstromberg Jun 30 '19 at 15:02
  • What if you `strace -f bash` and run `xset q` from there? Does the connect message show up in the log then? – melpomene Jun 30 '19 at 15:05
  • No, strace'ing bash -c 'xset q' doesn't show any interesting write's nor does it show any interesting occurrences of "connect". – dstromberg Jun 30 '19 at 15:15
  • Might be something in your `~/.bashrc`, then. That's why I said to run `xset q` from `bash` manually and not use `-c`. – melpomene Jun 30 '19 at 15:17
  • Same thing interactively: strace reveals no interesting write's, no interesting occurrences of "connect". – dstromberg Jun 30 '19 at 16:32
  • I wouldn't use `strace` for this task at all. Use `sysdig` -- it can track *every job on the system* at the same time with minimal overhead, to tell you which one is doing the write (and to which FD). – Charles Duffy Jun 30 '19 at 17:24
  • `sysdig 'evt.buffer contains "connect /tmp/.X11-unix"'` and there you are -- the only results will be processes reading or writing that string. (Of course, if it's split into more than one write call, you may need to loosen the filter). – Charles Duffy Jun 30 '19 at 17:25
  • This is the first time I've heard of sysdig. sysdig 'evt.buffer contains "connect /tmp/.X11-unix"' returned nothing. Neither did checking for just X11-unix. – dstromberg Jun 30 '19 at 17:34
  • Running your sysdig on the ssh client machine, I get just: 6660206 10:38:09.520806402 1 ssh (29440) < write res=54 data=connect /tmp/.X11-unix/X1: No such file or directory.. 6660237 10:38:09.520967273 2 mate-terminal (11998) < read res=55 data=.connect /tmp/.X11-unix/X1: No such file or directory.. – dstromberg Jun 30 '19 at 17:39
  • Possibly related to the issue here: https://unix.stackexchange.com/questions/57138/why-does-my-x11-forwarding-attempt-fail-with-connect-tmp-x11-unix-x0-no-such ? –  Jul 01 '19 at 01:45

1 Answers1

3

This is pretty easy to understand and replicate, but there is a number of moving parts.

We ssh to a remote machine with X forwarding. This ssh process must have access to a working X server locally. Here we'll start it up with a joke $DISPLAY:

(local) $ DISPLAY=:87 ssh -Y remote
Warning: No xauth data; using fake authentication data for X11 forwarding

That Warning is an indication that ssh cannot contact a working X server locally.

On remote $DISPLAY is not :87

(remote) $ echo $DISPLAY
(remote) localhost:11.0

This is the magic that ssh's -Y does and how its X11 proxy works.

We run a command on remote that tries to connect to $DISPLAY:

(remote) $ xset -q
connect /tmp/.X11-unix/X99: No such file or directory
xset:  unable to open display "localhost:11.0"

And here is your problem:

(remote) $ xset -q >/dev/null 2>&1
connect /tmp/.X11-unix/X99: No such file or directory

The unable error message was being printed by xset, and has been redirected away. However the connect error message is coming out of ssh. Remember that xset runs on remote, while ssh is running on local.

You need to validate $DISPLAY on local before running ssh.

You can quieten ssh in a number of ways, but I'm not a fan of throwing away error messages. One way would be to reduce the error verbosity:

(local) $ DISPLAY=:87 ssh -Y -o LogLevel=FATAL remote 'xset -q &>/dev/null'

See man ssh_config for a list of ssh settings.

bobbogo
  • 14,989
  • 3
  • 48
  • 57
  • Accepted. The followup question: Why doesn't sysdig see it? – dstromberg Jul 06 '19 at 17:24
  • @dstromberg _sysdig_? Assuming you meant _strace_. You say that you straced the ssh server _sshd_. You need to strace the ssh client running on local, _ssh_. – bobbogo Jul 15 '19 at 14:56
  • Shouldn't both strace and sysdig see it? – dstromberg Jul 19 '19 at 23:55
  • @dstromberg _strace_ will see it when you run it on the ssh client command (_ssh_). It won't see it when you run it on the ssh server command (_sshd_). – bobbogo Jan 15 '21 at 15:04