systemctl: show SELinuxContext=, AppArmorProfile= and SmackProcessLabel=
authorINSUN PYO <insun.pyo@samsung.com>
Thu, 17 Jan 2019 06:53:13 +0000 (15:53 +0900)
committerLennart Poettering <lennart@poettering.net>
Mon, 4 Mar 2019 14:27:30 +0000 (15:27 +0100)
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"]

src/systemctl/systemctl.c

index 57e3111..fc21d31 100644 (file)
@@ -4752,6 +4752,20 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
                         }
 
                         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;
                 }
 
                 break;