declare -gxr __ipc_private="$__ipc_root/priv/$USER"
declare -gxr __ipc_group="toolbox_ipc"
- declare -gxi __ipc_authentication=1
declare -gxir __ipc_version=1
if ! mkdir -p "$__ipc_private" ||
fi
}
-ipc_authentication_enable() {
- log_info "MESSAGE AUTHENTICATION ENABLED"
- __ipc_authentication=1
- return 0
-}
-
-ipc_authentication_disable() {
- log_error "MESSAGE AUTHENTICATION DISABLED"
- __ipc_authentication=0
- return 0
-}
-
_ipc_msg_get() {
local msg="$1"
local field="$2"
local data
local signature
- local output
data=$(_ipc_msg_get "$msg" "data")
signature=$(_ipc_msg_get "$msg" "signature")
ipc_msg_validate() {
local msg="$1"
- if (( __ipc_authentication == 1 )) &&
- ! _ipc_msg_verify "$msg"; then
+ if ! _ipc_msg_verify "$msg"; then
return 1
fi
local version_ok
local signature_ok
- local validation_status
version=$(_ipc_msg_get "$msg" "version")
data=$(_ipc_msg_get "$msg" "data")
version_ok="no"
signature_ok="no"
- validation_status="disabled"
if _ipc_msg_version_supported "$msg"; then
version_ok="yes"
signature_ok="yes"
fi
- if (( __ipc_authentication == 1 )); then
- validation_status="enabled"
- fi
-
cat <<EOF | log_highlight "ipc message"
Message version: $version [supported: $version_ok]
-Signature valid: $signature_ok [validation: $validation_status]
+Signature valid: $signature_ok
$(ipc_msg_get_signature_info "$msg")
$(_ipc_msg_decode <<< "$msg" | jq .)
EOF
return 1
fi
- if (( __ipc_authentication == 1 )); then
- if ! signature=$(gpg --output - --detach-sig <(echo "$data") |
- _ipc_msg_encode); then
- log_error "Could not make signature"
- return 1
- fi
- else
- signature="-"
+ if ! signature=$(gpg --output - --detach-sig <(echo "$data") |
+ _ipc_msg_encode); then
+ log_error "Could not make signature"
+ return 1
fi
if ! message=$(json_object "version" "$__ipc_version" \