From e9c72295d6c6ac9351ebc28ba71c1759635367f2 Mon Sep 17 00:00:00 2001 From: Pratham Date: Wed, 5 Oct 2022 21:36:42 +0200 Subject: [PATCH] kiss: use chroot in run_hook_pkg (#83) --- kiss | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kiss b/kiss index 6145b0c..a17f0d6 100755 --- a/kiss +++ b/kiss @@ -177,11 +177,19 @@ run_hook() { run_hook_pkg() { # Run a hook from the package's database files. - if [ -x "$sys_db/$2/$1" ]; then + hook_path="$sys_db/$2/$1" + if [ -x "$hook_path" ]; then log "$2" "Running $1 hook" - "$sys_db/$2/$1" - elif [ -f "$sys_db/$2/$1" ]; then + user=root + + set -- + equ "$LOGNAME" "$user" || set -- as_user + + "$@" env KISS_ROOT='' \ + chroot "${KISS_ROOT:-/}" "${hook_path#"$KISS_ROOT"}" + + elif [ -f "$hook_path" ]; then war "$2" "skipping $1 hook: not executable" fi }