Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the agent work with Home Assistant OS #736

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions agents/check_mk_agent.linux
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,9 @@ hex_decode() {
# We might not have xxd available, so we have to do it manually.
# Be aware that this implementation is very slow and should not be used for large data.
local hex="$1"
for ((i = 0; i < ${#hex}; i += 2)); do
while [ "$i" -lt ${#hex} ]; do
printf '%b' "\x${hex:i:2}"
$i = $i+2
done
}

Expand Down Expand Up @@ -405,9 +406,7 @@ define_optionally_encrypt() {
# kdf: pbkdf2, 600.000 iterations

local salt_hex key_hex iv_hex
read -r salt_hex key_hex iv_hex <<<"$(
parse_kdf_output "$(openssl enc -aes-256-cbc -md sha256 -pbkdf2 -iter 600000 -k "${1}" -P)"
)"
read -r salt_hex key_hex iv_hex "$(parse_kdf_output "$(openssl enc -aes-256-cbc -md sha256 -pbkdf2 -iter 600000 -k "${1}" -P)")"

printf "05"
printf "%s" "${2}"
Expand All @@ -420,9 +419,7 @@ define_optionally_encrypt() {
# kdf: openssl custom kdf based on sha256

local salt_hex key_hex iv_hex
read -r salt_hex key_hex iv_hex <<<"$(
parse_kdf_output "$(openssl enc -aes-256-cbc -md sha256 -k "${1}" -P)"
)"
read -r salt_hex key_hex iv_hex "$(parse_kdf_output "$(openssl enc -aes-256-cbc -md sha256 -k "${1}" -P)")"

printf "04"
printf "%s" "${2}"
Expand Down Expand Up @@ -493,14 +490,17 @@ HERE
#

echo "OSType: linux"
while read -r line; do
raw_line="${line//\"/}"
case $line in
ID=*) echo "OSPlatform: ${raw_line##*=}" ;;
NAME=*) echo "OSName: ${raw_line##*=}" ;;
VERSION_ID=*) echo "OSVersion: ${raw_line##*=}" ;;
esac
done <<<"$(cat /etc/os-release 2>/dev/null)"
OS_Release=/etc/os-release
if [ -e "$OS_Release" ]; then
while read -r line; do
raw_line="${line//\"/}"
case $line in
ID=*) echo "OSPlatform: ${raw_line##*=}" ;;
NAME=*) echo "OSName: ${raw_line##*=}" ;;
VERSION_ID=*) echo "OSVersion: ${raw_line##*=}" ;;
esac
done < $OS_Release
fi

#
# BEGIN COMMON AGENT CODE
Expand Down
Loading