Skip to content

Commit

Permalink
Fix handling of long/short names in config.sh
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
bitwalker committed Jan 26, 2019
1 parent 59e4835 commit b945641
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions priv/libexec/config.sh
Expand Up @@ -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
}
Expand Down

0 comments on commit b945641

Please sign in to comment.