[__hostname] Check hostname length if getconf(1) is available

This commit is contained in:
Dennis Camera 2019-10-24 19:44:51 +02:00
parent cee553a6dd
commit c3b066c147
2 changed files with 22 additions and 6 deletions

View file

@ -0,0 +1,10 @@
#!/bin/sh -e
command -v getconf >/dev/null || exit 0
val=$(getconf HOST_NAME_MAX 2>/dev/null)
if test -n "${val}" -a "${val}" != 'undefined'
then
echo "${val}"
fi

View file

@ -20,6 +20,13 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
not_supported() {
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
echo "Please contribute an implementation for it if you can." >&2
exit 1
}
os=$(cat "$__global/explorer/os") os=$(cat "$__global/explorer/os")
if [ -f "$__object/parameter/name" ]; then if [ -f "$__object/parameter/name" ]; then
name_should="$(cat "$__object/parameter/name")" name_should="$(cat "$__object/parameter/name")"
@ -38,12 +45,11 @@ else
esac esac
fi fi
if test -n "${max_len}" -a "$(wc -c "${name_should}")" -gt "${max_len}"a
not_supported() { then
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 printf "Host name too long. Up to %u characters allowed.\n" "${max_len}" >&2
echo "Please contribute an implementation for it if you can." >&2
exit 1 exit 1
} fi
case $os case $os
in in