Slow authentication on Fedora VM due to /var/run/dbus/system_bus_socket connect timeout

I had the similar problem: sudo, su, and login all hang for about 20 seconds waiting on dbus system socket.

Sometimes such problem is caused by missing local hostname in /etc/hosts. (e.g. if hostname command prints foo you can add 127.0.0.1 foo to /etc/hosts).

However, in my case, the problem was caused by not running systemd-logind or its replacement elogind (which is used on Gentoo). Usually it's started automatically when libelogind is used, but on my system it was disabled and recently things stopped working after system update.

Starting elogind fixed the issue for me.