Compare commits

...

3 Commits

Author SHA1 Message Date
Fierelier 8ebad1735b Harden cmd execution 2024-02-17 09:50:15 +01:00
Fierelier 063242f86c Remove lock on exit 2024-02-17 09:49:50 +01:00
Fierelier 6b81d61a3b Always trap 2024-02-17 09:49:24 +01:00
5 changed files with 12 additions and 4 deletions

View File

@ -3,6 +3,7 @@ set -e
APP_CMD="$(realpath "$BASH_SOURCE")"
APP_DIR="$(dirname "$APP_CMD")"
source "$APP_DIR/env"
source "$APP_DIR/cmd/trap"
echo "Locking '/run/$APP_NAME/lock' ..." >&2
mkdir -p "/run/$APP_NAME"
@ -14,4 +15,9 @@ while true; do
fi
sleep 1
done
exec bash "$APP_DIR/cmd/main" "${@}"
set +e
bash "$APP_DIR/cmd/main" "${@}"
EXITCODE="$?"
flock -u 100
exit "$EXITCODE"

View File

@ -1,6 +1,5 @@
#!/usr/bin/env bash
set -e
source "$APP_DIR/cmd/trap"
eval "$(bash "$APP_DIR/cmd/main" plist "$2")"
if ! [ "$mm_type" = "disk" ]; then
echo "$mm_path is not a disk." >&2

View File

@ -4,6 +4,11 @@ APP_CMD="$(realpath "$(dirname "$BASH_SOURCE")/../app")"
APP_DIR="$(dirname "$APP_CMD")"
source "$APP_DIR/env"
if [ -f "$APP_DIR/cmd/$1" ]; then
if ! [[ "$(realpath "$APP_DIR/cmd/$1")" == "$APP_DIR/cmd/"* ]]; then
echo "ERROR: Action \"$1\" not found, use: \"$0\" help" >&2
exit 1
fi
source "$APP_DIR/cmd/$1"
exit 0
else

View File

@ -1,6 +1,5 @@
#!/usr/bin/env bash
set -e
source "$APP_DIR/cmd/trap"
eval "$(bash "$APP_DIR/cmd/main" plist "$2")"
if [ "$mm_format" = "crypto_LUKS" ]; then

View File

@ -1,6 +1,5 @@
#!/usr/bin/env bash
set -e
source "$APP_DIR/cmd/trap"
eval "$(bash "$APP_DIR/cmd/main" plist "$2")"
if [ "$mm_format" = "crypto_LUKS" ]; then