summaryrefslogtreecommitdiff
path: root/src/hostname
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-03-26 16:32:40 +0200
committerLennart Poettering <lennart@poettering.net>2018-05-24 17:01:57 +0200
commitd58ad743f98b3a88de961462fb7adedbf30f727d (patch)
tree0978f88d2e97ef6aacd032b0c6540c70906f5207 /src/hostname
parent080dfda85a9fc4bd471bc056a570d9eab411efa2 (diff)
downloadsystemd-d58ad743f98b3a88de961462fb7adedbf30f727d.tar.gz
os-util: add helpers for finding /etc/os-release
Place this new helpers in a new source file os-util.[ch], and move the existing and related call path_is_os_tree() to it as well.
Diffstat (limited to 'src/hostname')
-rw-r--r--src/hostname/hostnamed.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index db54e472c6..28fc628742 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -16,6 +16,7 @@
#include "env-util.h"
#include "fileio-label.h"
#include "hostname-util.h"
+#include "os-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "selinux-util.h"
@@ -98,18 +99,11 @@ static int context_read_data(Context *c) {
if (r < 0 && r != -ENOENT)
return r;
- r = parse_env_file(NULL, "/etc/os-release", NEWLINE,
- "PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
- "CPE_NAME", &c->data[PROP_OS_CPE_NAME],
- "HOME_URL", &c->data[PROP_HOME_URL],
- NULL);
- if (r == -ENOENT)
- r = parse_env_file(NULL, "/usr/lib/os-release", NEWLINE,
- "PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
- "CPE_NAME", &c->data[PROP_OS_CPE_NAME],
- "HOME_URL", &c->data[PROP_HOME_URL],
- NULL);
-
+ r = parse_os_release(NULL,
+ "PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
+ "CPE_NAME", &c->data[PROP_OS_CPE_NAME],
+ "HOME_URL", &c->data[PROP_HOME_URL],
+ NULL);
if (r < 0 && r != -ENOENT)
return r;