Skip to content

Commit

Permalink
init: change rootful detection condition (#909)
Browse files Browse the repository at this point in the history
* Change rootful detection condition

`cat /run/host/etc/shadow > /dev/null` appears to always return true even when rootless.

Check to see if `/etc/shadow` is writable to determine access. The earlier commit for checking readability also always returned true.

* Update distrobox-init
  • Loading branch information
termdisc authored Aug 13, 2023
1 parent ace5009 commit 373eb30
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion distrobox-init
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ fi
#
# if /run/.nopasswd is present, let's treat the init as rootless, this is not
# a good thing, users behold!
if cat /run/host/etc/shadow > /dev/null && [ ! -e /run/.nopasswd ]; then
if stat /run/host/etc/shadow &&
[ "$(stat -c "%u" /run/host/etc/shadow)" = "0" ] &&
[ ! -e /run/.nopasswd ]; then
rootful=1
fi

Expand Down

0 comments on commit 373eb30

Please sign in to comment.