From: Roy Marples Date: Tue, 31 Mar 2020 18:45:17 +0000 (+0100) Subject: linux: the default hostname is (none) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbf2c290fbf303b684eb1366cfb61d0a48e8e40c;p=thirdparty%2Fdhcpcd.git linux: the default hostname is (none) It's blank for the BSD's. Respect this when relinquishing the hostname. --- diff --git a/.gitignore b/.gitignore index 99404cb7..6b1a5632 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ dhcpcd.8 dhcpcd-run-hooks dhcpcd-run-hooks.8 dhcpcd.conf.5 +hooks/30-hostname hooks/50-ypbind # Ignore distribution diff --git a/Makefile.inc b/Makefile.inc index 3561ba35..ec5361a6 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -32,3 +32,4 @@ SED_SERVICESTATUS= -e 's:@SERVICESTATUS@:${SERVICESTATUS}:g' SED_STATUSARG= -e 's:@STATUSARG@:${STATUSARG}:g' SED_SCRIPT= -e 's:@SCRIPT@:${SCRIPT}:g' SED_SYS= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' +SED_DEFAULT_HOSTNAME= -e 's:@DEFAULT_HOSTNAME@:${DEFAULT_HOSTNAME}:g' diff --git a/configure b/configure index 838c7222..a8932d33 100755 --- a/configure +++ b/configure @@ -87,6 +87,7 @@ for x do PKG_CONFIG) PKG_CONFIG=$var;; --with-hook) HOOKSCRIPTS="$HOOKSCRIPTS${HOOKSCRIPTS:+ }$var";; --with-hooks|HOOKSCRIPTS) HOOKSCRIPTS=$var; HOOKSET=true;; + --with-default-hostname) _DEFAULT_HOSTNAME=$var;; --build) BUILD=$var;; --host) HOST=$var; HOSTCC=$var-;; --target) TARGET=$var;; @@ -494,6 +495,16 @@ solaris*|sunos*) ;; esac +if [ -n "${_DEFAULT_HOSTNAME+x}" ]; then + DEFAULT_HOSTNAME="${_DEFAULT_HOSTNAME}" +else + case "$OS" in + *|linux*) DEFAULT_HOSTNAME="(none)";; + *) DEFAULT_HOSTNAME="";; + esac +fi +echo "DEFAULT_HOSTNAME= $DEFAULT_HOSTNAME" >>$CONFIG_MK + if [ -z "$INET" -o "$INET" = yes ]; then echo "Enabling INET support" echo "CPPFLAGS+= -DINET" >>$CONFIG_MK diff --git a/hooks/30-hostname b/hooks/30-hostname.in similarity index 97% rename from hooks/30-hostname rename to hooks/30-hostname.in index 3ac73ea4..579c73d3 100644 --- a/hooks/30-hostname +++ b/hooks/30-hostname.in @@ -17,7 +17,7 @@ # If we used to set the hostname, but relinquish control of it, we should # reset to the default value. -: ${hostname_default=} +: ${hostname_default=@DEFAULT_HOSTNAME@} # Some systems don't have hostname(1) _hostname() @@ -54,7 +54,7 @@ _hostname() is_default_hostname() { case "$1" in - ""|"(none)"|localhost|localhost.localdomain|"$hostname_default") + ""|"$hostname_default"|localhost|localhost.localdomain) return 0;; esac return 1 diff --git a/hooks/Makefile b/hooks/Makefile index c1332e58..aa908c12 100644 --- a/hooks/Makefile +++ b/hooks/Makefile @@ -27,6 +27,7 @@ FILES+= ${EGHOOKSCRIPTS} ${SED_SYS} ${SED_SCRIPT} ${SED_DATADIR} \ ${SED_SERVICEEXISTS} ${SED_SERVICECMD} ${SED_SERVICESTATUS} \ ${SED_STATUSARG} \ + ${SED_DEFAULT_HOSTNAME} \ -e 's:@YPDOMAIN_DIR@:${YPDOMAIN_DIR}:g' \ -e 's:@YPDOMAIN_SUFFIX@:${YPDOMAIN_SUFFIX}:g' \ $< > $@