diff options
author | merakor <cem@ckyln.com> | 2021-01-05 10:40:08 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-01-05 10:40:08 +0000 |
commit | 28d17201f061e0bcb1c30732c2b0c4d071df1f0c (patch) | |
tree | 8c351a43fd43d03fdc1b0a6a0eff842934aac6e3 | |
parent | 292945be7938f588d8ed2c90fd5759eca12eda10 (diff) | |
download | cpt-28d17201f061e0bcb1c30732c2b0c4d071df1f0c.tar.gz |
run_hook(): store and release the CPT_HOOK variable
FossilOrigin-Name: 4bd8dc7830c8308c31510e5624550b1cf39df1401b4091a5bb80a2e24e109a30
-rw-r--r-- | src/cpt-lib.in | 11 |
1 files 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() { |