From d4313c7501b39c09e01cee530ec36a7452bcfc53 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Fri, 25 Oct 2019 01:41:26 +0200 Subject: [PATCH] [__hostname] Fix checking of maximum hostname length against sysconf(3) --- cdist/conf/type/__hostname/manifest | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 2c6057d6..f3739f6c 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -28,6 +28,8 @@ not_supported() { os=$(cat "$__global/explorer/os") +max_len=$(cat "$__object/explorer/max_len") + if [ -f "$__object/parameter/name" ]; then name_should="$(cat "$__object/parameter/name")" else @@ -45,7 +47,7 @@ else esac fi -if test -n "${max_len}" -a "$(wc -c "${name_should}")" -gt "${max_len}"a +if test -n "${max_len}" -a "$(printf "${name_should}" | wc -c)" -gt "${max_len}" then printf "Host name too long. Up to %u characters allowed.\n" "${max_len}" >&2 exit 1