SHA256
1
0
forked from pool/systemd
systemd/handle-etc-HOSTNAME.patch
Marcus Meissner f35f0221c2 Accepting request 280821 from home:jengelh:branches:Base:System
- Update to new upstream release 218
I really want networkd with a functioning machinectl --network-veth (broken in 13.2).

OBS-URL: https://build.opensuse.org/request/show/280821
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=844
2015-02-13 09:43:21 +00:00

80 lines
2.6 KiB
Diff

From: Frederic Crozat <fcrozat@suse.com>
Date: Fri, 15 Feb 2013 16:04:39 +0000
Subject: handle /etc/HOSTNAME
(bnc#803653)
---
src/core/hostname-setup.c | 20 +++++++++++++++-----
src/hostname/hostnamed.c | 12 +++++++++++-
2 files changed, 26 insertions(+), 6 deletions(-)
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) {
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;
+ } else {
+ hn = b;
+ }
+ } else {
log_warning_errno(r, "Failed to read configured hostname: %m");
-
- hn = NULL;
+ hn = NULL;
+ }
} else
hn = b;
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)
if (r < 0 && r != -ENOENT)
return r;
+ r = read_one_line_file("/etc/HOSTNAME", &c->data[PROP_STATIC_HOSTNAME]);
+ if (r < 0 && r != -ENOENT)
+ return r;
+
return 0;
}
@@ -295,6 +299,7 @@ static int context_update_kernel_hostnam
}
static int context_write_data_static_hostname(Context *c) {
+ int r;
assert(c);
@@ -305,7 +310,12 @@ static int context_write_data_static_hos
return 0;
}
- return write_string_file_atomic_label("/etc/hostname", c->data[PROP_STATIC_HOSTNAME]);
+
+ r = write_string_file_atomic_label("/etc/hostname", c->data[PROP_STATIC_HOSTNAME]);
+ if (!r) {
+ r = symlink_atomic("/etc/hostname", "/etc/HOSTNAME");
+ }
+ return r;
}
static int context_write_data_machine_info(Context *c) {