1

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.

4
  • 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 Commented Sep 12, 2017 at 4:16
  • Interesting. Maybe it is the ht application then. ht is an ncurses hex editor. Commented Sep 12, 2017 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. Commented Sep 12, 2017 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. Commented Sep 12, 2017 at 9:13

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.