Skip to content

Commit

Permalink
sd-login: let's also make sd-login understand ".host"
Browse files Browse the repository at this point in the history
if sd-bus and machined grok it, then sd-login should grok it too.
  • Loading branch information
poettering committed Jul 25, 2018
1 parent 1e5057b commit a8c9b7a
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/libsystemd/sd-login/sd-login.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit a8c9b7a

Please sign in to comment.