summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 9cb555ecb..7e247f945 100644
--- a/src/util.c
+++ b/src/util.c
@@ -26,6 +26,7 @@
#include "largefile_wrappers.h"
#include "number_set.h"
#include "print_utils.h"
+#include "secontext.h"
#include "static_assert.h"
#include "string_to_uint.h"
#include "xlat.h"
@@ -667,6 +668,13 @@ printed:
} else {
tprintf("%d", fd);
}
+#ifdef ENABLE_SECONTEXT
+ char *context;
+ if (!selinux_getfdcon(pid, fd, &context)) {
+ tprintf(" [%s]", context);
+ free(context);
+ }
+#endif
}
void
@@ -959,6 +967,14 @@ printpathn(struct tcb *const tcp, const kernel_ulong_t addr, unsigned int n)
else {
path[n++] = !nul_seen;
print_quoted_cstring(path, n);
+
+#ifdef ENABLE_SECONTEXT
+ char *context;
+ if (nul_seen && !selinux_getfilecon(tcp, path, &context)) {
+ tprintf(" [%s]", context);
+ free(context);
+ }
+#endif
}
return nul_seen;