# HG changeset patch # User Rob Landley # Date 1423435118 21600 # Node ID 7f4413a90d45f51c2e7cb650b2523123025a690e # Parent d79dc782c2d977d666f0d1476b10e2b5b79560c0 Promote chcon to "other". diff -r d79dc782c2d9 -r 7f4413a90d45 toys/other/chcon.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toys/other/chcon.c Sun Feb 08 16:38:38 2015 -0600 @@ -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 -r d79dc782c2d9 -r 7f4413a90d45 toys/pending/chcon.c --- a/toys/pending/chcon.c Sun Feb 08 16:38:11 2015 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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); -}