0

The setup:

~$ ls -l /etc/sudoers
-r--r----- 1 root root 614 2017-09-10 20:29 /etc/sudoers

~$ ls -l /etc/shadow
-rw-r----- 1 root shadow 794 2011-04-18 11:49 /etc/shadow

$ ls -l $(which ht)
-rwsr-sr-x 1 root root 2072344 2011-04-16 07:26 /usr/local/bin/ht

ht is a ncurses hex editor.

The question: Why is the ht program able to edit /etc/sudoers (including saving changes), but cannot even read /etc/shadow? It seems like the ht executable should be able to access both files based on its setuid bit and root user ownership. Further, it seems like if edits can be saved to either file, it would be /etc/shadow based on the write bit for root. However, the setgid bit is unexpectedly coming in to play. If I change the /etc/shadow file group ownership to root (instead of shadow), I can then access it with the ht program.

  • I have not idea what ht is, but I tried the same setgid/setuid permissions on copies of cat and vim and both programs were able to read both files perfectly fine. (Vim complained about /etc/sudoers being read-only, of course.) On Ubuntu 16.04 – muru Sep 12 '17 at 4:16
  • Interesting. Maybe it is the ht application then. ht is an ncurses hex editor. – rootshellz Sep 12 '17 at 4:20
  • 1
    What error do you get from ht when you try? Please update the question with the exact and full error message that you get. – Kusalananda Sep 12 '17 at 7:05
  • Hey Ben, It may be due to different group ids (ht and sudoers have same uid and gid but not ht and shadow ) I am just helping explaining behavior. because even this is true still weird. – Devidas Sep 12 '17 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.