2013-04-13 13:09:53 +02:00
|
|
|
From: Frederic Crozat <fcrozat@suse.com>
|
|
|
|
Date: Fri, 15 Feb 2013 16:04:39 +0000
|
|
|
|
Subject: handle /etc/HOSTNAME
|
|
|
|
|
|
|
|
(bnc#803653)
|
|
|
|
---
|
2015-02-13 10:43:21 +01:00
|
|
|
src/core/hostname-setup.c | 20 +++++++++++++++-----
|
2014-02-28 18:10:52 +01:00
|
|
|
src/hostname/hostnamed.c | 12 +++++++++++-
|
2015-02-13 10:43:21 +01:00
|
|
|
2 files changed, 26 insertions(+), 6 deletions(-)
|
2013-04-13 13:09:53 +02:00
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
Index: systemd-218/src/core/hostname-setup.c
|
|
|
|
===================================================================
|
|
|
|
--- systemd-218.orig/src/core/hostname-setup.c
|
|
|
|
+++ systemd-218/src/core/hostname-setup.c
|
|
|
|
@@ -61,12 +61,22 @@ int hostname_setup(void) {
|
2013-04-26 18:25:08 +02:00
|
|
|
|
|
|
|
r = read_and_strip_hostname("/etc/hostname", &b);
|
|
|
|
if (r < 0) {
|
|
|
|
- if (r == -ENOENT)
|
|
|
|
- enoent = true;
|
|
|
|
- else
|
|
|
|
+ if (r == -ENOENT) {
|
|
|
|
+ /* use SUSE fallback */
|
|
|
|
+ r = read_and_strip_hostname("/etc/HOSTNAME", &b);
|
|
|
|
+ if (r < 0) {
|
|
|
|
+ if (r == -ENOENT)
|
|
|
|
+ enoent = true;
|
|
|
|
+ else
|
|
|
|
+ log_warning("Failed to read configured hostname: %s", strerror(-r));
|
|
|
|
+ hn = NULL;
|
2015-02-13 10:43:21 +01:00
|
|
|
+ } else {
|
2013-04-26 18:25:08 +02:00
|
|
|
+ hn = b;
|
2015-02-13 10:43:21 +01:00
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
log_warning_errno(r, "Failed to read configured hostname: %m");
|
|
|
|
-
|
2013-07-23 11:21:21 +02:00
|
|
|
- hn = NULL;
|
2013-04-26 18:25:08 +02:00
|
|
|
+ hn = NULL;
|
2015-02-13 10:43:21 +01:00
|
|
|
+ }
|
2013-04-26 18:25:08 +02:00
|
|
|
} else
|
|
|
|
hn = b;
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
Index: systemd-218/src/hostname/hostnamed.c
|
|
|
|
===================================================================
|
|
|
|
--- systemd-218.orig/src/hostname/hostnamed.c
|
|
|
|
+++ systemd-218/src/hostname/hostnamed.c
|
|
|
|
@@ -124,6 +124,10 @@ static int context_read_data(Context *c)
|
2013-04-13 13:09:53 +02:00
|
|
|
if (r < 0 && r != -ENOENT)
|
|
|
|
return r;
|
|
|
|
|
2014-02-28 18:10:52 +01:00
|
|
|
+ r = read_one_line_file("/etc/HOSTNAME", &c->data[PROP_STATIC_HOSTNAME]);
|
2013-04-13 13:09:53 +02:00
|
|
|
+ if (r < 0 && r != -ENOENT)
|
|
|
|
+ return r;
|
|
|
|
+
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -295,6 +299,7 @@ static int context_update_kernel_hostnam
|
2014-02-28 18:10:52 +01:00
|
|
|
}
|
2013-04-13 13:09:53 +02:00
|
|
|
|
2014-02-28 18:10:52 +01:00
|
|
|
static int context_write_data_static_hostname(Context *c) {
|
2013-04-13 13:09:53 +02:00
|
|
|
+ int r;
|
|
|
|
|
2014-02-28 18:10:52 +01:00
|
|
|
assert(c);
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -305,7 +310,12 @@ static int context_write_data_static_hos
|
2013-04-13 13:09:53 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-02-28 18:10:52 +01:00
|
|
|
- return write_string_file_atomic_label("/etc/hostname", c->data[PROP_STATIC_HOSTNAME]);
|
2013-04-13 13:09:53 +02:00
|
|
|
+
|
2014-02-28 18:10:52 +01:00
|
|
|
+ r = write_string_file_atomic_label("/etc/hostname", c->data[PROP_STATIC_HOSTNAME]);
|
2013-04-13 13:09:53 +02:00
|
|
|
+ if (!r) {
|
|
|
|
+ r = symlink_atomic("/etc/hostname", "/etc/HOSTNAME");
|
|
|
|
+ }
|
|
|
|
+ return r;
|
|
|
|
}
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
static int context_write_data_machine_info(Context *c) {
|