Lost sudo. Beyond salvation

chmoddockerlinuxrootsudo

I made a mistake and gave a container Homepage access to the docker.sock and briefly after I discovered that sudo is no more.

sudo

sudo: /etc/sudo.conf is owned by uid 1000, should be 0
sudo: /etc/sudo.conf is owned by uid 1000, should be 0
sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: error initializing audit plugin sudoers_audit

Am I beyond any salvation or what do you think?

Yes I've read almost every post I could find both here and on other forums and basically none of the suggestions work.

What I have not tried (yet) is doing an fresh install on some other drive, and then try to mount my system drive into that OS and maybe sort permissions through various commands and tools.. Thing is, I'm afraid of doing that cause even if I regain sudo abilities I don't really know what else has been done and maybe still is going on in/to my system since I guess through docker.sock my system has been and still is opened while I'm out.

Dose Linux based OS systems take logs of such actions?

Update, what I have tried:

pkexec chown root:root /etc/sudoers /etc/sudoers.d -R

====AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/usr/bin/chown' as the super user
Authenticating as: ,,, (pi)
Password: 
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ====
Error executing command as another user: Not authorized

This incident has been reported.

pkexec visudo

==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/usr/sbin/visudo' as the super user
Authenticating as: ,,, (pi)
Password: 
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ====
Error executing command as another user: Not authorized

This incident has been reported.

chown root:root /etc/sudoers

chown: changing ownership of '/etc/sudoers': Operation not permitted

Best Answer

Here are the commands and the steps, I sure hope this might help someone else if and when you would end up in my situation. However, you should not be so reckless and read previous answer here, which is informative and makes you causes moving forward.

  1. Start two terminals and SSH into your machine.

  2. In the first one run echo $$ make a note of that returned value.

  3. In the second terminal, run

    pkttyagent --process insert_value_here
    
  4. Back to the first terminal and run pkexec chown root:root /etc/sudoers /etc/sudoers.d -R keep an eye on the second terminal and keep entering your user password each time it asked for it.

  5. In the first terminal try using sudo, eg sudo fdisk -l or sudo -l if you can then nice, if you can't (I could not since some file was apparently missing) then go ahead and reinstall sudo using pkexec apt-get purge sudo followed by pkexec apt-get install sudo

    and then run (I had to) pkexec chown -R root:root /etc.

You are done.

Related Question