diff options
author | Djalal Harouni <tixxdz@opendz.org> | 2014-03-11 14:57:15 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-03-11 17:48:43 +0100 |
commit | 44c3298855b60d4635b1be989d7abf0b87070935 (patch) | |
tree | 2386f66db9a4e63a102f4178ab3fe01b3a3402db /src/hostname | |
parent | f200e8bb34d08616dbcb03d6503d0610f4e7e5bc (diff) |
hostnamed: expose OperatingSystemPrettyName and OperatingSystemCPEName on the bus
Diffstat (limited to 'src/hostname')
-rw-r--r-- | src/hostname/hostnamed.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index fab0601b87..3b19d430b2 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -40,6 +40,8 @@ enum { PROP_PRETTY_HOSTNAME, PROP_ICON_NAME, PROP_CHASSIS, + PROP_OS_PRETTY_NAME, + PROP_OS_CPE_NAME, _PROP_MAX }; @@ -89,6 +91,13 @@ static int context_read_data(Context *c) { if (r < 0 && r != -ENOENT) return r; + r = parse_env_file("/etc/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; + return 0; } @@ -546,6 +555,8 @@ static const sd_bus_vtable hostname_vtable[] = { SD_BUS_PROPERTY("PrettyHostname", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_PRETTY_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("IconName", "s", property_get_icon_name, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("Chassis", "s", property_get_chassis, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), + SD_BUS_PROPERTY("OperatingSystemPrettyName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_PRETTY_NAME, SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("OperatingSystemCPEName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_CPE_NAME, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_METHOD("SetHostname", "sb", NULL, method_set_hostname, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetStaticHostname", "sb", NULL, method_set_static_hostname, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetPrettyHostname", "sb", NULL, method_set_pretty_hostname, SD_BUS_VTABLE_UNPRIVILEGED), |