[systemd-devel] [PATCH 1/2] hostnamed: expose OperatingSystemVersion on the bus

Djalal Harouni tixxdz at opendz.org
Mon Apr 7 14:38:21 PDT 2014


This is needed to fix bug:

https://bugs.freedesktop.org/show_bug.cgi?id=76498

Reported-by: Zach <zachcook1991 at gmail.com>
---
 src/hostname/hostnamed.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index abafa62..ca80d50 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -43,6 +43,7 @@ enum {
         PROP_CHASSIS,
         PROP_OS_NAME,
         PROP_OS_RELEASE,
+        PROP_OS_VERSION,
         PROP_OS_PRETTY_NAME,
         PROP_OS_CPE_NAME,
         _PROP_MAX
@@ -82,7 +83,9 @@ static int context_read_data(Context *c) {
         assert_se(uname(&u) >= 0);
         c->data[PROP_OS_NAME] = strdup(u.sysname);
         c->data[PROP_OS_RELEASE] = strdup(u.release);
-        if (!c->data[PROP_OS_NAME] || !c->data[PROP_OS_RELEASE])
+        c->data[PROP_OS_VERSION] = strdup(u.version);
+        if (!c->data[PROP_OS_NAME] || !c->data[PROP_OS_RELEASE] ||
+            !c->data[PROP_OS_VERSION])
                 return -ENOMEM;
 
         c->data[PROP_HOSTNAME] = gethostname_malloc();
@@ -567,6 +570,7 @@ static const sd_bus_vtable hostname_vtable[] = {
         SD_BUS_PROPERTY("Chassis", "s", property_get_chassis, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
         SD_BUS_PROPERTY("OperatingSystemName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("OperatingSystemRelease", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_RELEASE, SD_BUS_VTABLE_PROPERTY_CONST),
+        SD_BUS_PROPERTY("OperatingSystemVersion", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_VERSION, SD_BUS_VTABLE_PROPERTY_CONST),
         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),
-- 
1.8.5.3



More information about the systemd-devel mailing list