2013-04-23 11:39:56 +02:00
|
|
|
From: Frederic Crozat <fcrozat@suse.com>
|
|
|
|
Date: Fri, 15 Feb 2013 16:04:39 +0000
|
|
|
|
Subject: handle /etc/HOSTNAME
|
|
|
|
|
|
|
|
(bnc#803653)
|
|
|
|
---
|
2014-03-11 09:24:11 +01:00
|
|
|
src/core/hostname-setup.c | 22 +++++++++++++++++-----
|
|
|
|
src/hostname/hostnamed.c | 12 +++++++++++-
|
2013-04-26 19:21:58 +02:00
|
|
|
2 files changed, 28 insertions(+), 6 deletions(-)
|
2013-04-23 11:39:56 +02:00
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
--- systemd-206/src/core/hostname-setup.c
|
2013-08-02 07:26:48 +02:00
|
|
|
+++ systemd-206/src/core/hostname-setup.c
|
2013-04-26 19:21:58 +02:00
|
|
|
@@ -61,12 +61,24 @@ int hostname_setup(void) {
|
|
|
|
|
|
|
|
r = read_and_strip_hostname("/etc/hostname", &b);
|
|
|
|
if (r < 0) {
|
|
|
|
- if (r == -ENOENT)
|
|
|
|
- enoent = true;
|
|
|
|
- else
|
2013-08-02 07:26:48 +02:00
|
|
|
- log_warning("Failed to read configured hostname: %s", strerror(-r));
|
2013-04-26 19:21:58 +02:00
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ hn = b;
|
2013-08-02 07:26:48 +02:00
|
|
|
|
|
|
|
- hn = NULL;
|
2013-04-26 19:21:58 +02:00
|
|
|
+ }
|
|
|
|
+ else {
|
2013-08-02 07:26:48 +02:00
|
|
|
+ log_warning("Failed to read configured hostname: %s", strerror(-r));
|
2013-04-26 19:21:58 +02:00
|
|
|
+ hn = NULL;
|
|
|
|
+ }
|
|
|
|
} else
|
|
|
|
hn = b;
|
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
--- systemd-209/src/hostname/hostnamed.c
|
|
|
|
+++ systemd-209/src/hostname/hostnamed.c 2014-02-28 11:36:30.594735241 +0000
|
|
|
|
@@ -89,6 +89,10 @@ static int context_read_data(Context *c)
|
2013-04-23 11:39:56 +02:00
|
|
|
if (r < 0 && r != -ENOENT)
|
|
|
|
return r;
|
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
+ r = read_one_line_file("/etc/HOSTNAME", &c->data[PROP_STATIC_HOSTNAME]);
|
2013-04-23 11:39:56 +02:00
|
|
|
+ if (r < 0 && r != -ENOENT)
|
|
|
|
+ return r;
|
|
|
|
+
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
@@ -246,6 +250,7 @@ static int context_write_data_hostname(C
|
|
|
|
}
|
2013-04-23 11:39:56 +02:00
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
static int context_write_data_static_hostname(Context *c) {
|
2013-04-23 11:39:56 +02:00
|
|
|
+ int r;
|
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
assert(c);
|
|
|
|
|
|
|
|
@@ -256,7 +261,12 @@ static int context_write_data_static_hos
|
2013-04-23 11:39:56 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-03-11 09:24:11 +01:00
|
|
|
- return write_string_file_atomic_label("/etc/hostname", c->data[PROP_STATIC_HOSTNAME]);
|
2013-04-23 11:39:56 +02:00
|
|
|
+
|
2014-03-11 09:24:11 +01:00
|
|
|
+ r = write_string_file_atomic_label("/etc/hostname", c->data[PROP_STATIC_HOSTNAME]);
|
2013-04-23 11:39:56 +02:00
|
|
|
+ if (!r) {
|
|
|
|
+ r = symlink_atomic("/etc/hostname", "/etc/HOSTNAME");
|
|
|
|
+ }
|
|
|
|
+ return r;
|
|
|
|
}
|
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
static int context_write_data_other(Context *c) {
|