Skip to content

Commit

Permalink
Use sudo instead of su.
Browse files Browse the repository at this point in the history
Fixes #3860
  • Loading branch information
dnschneid committed Dec 7, 2018
1 parent 38012fd commit fb40bff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion host-bin/crash_reporter_wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,5 @@ else
fi

# Run the generated command within the appropriate chroot
exec chroot "$root" su -s '/bin/sh' -c "$cmd" - "$username"
export SHELL=/bin/sh
exec chroot "$root" sudo -s -u "$username" "$cmd"
10 changes: 5 additions & 5 deletions host-bin/enter-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Options:
-b Fork and run the specified command silently in the background.
-c CHROOTS Directory the chroots are in. Default: $CHROOTS
-l Make the command part of a login. Parameters are passed directly
to the chroot command, and a call to su is appended.
to the chroot command, and a call to sudo is appended.
-k KEYFILE Override the auto-detected encryption key location.
-n NAME Name of the chroot to enter. Default: first one found in CHROOTS
-t TARGET Only enter the chroot if it contains the specified TARGET.
Expand All @@ -47,7 +47,7 @@ chrootcmd() {
# env may be overridden when running in the background; don't let it fork.
local ret=0 oldtrap="$TRAP"
TRAP=''
env -i chroot "$CHROOT" su -s '/bin/sh' -c "$*" - root || ret=$?
env -i SHELL=/bin/sh chroot "$CHROOT" sudo -u root -s "$*" || ret=$?
local pid="$!"
# $pid might not be set if env has not been redefined yet
if [ -n "$BACKGROUND" ] && [ -n "$pid" ]; then
Expand Down Expand Up @@ -729,7 +729,7 @@ else
fi

if [ $# = 0 -o -n "$LOGIN" ]; then
env -i TERM="$TERM" chroot "$CHROOT" "$@" su - "$USERNAME" || ret=$?
env -i TERM="$TERM" chroot "$CHROOT" "$@" sudo -i -u "$USERNAME" || ret=$?
else
# Escape out the command
cmd="export SHELL='$CHROOTSHELL';"
Expand All @@ -739,8 +739,8 @@ else
for param in "$@"; do
cmd="$cmd'`echo -n "$param" | sed "s/'/'\\\\\\''/g"`' "
done
env -i TERM="$TERM" chroot "$CHROOT" \
su -s '/bin/sh' -c "$cmd" - "$USERNAME" \
env -i TERM="$TERM" SHELL=/bin/sh chroot "$CHROOT" \
sudo -s -u "$USERNAME" "$cmd" \
|| ret=$?
fi
fi
Expand Down
4 changes: 2 additions & 2 deletions host-bin/unmount-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ unmount() {
fi

# Kill the chroot's system dbus if one is running; failure is fine
env -i chroot "$CHROOT" su -s '/bin/sh' -c '
env -i SHELL=/bin/sh chroot "$CHROOT" sudo -s -u root '
pidfile="/var/run/dbus/pid"
if [ ! -f "$pidfile" ]; then
exit 0
Expand All @@ -200,7 +200,7 @@ unmount() {
if ! grep -q "^dbus-daemon" "/proc/$pid/cmdline" 2>/dev/null; then
exit 0
fi
kill $pid' - root 2>/dev/null || true
kill $pid' 2>/dev/null || true

# Unmount all mounts
ntries=0
Expand Down

0 comments on commit fb40bff

Please sign in to comment.