Skip to content

Commit 61be15b

Browse files
committed
linux: the default hostname is (none)
It's blank for the BSD's. Respect this when relinquishing the hostname.
1 parent b78f0c7 commit 61be15b

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dhcpcd.8
1919
dhcpcd-run-hooks
2020
dhcpcd-run-hooks.8
2121
dhcpcd.conf.5
22+
hooks/30-hostname
2223
hooks/50-ypbind
2324

2425
# Ignore distribution

Makefile.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ SED_SERVICESTATUS= -e 's:@SERVICESTATUS@:${SERVICESTATUS}:g'
3232
SED_STATUSARG= -e 's:@STATUSARG@:${STATUSARG}:g'
3333
SED_SCRIPT= -e 's:@SCRIPT@:${SCRIPT}:g'
3434
SED_SYS= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
35+
SED_DEFAULT_HOSTNAME= -e 's:@DEFAULT_HOSTNAME@:${DEFAULT_HOSTNAME}:g'

configure

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ for x do
8787
PKG_CONFIG) PKG_CONFIG=$var;;
8888
--with-hook) HOOKSCRIPTS="$HOOKSCRIPTS${HOOKSCRIPTS:+ }$var";;
8989
--with-hooks|HOOKSCRIPTS) HOOKSCRIPTS=$var; HOOKSET=true;;
90+
--with-default-hostname) _DEFAULT_HOSTNAME=$var;;
9091
--build) BUILD=$var;;
9192
--host) HOST=$var; HOSTCC=$var-;;
9293
--target) TARGET=$var;;
@@ -494,6 +495,16 @@ solaris*|sunos*)
494495
;;
495496
esac
496497

498+
if [ -n "${_DEFAULT_HOSTNAME+x}" ]; then
499+
DEFAULT_HOSTNAME="${_DEFAULT_HOSTNAME}"
500+
else
501+
case "$OS" in
502+
*|linux*) DEFAULT_HOSTNAME="(none)";;
503+
*) DEFAULT_HOSTNAME="";;
504+
esac
505+
fi
506+
echo "DEFAULT_HOSTNAME= $DEFAULT_HOSTNAME" >>$CONFIG_MK
507+
497508
if [ -z "$INET" -o "$INET" = yes ]; then
498509
echo "Enabling INET support"
499510
echo "CPPFLAGS+= -DINET" >>$CONFIG_MK

hooks/30-hostname renamed to hooks/30-hostname.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# If we used to set the hostname, but relinquish control of it, we should
1919
# reset to the default value.
20-
: ${hostname_default=}
20+
: ${hostname_default=@DEFAULT_HOSTNAME@}
2121

2222
# Some systems don't have hostname(1)
2323
_hostname()
@@ -54,7 +54,7 @@ _hostname()
5454
is_default_hostname()
5555
{
5656
case "$1" in
57-
""|"(none)"|localhost|localhost.localdomain|"$hostname_default")
57+
""|"$hostname_default"|localhost|localhost.localdomain)
5858
return 0;;
5959
esac
6060
return 1

hooks/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ FILES+= ${EGHOOKSCRIPTS}
2727
${SED_SYS} ${SED_SCRIPT} ${SED_DATADIR} \
2828
${SED_SERVICEEXISTS} ${SED_SERVICECMD} ${SED_SERVICESTATUS} \
2929
${SED_STATUSARG} \
30+
${SED_DEFAULT_HOSTNAME} \
3031
-e 's:@YPDOMAIN_DIR@:${YPDOMAIN_DIR}:g' \
3132
-e 's:@YPDOMAIN_SUFFIX@:${YPDOMAIN_SUFFIX}:g' \
3233
$< > $@

0 commit comments

Comments
 (0)