chiark / gitweb /
util: generalize is_localhost() and use it everywhere where applicable
[elogind.git] / src / hostname / hostnamed.c
index a3504904a0aabdcc438ff5dbbe2165e002d7d24d..c2b6d3d6f3d66adceb9fc541da70a1446f714fdd 100644 (file)
@@ -108,6 +108,13 @@ static int context_read_data(Context *c) {
                            "PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
                            "CPE_NAME", &c->data[PROP_OS_CPE_NAME],
                            NULL);
+        if (r == -ENOENT) {
+                r = parse_env_file("/usr/lib/os-release", NEWLINE,
+                                   "PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
+                                   "CPE_NAME", &c->data[PROP_OS_CPE_NAME],
+                                   NULL);
+        }
+
         if (r < 0 && r != -ENOENT)
                 return r;
 
@@ -251,7 +258,7 @@ static char* context_fallback_icon_name(Context *c) {
 }
 
 static bool hostname_is_useful(const char *hn) {
-        return !isempty(hn) && !streq(hn, "localhost");
+        return !isempty(hn) && !is_localhost(hn);
 }
 
 static int context_update_kernel_hostname(Context *c) {