From b945641ebbc17848378f4cd0f1c116ec78326ad4 Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Sat, 26 Jan 2019 16:41:02 -0500 Subject: [PATCH] Fix handling of long/short names in config.sh - In some cases, valid long names were not being permitted - In some cases, names were transparently modified to match the name type given in vm.args, now a warning or error is printed when this is done, or is attempted but is invalid for some reason --- priv/libexec/config.sh | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/priv/libexec/config.sh b/priv/libexec/config.sh index 637620e4..2688e674 100755 --- a/priv/libexec/config.sh +++ b/priv/libexec/config.sh @@ -265,22 +265,21 @@ _configure_node() { # So here we check for @ and add @hostname if missing case $NAME in *@*) - if [ "$NAME_TYPE" = "-name" ]; then - if [[ ! "$NAME" =~ ^[^@]+@[^\.]+\..*$ ]]; then - # -name was given, but the hostname is not fully qualified - fail "Failed setting -name! The hostname in '$NAME' is not fully qualified" + if [[ "$NAME" =~ ^[^@]+@[^\.]+\..*$ ]]; then + if [ "$NAME_TYPE" = "-sname" ]; then + fail "cannot use fully-qualified name '$NAME' with -sname argument!" fi fi ;; *) - HOSTNAME="$(get_hostname)" - if [ "$NAME_TYPE" = "-name" ]; then - if [[ ! "$HOSTNAME" =~ ^[^\.]+\..*$ ]]; then - # If the hostname is not fully qualified, change the name type - NAME_TYPE="-sname" - fi + if [ "$NAME_TYPE" != "-sname" ]; then + HOSTNAME="$(get_hostname)" + OLD_NAME="$NAME" + NAME="$NAME@$HOSTNAME" + NAME_TYPE="-name" + notice "Automatically converted short name ($OLD_NAME) to long name ($NAME)!" + notice "It is recommended that you set a fully-qualified name in vm.args instead" fi - NAME="$NAME@$HOSTNAME" ;; esac }