summaryrefslogtreecommitdiffstats
path: root/toolbox/id.c
diff options
context:
space:
mode:
authorStephen Smalley <sds@tycho.nsa.gov>2012-01-13 08:53:56 -0500
committerStephen Smalley <sds@tycho.nsa.gov>2012-02-03 11:11:15 -0500
commit8290d1083ec7eee3f32265012f5d6be2774c4afc (patch)
tree6d7e239b2a5b3d4a8faf8c3f404f8d9b3270f61d /toolbox/id.c
parent0458d373261d89979529853fa63cdd998b12e04a (diff)
downloadsystem_core-8290d1083ec7eee3f32265012f5d6be2774c4afc.zip
system_core-8290d1083ec7eee3f32265012f5d6be2774c4afc.tar.gz
system_core-8290d1083ec7eee3f32265012f5d6be2774c4afc.tar.bz2
Extend toolbox with SE Android support.
Add -Z option to ls and ps for displaying security contexts. Modify id to display security context. Add new SELinux commands: chcon, getenforce, getsebool, load_policy, restorecon, runcon, setenforce, setsebool. Change-Id: Ia20941be4a6cd706fe392fed6e38a37d880ec5f1
Diffstat (limited to 'toolbox/id.c')
-rw-r--r--toolbox/id.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/toolbox/id.c b/toolbox/id.c
index bb03cad..bc79288 100644
--- a/toolbox/id.c
+++ b/toolbox/id.c
@@ -5,6 +5,10 @@
#include <pwd.h>
#include <grp.h>
+#ifdef HAVE_SELINUX
+#include <selinux/selinux.h>
+#endif
+
static void print_uid(uid_t uid)
{
struct passwd *pw = getpwuid(uid);
@@ -30,6 +34,9 @@ int id_main(int argc, char **argv)
{
gid_t list[64];
int n, max;
+#ifdef HAVE_SELINUX
+ char *secctx;
+#endif
max = getgroups(64, list);
if (max < 0) max = 0;
@@ -46,6 +53,12 @@ int id_main(int argc, char **argv)
print_gid(list[n]);
}
}
+#ifdef HAVE_SELINUX
+ if (getcon(&secctx) == 0) {
+ printf(" context=%s", secctx);
+ free(secctx);
+ }
+#endif
printf("\n");
return 0;
}