我使用的是 Fedora 23,Fedora 22 上也有同样的问题。Sudo 需要约 20 秒才能启动,它会执行约 20 秒的操作,然后询问密码。
重启可以暂时解决这个问题。几个小时后问题再次出现。
这是 strace 输出的和平
0.000022 write(7, "\1", 1) = 1
0.000038 rt_sigreturn({mask=[INT QUIT]}) = -1 EINTR (Interrupted system call)
0.000026 --- SIGCONT {si_signo=SIGCONT, si_code=SI_KERNEL} ---
0.000012 poll([{fd=11, events=POLLIN}], 1, 25000) = 0 (Timeout)
25.025434 sendmsg(11, {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.000378 sendmsg(11, {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.000176 write(12, "\1\0\0\0\0\0\0\0", 8) = 8
0.000109 close(11) = 0
0.000121 close(12) = 0
0.000090 getuid() = 1000
您可以看到 sendmsg 花费了太多时间。
有人可以帮我弄这个吗?我不想每次发生这种情况都重新启动我的笔记本电脑。
uname -a
Linux c0rp 4.4.9-300.fc23.x86_64
链接到 stracehttp://pastebin.com/n5GWi9G1
这是输出strace -f -v -s300 -o log sudo
8204 poll([{fd=11, events=POLLIN}], 1, -1) = 1 ([{fd=11, revents=POLLIN}])
8204 read(11, "AGREE_UNIX_FD\r\n", 2048) = 15
8204 poll([{fd=11, events=POLLOUT}], 1, -1) = 1 ([{fd=11, revents=POLLOUT}])
8204 sendto(11, "BEGIN\r\n", 7, MSG_NOSIGNAL, NULL, 0) = 7
8204 poll([{fd=11, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=11, revents=POLLOUT}])
8204 sendmsg(11, {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/freedesktop/DBus\0\0\0\6\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\2\1s\0\24\0\0\0org.fr
eedesktop.DBus\0\0\0\0\3\1s\0\5\0\0\0Hello\0\0\0", 128}, {"", 0}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 128
8204 poll([{fd=11, events=POLLIN}], 1, 25000) = 1 ([{fd=11, revents=POLLIN}])
8204 recvmsg(11, {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.491\0\0\5\1u\0\1\0\0\0\10\1g\0\1s\0\0\7\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\6\0\0\0:1
.491\0l\4\1\1\v\0\0\0\2\0\0\0\215\0\0\0\1\1o\0\25\0\0\0/org/freedesktop/DBus\0\0\0\2\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\3\1s\0\f\0\0\0NameAcquired\0\0\0\0\6\1s\0\6\0\0\0:1.491\0\0\10\
1g\0\1s\0\0\7\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\6\0\0\0:1.491\0", 2048}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 262
8204 recvmsg(11, 0x7ffec28d88e0, MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)
8204 eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK) = 12
8204 write(12, "\1\0\0\0\0\0\0\0", 8) = 8
8204 fstat(11, {st_dev=makedev(0, 8), st_ino=3014822, st_mode=S_IFSOCK|0777, st_nlink=1, st_uid=0, st_gid=1000, st_blksize=4096, st_blocks=0, st_size=0, st_atime=0, st_mtime=0, st_ctime=0})
= 0
8204 fcntl(11, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
8204 write(12, "\1\0\0\0\0\0\0\0", 8) = 8
8204 sendmsg(11, {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/freedesktop/DBus\0\0\0\6\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\2\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\3\1s\0\10\0\0\0AddMatch\0\0\0\0\0\0\0\0\10\1g\0\1s\0\0", 144}, {"\177\0\0\0type='signal',sender='net.reactivated.Fprint',path='/net/reactivated/Fprint/Manager',interface='net.reactivated.Fprint.Manager'\0", 132}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 276
8204 sendmsg(11, {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/freedesktop/DBus\0\0\0\6\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\2\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\3\1s\0\10\0\0\0AddMatch\0\0\0\0\0\0\0\0\10\1g\0\1s\0\0", 144}, {"\241\0\0\0type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='net.reactivated.Fprint'\0", 166}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 310
8204 sendmsg(11, {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/freedesktop/DBus\0\0\0\6\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\2\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\3\1s\0\f\0\0\0GetNameOwner\0\0\0\0\10\1g\0\1s\0\0", 144}, {"\26\0\0\0net.reactivated.Fprint\0", 27}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 171
8204 sendmsg(11, {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/reactivated/Fprint/Manager\0\6\1s\0\26\0\0\0net.reactivated.Fprint\0\0\2\1s\0\36\0\0\0net.reactivated.Fprint.Manager\0\0\3\1s\0\n\0\0\0GetDevices\0\0\0\0\0\0", 152}, {"", 0}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 152
8204 poll([{fd=11, events=POLLIN}], 1, 25000) = 1 ([{fd=11, revents=POLLIN}])
8204 recvmsg(11, {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.491\0\0\5\1u\0\4\0\0\0\10\1g\0\1s\0\0\7\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\6\0\0\0:1.413\0", 2048}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 91
8204 write(12, "\1\0\0\0\0\0\0\0", 8) = 8
8204 recvmsg(11, 0x7ffec28d8730, MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)
8204 poll([{fd=11, events=POLLIN}], 1, 25000) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
8204 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
8204 restart_syscall(<... resuming interrupted poll ...>) = 0
8204 sendmsg(11, {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/freedesktop/DBus\0\0\0\6\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\2\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\3\1s\0\v\0\0\0RemoveMatch\0\0\0\0\0\10\1g\0\1s\0\0", 144}, {"\177\0\0\0type='signal',sender='net.reactivated.Fprint',path='/net/reactivated/Fprint/Manager',interface='net.reactivated.Fprint.Manager'\0", 132}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 276
8204 sendmsg(11, {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/freedesktop/DBus\0\0\0\6\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\2\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\3\1s\0\v\0\0\0RemoveMatch\0\0\0\0\0\10\1g\0\1s\0\0", 144}, {"\241\0\0\0type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='net.reactivated.Fprint'\0", 166}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 310
/etc/nsswitch.conf
#
# /etc/nsswitch.conf
passwd: files sss
shadow: files sss
group: files sss
#initgroups: files
#hosts: db files nisplus nis dns
hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname mymachines
# Example - obey only what nisplus tells us...
#services: nisplus [NOTFOUND=return] files
#networks: nisplus [NOTFOUND=return] files
#protocols: nisplus [NOTFOUND=return] files
#rpc: nisplus [NOTFOUND=return] files
#ethers: nisplus [NOTFOUND=return] files
#netmasks: nisplus [NOTFOUND=return] files
bootparams: nisplus [NOTFOUND=return] files
ethers: files
netmasks: files
networks: files
protocols: files
rpc: files
services: files sss
netgroup: files sss
publickey: nisplus
automount: files sss
aliases: files nisplus
答案1
Pastebin 链接中的完整 strace 显示 sudo 正在尝试打开libnss-sss.so.2
:
open("/lib64/libnss_sss.so.2", O_RDONLY|O_CLOEXEC) = 8
这是一个 NSS 模块SSSD - 系统安全服务守护进程,它管理对各种远程身份验证服务的访问。
检查 SSSD 是否已安装并正在运行。如果是,请尝试按照指示在该网站上调试sudo
问题。
如果不是,则找出原因并修复它,或者(如果您不想/不需要sss
)只需编辑/etc/nsswitch.conf
并注释掉或sss
从配置为使用它的所有服务中删除。