-1

I need to restore /etc/shadow with the contents of /etc/shadow.bak. I don't have a sudo password but was told that maybe "Non-default shadow group permissions" would help?

I run

sudo -ll

I get the following

james@machine:~$ sudo -ll
Matching Defaults entries for elf on 8ee2351512ca:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User james may run the following commands on machine:
Sudoers entry:
    RunAsUsers: james
    RunAsGroups: shadow
    Options: !authenticate
    Commands:
        /usr/bin/find

Permissions on shadow are as follows

james@machine:~$ ls -laah /etc/shadow
-rw-rw---- 1 root shadow 0 Dec 15 20:00 /etc/shadow
1
  • 2
    After you have received an answer, you can no longer delete your post so others can use this Q&A pair if they have a similar problem.
    – Sven
    Dec 16, 2017 at 20:51

1 Answer 1

4

You can run /usr/bin/find as group shadow and group shadow has write access to /etc/shadow so you may be able to do something like this

sudo -g shadow find /path/to/shadow.bak -exec cp {} /etc/shadow \;

This should work as the exec is run with the user:group of the calling process which in this case would be james:shadow.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .