Skip to content

Commit

Permalink
enter: do not use a shell when executing a custom command, Fix #1275
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
  • Loading branch information
89luca89 committed Mar 11, 2024
1 parent 50595a8 commit 82a69f0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions distrobox-enter
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ fi
container_command=""
# by default we use getent to get the login shell of the user and use that
container_command_login="/bin/sh -c \"\\\$(getent passwd ${USER} | cut -f 7 -d :) -l\""
# and we execute container_command using sh -c
container_command_prefix="/bin/sh -c"
container_image_default="registry.fedoraproject.org/fedora-toolbox:39"
container_manager="autodetect"
container_manager_additional_flags=""
Expand Down Expand Up @@ -214,7 +212,7 @@ while :; do
;;
-e | --exec | --)
shift
container_command="$1"
container_command="\"$1\""
shift
for arg in "$@"; do
arg="$(echo "${arg}x" | sed 's|'\''|'\'\\\\\'\''|g')"
Expand Down Expand Up @@ -335,7 +333,6 @@ generate_command() {
container_command_login="${container_command_login} --pty"
fi
container_command_login="${container_command_login} -c \"\\\$(getent passwd ${USER} | cut -f 7 -d :) -l\""
container_command_prefix="${container_command_login} -c"
else
result_command="${result_command}
--user=\"${USER}"\"
Expand Down Expand Up @@ -468,8 +465,7 @@ generate_command() {
${container_name}"

if [ -n "${container_command}" ]; then
result_command="${result_command}
${container_command_prefix} \"${container_command}\""
result_command="${result_command} ${container_command}"
else
# if no command was specified, let's execute a command that will find
# and run the default shell for the user
Expand Down

0 comments on commit 82a69f0

Please sign in to comment.