From 28d17201f061e0bcb1c30732c2b0c4d071df1f0c Mon Sep 17 00:00:00 2001 From: merakor Date: Tue, 5 Jan 2021 10:40:08 +0000 Subject: run_hook(): store and release the CPT_HOOK variable FossilOrigin-Name: 4bd8dc7830c8308c31510e5624550b1cf39df1401b4091a5bb80a2e24e109a30 --- src/cpt-lib.in | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cpt-lib.in b/src/cpt-lib.in index 7728ae8..0c46dbe 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -429,16 +429,19 @@ pop() { } run_hook() { - # If a fourth parameter 'root' is specified, source - # the hook from a predefined location to avoid privilige - # escalation through user scripts. + # Store the CPT_HOOK variable so that we can revert it if it is changed. + oldCPT_HOOK=$CPT_HOOK + + # If a fourth parameter 'root' is specified, source the hook from a + # predefined location to avoid privilige escalation through user scripts. [ "$4" ] && CPT_HOOK=$CPT_ROOT/etc/cpt-hook - [ -f "$CPT_HOOK" ] || return 0 + [ -f "$CPT_HOOK" ] || { CPT_HOOK=$oldCPT_HOOK; return 0 ;} [ "$2" ] && log "$2" "Running $1 hook" TYPE=${1:-null} PKG=${2:-null} DEST=${3:-null} . "$CPT_HOOK" + CPT_HOOK=$oldCPT_HOOK } decompress() { -- cgit v1.2.3