return (int) ELEMENTSOF(capability_names);
}
-int capability_set_to_string_alloc(uint64_t set, char **s) {
+int capability_set_to_string(uint64_t set, char **ret) {
_cleanup_free_ char *str = NULL;
size_t n = 0;
- assert(s);
+ assert(ret);
for (unsigned i = 0; i <= cap_last_cap(); i++)
if (set & (UINT64_C(1) << i)) {
str[n > 0 ? n - 1 : 0] = '\0'; /* truncate the last space, if it's there */
- *s = TAKE_PTR(str);
-
+ *ret = TAKE_PTR(str);
return 0;
}
int capability_from_name(const char *name);
int capability_list_length(void);
-int capability_set_to_string_alloc(uint64_t set, char **s);
+int capability_set_to_string(uint64_t set, char **ret);
int capability_set_from_string(const char *s, uint64_t *set);
static BUS_DEFINE_SET_TRANSIENT_PARSE(preserve_mode, ExecPreserveMode, exec_preserve_mode_from_string);
static BUS_DEFINE_SET_TRANSIENT_PARSE_PTR(personality, unsigned long, parse_personality);
static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(secure_bits, "i", int32_t, int, "%" PRIi32, secure_bits_to_string_alloc_with_check);
-static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(capability, "t", uint64_t, uint64_t, "%" PRIu64, capability_set_to_string_alloc);
+static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(capability, "t", uint64_t, uint64_t, "%" PRIu64, capability_set_to_string);
static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(namespace_flag, "t", uint64_t, unsigned long, "%" PRIu64, namespace_flags_to_string);
static BUS_DEFINE_SET_TRANSIENT_TO_STRING(mount_flags, "t", uint64_t, unsigned long, "%" PRIu64, mount_propagation_flag_to_string_with_check);
if (c->capability_bounding_set != CAP_ALL) {
_cleanup_free_ char *str = NULL;
- r = capability_set_to_string_alloc(c->capability_bounding_set, &str);
+ r = capability_set_to_string(c->capability_bounding_set, &str);
if (r >= 0)
fprintf(f, "%sCapabilityBoundingSet: %s\n", prefix, str);
}
if (c->capability_ambient_set != 0) {
_cleanup_free_ char *str = NULL;
- r = capability_set_to_string_alloc(c->capability_ambient_set, &str);
+ r = capability_set_to_string(c->capability_ambient_set, &str);
if (r >= 0)
fprintf(f, "%sAmbientCapabilities: %s\n", prefix, str);
}
} else if (STR_IN_SET(name, "CapabilityBoundingSet", "AmbientCapabilities")) {
_cleanup_free_ char *s = NULL;
- r = capability_set_to_string_alloc(u, &s);
+ r = capability_set_to_string(u, &s);
if (r < 0)
return r;
_cleanup_free_ char *t1 = NULL;
uint64_t c1, c_masked = c & all_capabilities();
- assert_se(capability_set_to_string_alloc(c, &t1) == 0);
+ assert_se(capability_set_to_string(c, &t1) == 0);
assert_se(streq(t1, t));
assert_se(capability_set_from_string(t1, &c1) == 0);