core: add missing SELinux access checks when listing units
Add mac_selinux_unit_access_check_varlink() to the unit enumeration loop in vl_method_list_units(), silently skipping units the caller is not permitted to see, matching the D-Bus ListUnits behavior. Add mac_selinux_access_check_varlink() to vl_method_describe_manager(). Follow-up for472abf7becFollow-up for736349958e
This commit is contained in:
@@ -207,6 +207,10 @@ int vl_method_describe_manager(sd_varlink *link, sd_json_variant *parameters, sd
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = mac_selinux_access_check_varlink(link, "status");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_json_buildo(
|
||||
&v,
|
||||
SD_JSON_BUILD_PAIR_CALLBACK("context", manager_context_build_json, manager),
|
||||
|
||||
@@ -523,6 +523,10 @@ int vl_method_list_units(sd_varlink *link, sd_json_variant *parameters, sd_varli
|
||||
if (k != unit->id)
|
||||
continue;
|
||||
|
||||
r = mac_selinux_unit_access_check_varlink(unit, link, "status");
|
||||
if (r < 0)
|
||||
continue; /* silently skip units the caller is not allowed to see */
|
||||
|
||||
r = list_unit_one(link, unit);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user