diff options
author | Martin Pitt <martinpitt@users.noreply.github.com> | 2017-01-31 08:26:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-31 08:26:42 +0100 |
commit | 70d940ec75143399b4065eeddcc20987cd7f4ad1 (patch) | |
tree | 6666e27ae11c51d67ea801fa40af31dd1c48c994 | |
parent | c954f33233be2a3aad2d13e934316c10897d4893 (diff) | |
parent | 8146c32b9264a6915d467a5cab1a24311fbede7e (diff) |
Merge pull request #5175 from keszybz/hostname-fallback
Allow distributions to override the "localhost" fallback
-rw-r--r-- | configure.ac | 18 | ||||
-rw-r--r-- | src/hostname/hostnamed.c | 4 |
2 files changed, 16 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index 48c71ce340..b9143d28ca 100644 --- a/configure.ac +++ b/configure.ac @@ -601,6 +601,15 @@ AC_ARG_WITH([nobody-group], AC_SUBST(NOBODY_GROUP_NAME) AC_DEFINE_UNQUOTED(NOBODY_GROUP_NAME, ["$NOBODY_GROUP_NAME"], [The name of the nobody group (the one with GID 65534)]) +AC_ARG_WITH([fallback-hostname], + AS_HELP_STRING([--with-fallback-hostname=NAME], + [specify the hostname used if none configured]), + [FALLBACK_HOSTNAME="$withval"], + [FALLBACK_HOSTNAME=localhost]) + +AC_SUBST(FALLBACK_HOSTNAME) +AC_DEFINE_UNQUOTED(FALLBACK_HOSTNAME, ["$FALLBACK_HOSTNAME"], [The hostname used if none configured]) + # ------------------------------------------------------------------------------ have_xz=no AC_ARG_ENABLE(xz, AS_HELP_STRING([--disable-xz], [disable optional XZ support])) @@ -1715,12 +1724,13 @@ AC_MSG_RESULT([ Wheel group: ${have_wheel_group} Debug shell: ${SUSHELL} @ ${DEBUGTTY} TTY GID: ${TTY_GID} - Maximum System UID: ${SYSTEM_UID_MAX} - Maximum System GID: ${SYSTEM_GID_MAX} + Maximum system UID: ${SYSTEM_UID_MAX} + Maximum system GID: ${SYSTEM_GID_MAX} Certificate root: ${CERTIFICATEROOT} Support URL: ${SUPPORT_URL} - Nobody User Name: ${NOBODY_USER_NAME} - Nobody Group Name: ${NOBODY_GROUP_NAME} + nobody user name: ${NOBODY_USER_NAME} + nobody group name: ${NOBODY_GROUP_NAME} + Fallback hostname: ${FALLBACK_HOSTNAME} CFLAGS: ${OUR_CFLAGS} ${CFLAGS} CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS} diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 74256e4444..4657cf8c77 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -283,7 +283,7 @@ static int context_update_kernel_hostname(Context *c) { /* ... and the ultimate fallback */ else - hn = "localhost"; + hn = FALLBACK_HOSTNAME; if (sethostname_idempotent(hn) < 0) return -errno; @@ -419,7 +419,7 @@ static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error * name = c->data[PROP_STATIC_HOSTNAME]; if (isempty(name)) - name = "localhost"; + name = FALLBACK_HOSTNAME; if (!hostname_is_valid(name, false)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid hostname '%s'", name); |