static int dump_profiles(void) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; _cleanup_strv_free_ char **l = NULL; char **i; int r; r = acquire_bus(&bus); if (r < 0) return r; r = sd_bus_get_property_strv( bus, "org.freedesktop.portable1", "/org/freedesktop/portable1", "org.freedesktop.portable1.Manager", "Profiles", &error, &l); if (r < 0) return log_error_errno(r, "Failed to acquire list of profiles: %s", bus_error_message(&error, r)); if (arg_legend) log_info("Available unit profiles:"); STRV_FOREACH(i, l) { fputs(*i, stdout); fputc('\n', stdout); }
static int bus_get_unit_property_strv(sd_bus *bus, const char *path, const char *property, char ***strv) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; int r; assert(bus); assert(path); assert(property); assert(strv); r = sd_bus_get_property_strv( bus, "org.freedesktop.systemd1", path, "org.freedesktop.systemd1.Unit", property, &error, strv); if (r < 0) { log_error("Failed to get unit property %s: %s", property, bus_error_message(&error, -r)); return r; } return 0; }