]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-login: let's also make sd-login understand ".host"
authorLennart Poettering <lennart@poettering.net>
Tue, 17 Jul 2018 10:24:50 +0000 (12:24 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 25 Jul 2018 20:48:11 +0000 (22:48 +0200)
if sd-bus and machined grok it, then sd-login should grok it too.

src/libsystemd/sd-login/sd-login.c

index 9dfba51ceaf81e37a1eced8ca013c2a93cb99450..5940eccead8c9e3a83e4318817654e294e71e899 100644 (file)
@@ -890,20 +890,27 @@ _public_ int sd_machine_get_class(const char *machine, char **class) {
         const char *p;
         int r;
 
-        assert_return(machine_name_is_valid(machine), -EINVAL);
         assert_return(class, -EINVAL);
 
-        p = strjoina("/run/systemd/machines/", machine);
-        r = parse_env_file(NULL, p, NEWLINE, "CLASS", &c, NULL);
-        if (r == -ENOENT)
-                return -ENXIO;
-        if (r < 0)
-                return r;
-        if (!c)
-                return -EIO;
+        if (streq(machine, ".host")) {
+                c = strdup("host");
+                if (!c)
+                        return -ENOMEM;
+        } else {
+                if (!machine_name_is_valid(machine))
+                        return -EINVAL;
 
-        *class = TAKE_PTR(c);
+                p = strjoina("/run/systemd/machines/", machine);
+                r = parse_env_file(NULL, p, NEWLINE, "CLASS", &c, NULL);
+                if (r == -ENOENT)
+                        return -ENXIO;
+                if (r < 0)
+                        return r;
+                if (!c)
+                        return -EIO;
+        }
 
+        *class = TAKE_PTR(c);
         return 0;
 }