From 452dcd5f7d5374411da86777de9fe94f5a88f709 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 8 Feb 2015 16:38:38 -0600 Subject: Promote chcon to "other". --- toys/other/chcon.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ toys/pending/chcon.c | 44 -------------------------------------------- 2 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 toys/other/chcon.c delete mode 100644 toys/pending/chcon.c diff --git a/toys/other/chcon.c b/toys/other/chcon.c new file mode 100644 index 00000000..a2bbb66c --- /dev/null +++ b/toys/other/chcon.c @@ -0,0 +1,44 @@ +/* chcon.c - Change file security context + * + * Copyright 2014 The Android Open Source Project + +USE_CHCON(NEWTOY(chcon, "<2hvR", TOYFLAG_USR|TOYFLAG_BIN)) + +config CHCON + bool "chcon" + depends on TOYBOX_SELINUX + default y + help + usage: chcon [-hRv] CONTEXT FILE... + + Change the SELinux security context of listed file[s]. + + -h change symlinks instead of what they point to. + -R recurse into subdirectories. + -v verbose output. +*/ + +#define FOR_chcon +#include "toys.h" + +int do_chcon(struct dirtree *try) +{ + char *path, *con = *toys.optargs; + + if (!dirtree_notdotdot(try)) return 0; + + path = dirtree_path(try, 0); + if (toys.optflags & FLAG_v) printf("chcon '%s' to %s\n", path, con); + if (-1 == ((toys.optflags & FLAG_h) ? lsetfilecon : setfilecon)(path, con)) + perror_msg("'%s' to %s", path, con); + free(path); + + return (toys.optflags & FLAG_R)*DIRTREE_RECURSE; +} + +void chcon_main(void) +{ + char **file; + + for (file = toys.optargs+1; *file; file++) dirtree_read(*file, do_chcon); +} diff --git a/toys/pending/chcon.c b/toys/pending/chcon.c deleted file mode 100644 index a2bbb66c..00000000 --- a/toys/pending/chcon.c +++ /dev/null @@ -1,44 +0,0 @@ -/* chcon.c - Change file security context - * - * Copyright 2014 The Android Open Source Project - -USE_CHCON(NEWTOY(chcon, "<2hvR", TOYFLAG_USR|TOYFLAG_BIN)) - -config CHCON - bool "chcon" - depends on TOYBOX_SELINUX - default y - help - usage: chcon [-hRv] CONTEXT FILE... - - Change the SELinux security context of listed file[s]. - - -h change symlinks instead of what they point to. - -R recurse into subdirectories. - -v verbose output. -*/ - -#define FOR_chcon -#include "toys.h" - -int do_chcon(struct dirtree *try) -{ - char *path, *con = *toys.optargs; - - if (!dirtree_notdotdot(try)) return 0; - - path = dirtree_path(try, 0); - if (toys.optflags & FLAG_v) printf("chcon '%s' to %s\n", path, con); - if (-1 == ((toys.optflags & FLAG_h) ? lsetfilecon : setfilecon)(path, con)) - perror_msg("'%s' to %s", path, con); - free(path); - - return (toys.optflags & FLAG_R)*DIRTREE_RECURSE; -} - -void chcon_main(void) -{ - char **file; - - for (file = toys.optargs+1; *file; file++) dirtree_read(*file, do_chcon); -} -- cgit v1.2.3