Skip to content

Commit

Permalink
export: use su-exec when sudo is absent
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Nov 19, 2023
1 parent 8fa9cd3 commit 2894315
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions distrobox-export
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,18 @@ if [ -z "${container_name}" ]; then
fi

#
if [ "${is_sudo}" -ne 0 ]; then
start_shell="$(command -v sudo) -i"
else
start_shell="$(command -v sudo) -u ${USER} -i"
if command -v su-exec 2> /dev/null; then
if [ "${is_sudo}" -ne 0 ]; then
start_shell="su-exec root su - root -c"
else
start_shell="su-exec root su - ${USER} -c"
fi
elif command -v sudo 2> /dev/null; then
if [ "${is_sudo}" -ne 0 ]; then
start_shell="$(command -v sudo) -i"
else
start_shell="$(command -v sudo) -u ${USER} -i"
fi
fi

# Prefix to add to an existing command to work through the container
Expand Down

0 comments on commit 2894315

Please sign in to comment.