X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fgrml-hostname;h=b7a6eab8667424bc23c8b97f2a04c07143b6282b;hb=2d67bfb005b9f1c2f94f0cfb350ea47912542c79;hp=b529d1772107c632ef79b92b46880a7b0ca907c6;hpb=9375a86c1fe0f2936a7ff20f46aa98a4d5f1ffb3;p=grml-scripts.git diff --git a/usr_sbin/grml-hostname b/usr_sbin/grml-hostname index b529d17..b7a6eab 100755 --- a/usr_sbin/grml-hostname +++ b/usr_sbin/grml-hostname @@ -37,6 +37,20 @@ else retval=0 fi +# stupid + simplified checking for valid hostname (according to RFC 952) +VALIDATE=$(echo "$NEW_HOSTNAME" | tr --delete '[:alnum:]-') +if [ -n "$VALIDATE" ] ; then + if [ -z "$NONINTERACTIVE" ] ; then + dialog --title "${PN}" \ + --msgbox "Error: invalid characters specified in hostname: '$VALIDATE' can not be used inside hostnames." \ + 0 0 + exec "$0" + else + echo "Error: invalid characters specified in hostname: '$VALIDATE' can not be used inside hostnames." >&2 + exit 1 + fi +fi + case $retval in 0) echo "$NEW_HOSTNAME" > /etc/hostname