chiark / gitweb /
hostnamed: expose KernelVersion on the bus
authorDjalal Harouni <tixxdz@opendz.org>
Wed, 23 Apr 2014 22:03:34 +0000 (23:03 +0100)
committerLennart Poettering <lennart@poettering.net>
Sun, 18 May 2014 16:46:52 +0000 (01:46 +0900)
This is needed to fix bug:

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

Reported-by: Zach <zachcook1991@gmail.com>
src/hostname/hostnamed.c

index 48cbbdb..5c767cd 100644 (file)
@@ -43,6 +43,7 @@ enum {
         PROP_CHASSIS,
         PROP_KERNEL_NAME,
         PROP_KERNEL_RELEASE,
+        PROP_KERNEL_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_KERNEL_NAME] = strdup(u.sysname);
         c->data[PROP_KERNEL_RELEASE] = strdup(u.release);
-        if (!c->data[PROP_KERNEL_NAME] || !c->data[PROP_KERNEL_RELEASE])
+        c->data[PROP_KERNEL_VERSION] = strdup(u.version);
+        if (!c->data[PROP_KERNEL_NAME] || !c->data[PROP_KERNEL_RELEASE] ||
+            !c->data[PROP_KERNEL_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("KernelName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_KERNEL_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("KernelRelease", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_KERNEL_RELEASE, SD_BUS_VTABLE_PROPERTY_CONST),
+        SD_BUS_PROPERTY("KernelVersion", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_KERNEL_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),