Fixing slow sudo (failed systemd services)

Just noting something for the future. No response necessary.

After a recent update I noticed sudo taking an absurdly long time to display the password prompt, nearly 30 seconds.

Some other forum answers claim it has to do with various hostname issues in /etc/hosts or /etc/hostname. I found that /etc/hostname was already set correctly, and hard coding my hostname in /etc/hosts file did not solve the issue.

What did help was this post:

systemctl list-units --state=failed showed that fprintd.service and systemd-hostnamed were now failing to start (I’m not really sure why)

systemctl restart on each service immediately started the service and fixed the slow sudo issue.

1 Like

But somehow also related to the hostname. I wonder if restarting just systemd-hostnamed would have fixed it. Also wondering if using hostnamectl to set the hostname would have had any impact.

Did you find out why systemd-hostnamed failed?

Has this bug been reported somewhere?

re: systemd-hostnamed errors

Jul 23 22:09:10 jupiter systemd[179649]: systemd-hostnamed.service: Failed to set up mount namespacing: /run/systemd/unit-root/: Permis>
Jul 23 22:09:10 jupiter systemd[179649]: systemd-hostnamed.service: Failed at step NAMESPACE spawning /usr/lib/systemd/systemd-hostname>
Jul 23 22:09:10 jupiter systemd[1]: systemd-hostnamed.service: Main process exited, code=exited, status=226/NAMESPACE
Jul 23 22:09:10 jupiter systemd[1]: systemd-hostnamed.service: Failed with result 'exit-code'.
Jul 23 22:09:10 jupiter systemd[1]: Failed to start Hostname Service.

Similar errors and timestamps for fprintd

Jul 23 22:12:15 jupiter systemd[180682]: fprintd.service: Failed to set up mount namespacing: /run/systemd/unit-root/: Permission denied
Jul 23 22:12:15 jupiter systemd[180682]: fprintd.service: Failed at step NAMESPACE spawning /usr/libexec/fprintd: Permission denied
Jul 23 22:12:15 jupiter systemd[1]: fprintd.service: Main process exited, code=exited, status=226/NAMESPACE
Jul 23 22:12:15 jupiter systemd[1]: fprintd.service: Failed with result 'exit-code'.
Jul 23 22:12:15 jupiter systemd[1]: Failed to start Fingerprint Authentication Daemon.

Journal logs are unclear beyond that, but I believe that may(?) line up with the first reboot after a system update.

As for restarting hostnamed to fix it - that’s what I tried first. On its own it had no effect. So it was either restarting fprintd, or restarting both of them that fixed the issue.

re: hostnamectl -

To be clear I didn’t actually change my hostname, it’s been the same as when I initially set up the system 2 years go. hostnamectl status does show the correct info, and /etc/hostname already contains the correct hostname.

But I did try manually adding the hostname to the localhost ip address lines in /etc/hosts/, that had no effect.

re: bug reports - I’m not really sure which upstream I would report this to. bugzilla?

Please, post the output:

sudo grep -v -r -e ^# -e ^$ /etc/nsswitch.conf /etc/sudoers*
time getent passwd root $(id -n -u)
time getent group wheel root $(id -n -g)
time hostnamectl --static status