Linux Mint Policy Kit Problems
So in Linux Mint 19.1 I managed to kill Policy Kit. Nemo stopped prompting for a password when I tried to ‘open as root’. Synaptic Package Manager stopped opening when I tried to launched it. And various other things broke as well.
After most of a day Googling for an answer, the only thing I kept finding was REINSTALL LINUX. Over and over and over. After I finally gave up on the internet I started trying various ideas. Such as:
sudo apt reinstall policykit-1
sudo apt purge policykit-1
etc.
None of it helped. In fact when I started to purge it, it wanted to also remove my Desktop Environment (Cinnamon). So I decided on a new approach. I Googled up PolicyKit’s repository. https://cgit.freedesktop.org/polkit/tree/ From there I started I poked around in the source code until I found things like this:
install-data-hook:
mkdir -p $(DESTDIR)$(sysconfdir)/polkit-1/rules.d
-chmod 700 $(DESTDIR)$(sysconfdir)/polkit-1/rules.d
-chown $(POLKITD_USER) $(DESTDIR)$(sysconfdir)/polkit-1
/rules.d
mkdir -p $(DESTDIR)$(datadir)/polkit-1/rules.d
-chmod 700 $(DESTDIR)$(datadir)/polkit-1/rules.d
-chown $(POLKITD_USER) $(DESTDIR)$(datadir)/polkit-1
/rules.d
OR
install-data-hook:
-chown root $(DESTDIR)$(libprivdir)/polkit-agent-helper-1
-chmod 4755 $(DESTDIR)$(libprivdir)/polkit-agent-helper-1
AND THEN
echo "NOTE: The file ${prefix}/lib/polkit-1/polkit-agent-helper-1
must be owned"
echo " by root and have mode 4755 (setuid root binary)"
echo
echo "NOTE: The file ${bindir}/pkexec must be owned by root and"
echo " have mode 4755 (setuid root binary)"
echo
echo "NOTE: The directory ${sysconfdir}/polkit-1/rules.d must
be owned"
echo " by user '$POLKITD_USER' and have mode 700"
echo
echo "NOTE: The directory ${datadir}/polkit-1/rules.d must
be owned"
echo " by user '$POLKITD_USER' and have mode 700"
echo
Now I started looking at those directories and checking owner and permissions. Found a few wrong and corrected them. Still it didn’t work.
So I started looking at dbus. dbus is the system that PolicyKit uses to communicate. As I started digging though dbus I found this page https://askubuntu.com/questions/502837/dbus-folder-in-home-folder-belongs-root And as a result checked those permissions too. The final solution was:
sudo chown root:root /usr/bin/pkexec
sudo chmod 4755 /usr/bin/pkexec
sudo chown -R root:root /usr/lib/polkit-1
sudo chmod -R 755 /usr/lib/polkit-1
sudo chown -R root:root /etc/polkit-1
sudo chmod -R 755 /etc/polkit-1
sudo chmod -R 4755 /etc/polkit-1/polkit-agent-helper-1
cd ~
sudo chown -R root:root .dbus
sudo chmod -R 700 .dbus
sudo chown -R root:root .cache/dconf
sudo chmod -R 700 .cache/dconf
And lastly, when you’re working backwards trying to figure out how you got to where you are, /root/.bash_history and ~/.bash_history are your friends!