From 6f07527f36d59a11e6415b535cbf89ce93c36f01 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Thu, 11 Feb 2016 09:50:17 -0500 Subject: [PATCH] Strip leading and trailing hyphens Strip leading and trailing hyphens in the resulting munged hostname. Leading and trailing hyphens are not valid according to RFCs 952 and 1123. (This problem surfaces immediately when using the default configuration of OneFlow, since it names new VMs ending with a parenthesis.) --- base_arch/etc/one-context.d/05-hostname | 2 +- base_deb.one/etc/one-context.d/05-hostname | 2 +- base_rpm.one/etc/one-context.d/05-hostname | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/base_arch/etc/one-context.d/05-hostname b/base_arch/etc/one-context.d/05-hostname index 60e732b..d401dd0 100755 --- a/base_arch/etc/one-context.d/05-hostname +++ b/base_arch/etc/one-context.d/05-hostname @@ -20,7 +20,7 @@ function get_dns_name() { } if [ -n "$SET_HOSTNAME" ]; then - set_hostname $(echo "$SET_HOSTNAME" | sed -e 's/[^-a-zA-Z0-9]/-/g') + set_hostname $(echo "$SET_HOSTNAME" | sed -e 's/[^-a-zA-Z0-9]/-/g' -e 's/^-*//g' -e 's/-*$//g') elif [ -n "$DNS_HOSTNAME" ]; then set_hostname $(get_dns_name) fi diff --git a/base_deb.one/etc/one-context.d/05-hostname b/base_deb.one/etc/one-context.d/05-hostname index b0b08c7..92bcc76 100755 --- a/base_deb.one/etc/one-context.d/05-hostname +++ b/base_deb.one/etc/one-context.d/05-hostname @@ -22,7 +22,7 @@ function get_dns_name() { } if [ -n "$SET_HOSTNAME" ]; then - set_hostname $(echo "$SET_HOSTNAME" | sed -e 's/[^-a-zA-Z0-9]/-/g') + set_hostname $(echo "$SET_HOSTNAME" | sed -e 's/[^-a-zA-Z0-9]/-/g' -e 's/^-*//g' -e 's/-*$//g') elif [ -n "$DNS_HOSTNAME" ]; then set_hostname $(get_dns_name) fi diff --git a/base_rpm.one/etc/one-context.d/05-hostname b/base_rpm.one/etc/one-context.d/05-hostname index 4532c51..df77aa0 100755 --- a/base_rpm.one/etc/one-context.d/05-hostname +++ b/base_rpm.one/etc/one-context.d/05-hostname @@ -23,7 +23,7 @@ function get_dns_name() { } if [ -n "$SET_HOSTNAME" ]; then - set_hostname $(echo "$SET_HOSTNAME" | sed -e 's/[^-a-zA-Z0-9]/-/g') + set_hostname $(echo "$SET_HOSTNAME" | sed -e 's/[^-a-zA-Z0-9]/-/g' -e 's/^-*//g' -e 's/-*$//g') elif [ -n "$DNS_HOSTNAME" ]; then set_hostname $(get_dns_name) fi