SHA256
1
0
forked from pool/systemd
systemd/handle-etc-HOSTNAME.patch

82 lines
2.6 KiB
Diff
Raw Normal View History

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 | 22 +++++++++++++++++-----
src/hostname/hostnamed.c | 12 +++++++++++-
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c
Accepting request 176957 from home:fcrozat:branches:Base:System - Update to release 204: + systemd-nspawn creates etc/resolv.conf in container if needed. + systemd-nspawn will store metadata about container in container cgroup including its root directory. + cgroup hierarchy has been reworked, all objects are now suffxed (with .session for user sessions, .user for users, .nspawn for containers). All cgroup names are now escaped to preven collision of object names. + systemctl list-dependencies gained --plain, --reverse, --after and --before switches. + systemd-inhibit shows processes name taking inhibitor lock. + nss-myhostname will now resolve "localhost" implicitly. + .include is not allowed recursively anymore and only in unit files. Drop-in files should be favored in most cases. + systemd-analyze gained "critical-chain" command, to get slowest chain of units run during boot-up. + systemd-nspawn@.service has been added to easily run nspawn container for system services. Just start "systemd-nspawn@foobar.service" and container from /var/lib/container/foobar" will be booted. + systemd-cgls has new --machine parameter to list processes from one container. + ConditionSecurity= can now check for apparmor and SMACK. + /etc/systemd/sleep.conf has been introduced to configure which kernel operation will be execute when "suspend", "hibernate" or "hybrid-sleep" is requrested. It allow new kernel "freeze" state to be used too. (This setting won't have any effect if pm-utils is installed). + ENV{SYSTEMD_WANTS} in udev rules will now implicitly escape passed argument if applicable. OBS-URL: https://build.opensuse.org/request/show/176957 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=388
2013-05-29 17:26:40 +02:00
index 8aa1cff..0ce683b 100644
--- a/src/core/hostname-setup.c
+++ b/src/core/hostname-setup.c
@@ -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
+ 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("Failed to read configured hostname: %s", strerror(-r));
-
- hn = NULL;
+ hn = NULL;
+ }
} else
hn = b;
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
2013-04-19 22:31:17 +02:00
index c7f454c..cfbd706 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -129,6 +129,10 @@ static int read_data(void) {
if (r < 0 && r != -ENOENT)
return r;
+ r = read_one_line_file("/etc/HOSTNAME", &data[PROP_STATIC_HOSTNAME]);
+ if (r < 0 && r != -ENOENT)
+ return r;
+
return 0;
}
@@ -283,6 +287,7 @@ static int write_data_hostname(void) {
static int write_data_static_hostname(void) {
+ int r;
if (isempty(data[PROP_STATIC_HOSTNAME])) {
if (unlink("/etc/hostname") < 0)
@@ -290,7 +295,12 @@ static int write_data_static_hostname(void) {
return 0;
}
2013-04-19 22:31:17 +02:00
- return write_string_file_atomic_label("/etc/hostname", data[PROP_STATIC_HOSTNAME]);
+
2013-04-19 22:31:17 +02:00
+ r = write_string_file_atomic_label("/etc/hostname", data[PROP_STATIC_HOSTNAME]);
+ if (!r) {
+ r = symlink_atomic("/etc/hostname", "/etc/HOSTNAME");
+ }
+ return r;
}
static int write_data_other(void) {