From: Frederic Crozat Date: Fri, 15 Feb 2013 16:04:39 +0000 Subject: handle /etc/HOSTNAME (bnc#803653) --- src/hostname/hostnamed.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 4aad17b..e7532f6 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; } - return write_one_line_file_atomic_label("/etc/hostname", data[PROP_STATIC_HOSTNAME]); + + r = write_one_line_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) {