我有一台 Fedora VM,不知为何,一段时间后,它总是开始出现非常慢的“sudo”身份验证(或一般的身份验证,如要求提供凭据的 GUI 应用程序)。它会正常工作,直到某个时刻 (*) 它开始等待 20 秒以上才显示密码提示。
(*) 那一刻可能发生在我暂停并重新启动虚拟机之后,但我无法可靠地重现这一情况。
我认为我将其追溯到与 DBus 有关的事情,因为执行 sudo 的“strace”会给我以下结果:
0.000040 connect(8, {sa_family=AF_LOCAL, sun_path="/var/run/dbus/system_bus_socket"}, 33) = 0
0.000095 fcntl(8, F_GETFL) = 0x2 (flags O_RDWR)
0.000035 fcntl(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
0.000039 geteuid() = 0
0.000038 getsockname(8, {sa_family=AF_LOCAL, NULL}, [2]) = 0
0.000060 poll([{fd=8, events=POLLOUT}], 1, 0) = 1 ([{fd=8, revents=POLLOUT}])
0.000041 sendto(8, "\0", 1, MSG_NOSIGNAL, NULL, 0) = 1
0.000090 sendto(8, "AUTH EXTERNAL 30\r\n", 18, MSG_NOSIGNAL, NULL, 0) = 18
0.000135 poll([{fd=8, events=POLLIN}], 1, 4294967295) = 1 ([{fd=8, revents=POLLIN}])
0.000053 read(8, "OK 646ed40b36ee6ecf4fee737c54368"..., 2048) = 37
0.000047 poll([{fd=8, events=POLLOUT}], 1, 4294967295) = 1 ([{fd=8, revents=POLLOUT}])
0.000039 sendto(8, "NEGOTIATE_UNIX_FD\r\n", 19, MSG_NOSIGNAL, NULL, 0) = 19
0.000369 poll([{fd=8, events=POLLIN}], 1, 4294967295) = 1 ([{fd=8, revents=POLLIN}])
0.000047 read(8, "AGREE_UNIX_FD\r\n", 2048) = 15
0.000043 poll([{fd=8, events=POLLOUT}], 1, 4294967295) = 1 ([{fd=8, revents=POLLOUT}])
0.000039 sendto(8, "BEGIN\r\n", 7, MSG_NOSIGNAL, NULL, 0) = 7
0.000088 poll([{fd=8, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=8, revents=POLLOUT}])
0.000041 sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\0\1\0\0\0\0\1\0\0\0n\0\0\0\1\1o\0\25\0\0\0/org/fre"..., 128}, {"", 0}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 128
0.000108 clock_gettime(CLOCK_MONOTONIC, {115342, 676969855}) = 0
0.000042 poll([{fd=8, events=POLLIN}], 1, 25000) = 1 ([{fd=8, revents=POLLIN}])
0.000818 recvmsg(8, {msg_name(0)=NULL, msg_iov(1)=[{"l\2\1\1\v\0\0\0\1\0\0\0=\0\0\0\6\1s\0\6\0\0\0:1.196\0\0"..., 2048}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 262
0.000062 recvmsg(8, 0x7fff421ab1a0, MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)
0.000312 eventfd2(0, O_NONBLOCK|O_CLOEXEC) = 9
0.000046 write(9, "\1\0\0\0\0\0\0\0", 8) = 8
0.000042 fstat(8, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
0.000039 fcntl(8, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
0.000038 write(9, "\1\0\0\0\0\0\0\0", 8) = 8
0.000133 sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\1\1\204\0\0\0\2\0\0\0\177\0\0\0\1\1o\0\25\0\0\0/org/fre"..., 144}, {"\177\0\0\0type='signal',sender='net.re"..., 132}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 276
0.000130 sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\1\1\246\0\0\0\3\0\0\0\177\0\0\0\1\1o\0\25\0\0\0/org/fre"..., 144}, {"\241\0\0\0type='signal',sender='org.fr"..., 166}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 310
0.000126 clock_gettime(CLOCK_MONOTONIC, {115342, 678759459}) = 0
0.000048 sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\0\1\33\0\0\0\4\0\0\0\177\0\0\0\1\1o\0\25\0\0\0/org/fre"..., 144}, {"\26\0\0\0net.reactivated.Fprint\0", 27}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 171
0.000119 clock_gettime(CLOCK_MONOTONIC, {115342, 678926239}) = 0
0.000048 sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\0\1\0\0\0\0\5\0\0\0\203\0\0\0\1\1o\0\37\0\0\0/net/rea"..., 152}, {"", 0}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 152
0.000267 clock_gettime(CLOCK_MONOTONIC, {115342, 679268460}) = 0
0.000123 poll([{fd=8, events=POLLIN}], 1, 25000) = 1 ([{fd=8, revents=POLLIN}])
0.000060 recvmsg(8, {msg_name(0)=NULL, msg_iov(1)=[{"l\2\1\1\v\0\0\0\3\0\0\0=\0\0\0\6\1s\0\6\0\0\0:1.196\0\0"..., 2048}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 91
0.000065 write(9, "\1\0\0\0\0\0\0\0", 8) = 8
0.000040 recvmsg(8, 0x7fff421ab010, MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)
0.000053 clock_gettime(CLOCK_MONOTONIC, {115342, 679581347}) = 0
vvvvvvvv
0.000042 poll([{fd=8, events=POLLIN}], 1, 25000) = 0 (Timeout) <<<****** HERE
^^^^^^^^
25.025437 clock_gettime(CLOCK_MONOTONIC, {115367, 705179464}) = 0
0.000562 sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\1\1\204\0\0\0\6\0\0\0\177\0\0\0\1\1o\0\25\0\0\0/org/fre"..., 144}, {"\177\0\0\0type='signal',sender='net.re"..., 132}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 276
0.000835 sendmsg(8, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\1\1\246\0\0\0\7\0\0\0\177\0\0\0\1\1o\0\25\0\0\0/org/fre"..., 144}, {"\241\0\0\0type='signal',sender='org.fr"..., 166}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 310
0.000704 write(9, "\1\0\0\0\0\0\0\0", 8) = 8
0.000503 close(8) = 0
执行在标记的超时线上暂停约 20 秒。
有人有什么想法吗?(不,这与我的主机文件无关)
答案1
我遇到了类似的问题:sudo
,,su
并且login
全部挂起大约 20 秒等待 dbus 系统套接字。
有时此类问题是由于 /etc/hosts 中缺少本地主机名引起的。(例如,如果hostname
命令打印,foo
您可以将其添加127.0.0.1 foo
到 /etc/hosts)。
然而,就我而言,问题是由不是正在运行systemd-logind
或其替代品elogind
(用于 Gentoo)。通常它在libelogind
使用时会自动启动,但在我的系统上它被禁用,最近系统更新后它停止工作。
开始elogind
为我解决了这个问题。
答案2
我遇到了类似的问题,su
甚至类似的命令,如id root
挂起轮询/run/dbus/system_bus_socket
:
connect(3, {sa_family=AF_UNIX, sun_path="/run/dbus/system_bus_socket"}, 30) = 0 <0.000031>
...
recvmsg(3, {msg_namelen=0}, MSG_DONTWAIT|MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable) <0.000011>
clock_gettime(CLOCK_MONOTONIC, {tv_sec=35439646, tv_nsec=638969580}) = 0 <0.000015>
ppoll([{fd=3, events=POLLIN}], 1, {tv_sec=24, tv_nsec=999824000}, NULL, 8) = 1 ([{fd=3, revents=POLLIN}], left {tv_sec=0, tv_nsec=0}) <25.018954>
这是在长期未维护的 pre-systemd VM 上发生的。我最终关闭了 dbus 才能够登录。