Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.3:Update
pacemaker.8750
pacemaker-libcrmservice-list-systemd-unit-files...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pacemaker-libcrmservice-list-systemd-unit-files.patch of Package pacemaker.8750
commit 59a3dd2f5a9ae218d1064e02188d4d83a6771b01 Author: Ken Gaillot <kgaillot@redhat.com> Date: Fri Oct 13 11:04:50 2017 -0500 Fix: libcrmservice: list systemd unit files, not only active units The typical use case of listing agents is to see what can be used, and if a systemd unit isn't active, it won't be listed by ListUnits. Use ListUnitFiles instead, and filter them by the types of units we can manage (service, mount, and socket). Closes CLBZ#5299 diff --git a/lib/services/systemd.c b/lib/services/systemd.c index 6f3c28e65..6d139eee6 100644 --- a/lib/services/systemd.c +++ b/lib/services/systemd.c @@ -357,7 +357,7 @@ systemd_unit_by_name(const gchar * arg_name, svc_action_t *op) GList * systemd_unit_listall(void) { - int lpc = 0; + int nfiles = 0; GList *units = NULL; DBusMessageIter args; DBusMessageIter unit; @@ -369,23 +369,23 @@ systemd_unit_listall(void) } /* - " <method name=\"ListUnits\">\n" \ - " <arg name=\"units\" type=\"a(ssssssouso)\" direction=\"out\"/>\n" \ + " <method name=\"ListUnitFiles\">\n" \ + " <arg name=\"files\" type=\"a(ss)\" direction=\"out\"/>\n" \ " </method>\n" \ */ - reply = systemd_call_simple_method("ListUnits"); + reply = systemd_call_simple_method("ListUnitFiles"); if (reply == NULL) { return NULL; } if (!dbus_message_iter_init(reply, &args)) { - crm_err("Could not list systemd units: systemd reply has no arguments"); + crm_err("Could not list systemd unit files: systemd reply has no arguments"); dbus_message_unref(reply); return NULL; } if (!pcmk_dbus_type_check(reply, &args, DBUS_TYPE_ARRAY, __FUNCTION__, __LINE__)) { - crm_err("Could not list systemd units: systemd reply has invalid arguments"); + crm_err("Could not list systemd unit files: systemd reply has invalid arguments"); dbus_message_unref(reply); return NULL; } @@ -404,21 +404,36 @@ systemd_unit_listall(void) } dbus_message_iter_get_basic(&elem, &value); - crm_trace("DBus ListUnits listed: %s", value.str); + crm_trace("DBus ListUnitFiles listed: %s", value.str); if(value.str) { const char *match = systemd_unit_extension(value.str); if (match) { - char *unit_name; + char *unit_name = NULL; + char *basename = NULL; - if (!strcmp(match, ".service")) { - /* service is the "default" unit type, so strip it */ - unit_name = strndup(value.str, match - value.str); + // ListUnitFiles returns full path names + basename = strrchr(value.str, '/'); + if (basename) { + basename = basename + 1; } else { - unit_name = strdup(value.str); + basename = value.str; + } + + if (!strcmp(match, ".service")) { + // Service is the "default" unit type, so strip it + unit_name = strndup(basename, match - basename); + + } else if (!strcmp(match, ".mount") + || !strcmp(match, ".socket")) { + // Only list things we can start and stop + unit_name = strdup(basename); + } + if (unit_name) { + nfiles++; + // @TODO sort alphabetically + units = g_list_prepend(units, unit_name); } - lpc++; - units = g_list_append(units, unit_name); } } dbus_message_iter_next (&unit); @@ -426,7 +441,7 @@ systemd_unit_listall(void) dbus_message_unref(reply); - crm_trace("Found %d systemd services", lpc); + crm_trace("Found %d manageable systemd unit files", nfiles); return units; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor