~$ 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.
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.