systemctl: show SELinuxContext=, AppArmorProfile= and SmackProcessLabel=

Run: systemctl show -a dbus.service | grep -E "SELinuxContext|AppArmorProfile|SmackProcessLabel"

Before patch:
  SELinuxContext=[unprintable]
  AppArmorProfile=[unprintable]
  SmackProcessLabel=[unprintable]

After patch:
  SELinuxContext=[""|"value of context"]
  AppArmorProfile=[""|"value of context"]
  SmackProcessLabel=[""|"value of context"]
This commit is contained in:
INSUN PYO 2019-01-17 15:53:13 +09:00 committed by Lennart Poettering
parent 0d427d377a
commit c7bb2fec78

View file

@ -4751,6 +4751,20 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
fputc('\n', stdout);
}
return 1;
} else if (STR_IN_SET(name, "SELinuxContext", "AppArmorProfile", "SmackProcessLabel")) {
int ignore;
const char *s;
r = sd_bus_message_read(m, "(bs)", &ignore, &s);
if (r < 0)
return bus_log_parse_error(r);
if (!isempty(s))
bus_print_property_value(name, expected_value, value, "%s%s", ignore ? "-" : "", s);
else if (all)
bus_print_property_value(name, expected_value, value, "%s", "");
return 1;
}