mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-16 01:27:08 +00:00
exit code check on close
also removed pre-open and post-close as they don't really make sense since all hooks are contained inside the Tomb. The post-close may be implemented using a temp file, if a use case turns up for it.
This commit is contained in:
parent
056d0174f4
commit
127a8ed7ee
12
doc/tomb.1
12
doc/tomb.1
@ -300,12 +300,12 @@ example:
|
|||||||
.B
|
.B
|
||||||
.IP "exec-hooks"
|
.IP "exec-hooks"
|
||||||
This hook file gets executed as user by tomb with the first argument
|
This hook file gets executed as user by tomb with the first argument
|
||||||
determining the step of execution: "pre-open", "post-open",
|
determining the step of execution: "open" or "close". The exec-hooks
|
||||||
"pre-close" or "post-close". The exec-hooks file should be an
|
file should be an executable (ELF or shell script) present inside the
|
||||||
executable (ELF or shell script). Tomb executes this hook as user
|
Tomb. Tomb executes this hook as user supplying two or more arguments,
|
||||||
supplying two or more arguments, the first being the step, followed by
|
the first being the step, followed by the mountpoint of the tomb and,
|
||||||
the mountpoint of the tomb and, on close events, its name, loopback
|
on close events, its name, loopback device and dev-mapper device
|
||||||
device and dev-mapper device paths.
|
paths.
|
||||||
|
|
||||||
.SH PRIVILEGE ESCALATION
|
.SH PRIVILEGE ESCALATION
|
||||||
|
|
||||||
|
25
tomb
25
tomb
@ -1940,10 +1940,6 @@ mount_tomb() {
|
|||||||
|
|
||||||
_success "Opening ::1 tomb file:: on ::2 mount point::" $TOMBNAME $tombmount
|
_success "Opening ::1 tomb file:: on ::2 mount point::" $TOMBNAME $tombmount
|
||||||
|
|
||||||
# execute pre-open hooks if present
|
|
||||||
option_is_set -n ||
|
|
||||||
exec_safe_func_hooks pre-open ${tombmount}
|
|
||||||
|
|
||||||
lo_mount $TOMBPATH
|
lo_mount $TOMBPATH
|
||||||
nstloop=`lo_new`
|
nstloop=`lo_new`
|
||||||
|
|
||||||
@ -2072,7 +2068,7 @@ mount_tomb() {
|
|||||||
# and exec-hooks (execute on open)
|
# and exec-hooks (execute on open)
|
||||||
option_is_set -n || {
|
option_is_set -n || {
|
||||||
exec_safe_bind_hooks ${tombmount}
|
exec_safe_bind_hooks ${tombmount}
|
||||||
exec_safe_func_hooks post-open ${tombmount}
|
exec_safe_func_hooks open ${tombmount}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -2152,7 +2148,7 @@ exec_safe_bind_hooks() {
|
|||||||
#
|
#
|
||||||
# Synopsis: exec_safe_func_hooks /path/to/mounted/tomb
|
# Synopsis: exec_safe_func_hooks /path/to/mounted/tomb
|
||||||
#
|
#
|
||||||
# If an executable file named 'post-hooks' is found inside the tomb,
|
# If an executable file named 'exec-hooks' is found inside the tomb,
|
||||||
# run it as a user. This might need a dialog for security on what is
|
# run it as a user. This might need a dialog for security on what is
|
||||||
# being run, however we expect you know well what is inside your tomb.
|
# being run, however we expect you know well what is inside your tomb.
|
||||||
# If you're mounting an untrusted tomb, be safe and use the -n switch
|
# If you're mounting an untrusted tomb, be safe and use the -n switch
|
||||||
@ -2164,7 +2160,9 @@ exec_safe_func_hooks() {
|
|||||||
_success "Exec hook: ::1 exec hook:: ::2 action:: ::3 argument::" \
|
_success "Exec hook: ::1 exec hook:: ::2 action:: ::3 argument::" \
|
||||||
"${mnt}/exec-hooks" "$1" "$2"
|
"${mnt}/exec-hooks" "$1" "$2"
|
||||||
$mnt/exec-hooks "$1" "$2"
|
$mnt/exec-hooks "$1" "$2"
|
||||||
|
return $?
|
||||||
}
|
}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# }}} - Tomb open
|
# }}} - Tomb open
|
||||||
@ -2628,9 +2626,15 @@ umount_tomb() {
|
|||||||
_warning "Please specify an existing tomb."
|
_warning "Please specify an existing tomb."
|
||||||
return 0 }
|
return 0 }
|
||||||
|
|
||||||
option_is_set -n ||
|
option_is_set -n || {
|
||||||
exec_safe_func_hooks \
|
exec_safe_func_hooks \
|
||||||
pre-close "$tombmount" "$tombname" "$tombloop" "$mapper"
|
close "$tombmount" "$tombname" "$tombloop" "$mapper"
|
||||||
|
exec_hook_res=$?
|
||||||
|
[[ $exec_hook_res = 0 ]] || {
|
||||||
|
_warning "close exec-hook returns a non-zero error code: ::1 error::" $exec_hook_res
|
||||||
|
_failure "Operation aborted"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[[ -n $SLAM ]] && {
|
[[ -n $SLAM ]] && {
|
||||||
_success "Slamming tomb ::1 tomb name:: mounted on ::2 mount point::" \
|
_success "Slamming tomb ::1 tomb name:: mounted on ::2 mount point::" \
|
||||||
@ -2680,11 +2684,6 @@ umount_tomb() {
|
|||||||
[[ $? = 0 ]] || _verbose "/dev/$tombloop was already closed."
|
[[ $? = 0 ]] || _verbose "/dev/$tombloop was already closed."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute post-hooks for eventual cleanup
|
|
||||||
option_is_set -n ||
|
|
||||||
exec_safe_func_hooks \
|
|
||||||
post-close "$tombmount" "$tombname" "$tombloop" "$mapper"
|
|
||||||
|
|
||||||
_success "Tomb ::1 tomb name:: closed: your bones will rest in peace." $tombname
|
_success "Tomb ::1 tomb name:: closed: your bones will rest in peace." $tombname
|
||||||
|
|
||||||
done # loop across mounted tombs
|
done # loop across mounted tombs
|
||||||
|
Loading…
Reference in New Issue
Block a user