Skip to content

Commit 8a4b55f

Browse files
committed
scripts(run-docker): fix AppArmor sudo
1 parent 5f09a65 commit 8a4b55f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

scripts/run-docker.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ _show_usage() {
5353
echo " running the command in the container"
5454
echo " TERMUX_CONTAINER_SUDO Privilege escalation command to use for"
5555
echo " container commands, e.g. 'sudo', 'doas'"
56-
echo " (Docker only, empty by default)"
5756
echo ""
5857
echo ""
5958
echo "Kindly note that:"
@@ -167,7 +166,14 @@ if [ "$RUNTIME" = "docker" ]; then
167166
APPARMOR_PARSER="apparmor_parser"
168167
fi
169168

170-
if [ -z "$APPARMOR_PARSER" ] || ! $SUDO aa-status --enabled; then
169+
APPARMOR_SUDO=""
170+
if command -v sudo > /dev/null; then
171+
APPARMOR_SUDO="sudo"
172+
elif command -v doas > /dev/null; then
173+
APPARMOR_SUDO="doas"
174+
fi
175+
176+
if [ -z "$APPARMOR_PARSER" ] || ! $APPARMOR_SUDO aa-status --enabled; then
171177
echo "WARNING: apparmor_parser not found, AppArmor profiles will not be loaded!"
172178
echo " This is not recommended, as it may cause security issues and unexpected behavior"
173179
echo " Avoid executing untrusted code in the container"
@@ -181,7 +187,7 @@ if [ "$RUNTIME" = "docker" ]; then
181187
if [ -n "$msg" ]; then
182188
echo "$msg..."
183189
fi
184-
cat "$profile_path" | sed -e "s/{{CONTAINER_NAME}}/$CONTAINER_NAME/g" | $SUDO "$APPARMOR_PARSER" -rK
190+
cat "$profile_path" | sed -e "s/{{CONTAINER_NAME}}/$CONTAINER_NAME/g" | $APPARMOR_SUDO "$APPARMOR_PARSER" -rK
185191
fi
186192
}
187193

0 commit comments

Comments
 (0)