X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=selinux%2Fsetfiles.c;h=c974c4a9d4e00aa344dbe0f9d61c423c98635cad;hb=51aa861843002e92b605be840460e7141d4d86a2;hp=f45e41b2b465144f364d47c2f0612c58c3843aa7;hpb=98a4c7cf3d799ab953cb77e8b34597c73e3e7335;p=oweals%2Fbusybox.git diff --git a/selinux/setfiles.c b/selinux/setfiles.c index f45e41b2b..c974c4a9d 100644 --- a/selinux/setfiles.c +++ b/selinux/setfiles.c @@ -4,6 +4,46 @@ Port to BusyBox (c) 2007 by Yuichi Nakamura */ +//usage:#define setfiles_trivial_usage +//usage: "[-dnpqsvW] [-e DIR]... [-o FILE] [-r alt_root_path]" +//usage: IF_FEATURE_SETFILES_CHECK_OPTION( +//usage: " [-c policyfile] spec_file" +//usage: ) +//usage: " pathname" +//usage:#define setfiles_full_usage "\n\n" +//usage: "Reset file contexts under pathname according to spec_file\n" +//usage: IF_FEATURE_SETFILES_CHECK_OPTION( +//usage: "\n -c FILE Check the validity of the contexts against the specified binary policy" +//usage: ) +//usage: "\n -d Show which specification matched each file" +//usage: "\n -l Log changes in file labels to syslog" +//usage: "\n -n Don't change any file labels" +//usage: "\n -q Suppress warnings" +//usage: "\n -r DIR Use an alternate root path" +//usage: "\n -e DIR Exclude DIR" +//usage: "\n -F Force reset of context to match file_context for customizable files" +//usage: "\n -o FILE Save list of files with incorrect context" +//usage: "\n -s Take a list of files from stdin (instead of command line)" +//usage: "\n -v Show changes in file labels, if type or role are changing" +//usage: "\n -vv Show changes in file labels, if type, role, or user are changing" +//usage: "\n -W Display warnings about entries that had no matching files" +//usage: +//usage:#define restorecon_trivial_usage +//usage: "[-iFnRv] [-e EXCLUDEDIR]... [-o FILE] [-f FILE]" +//usage:#define restorecon_full_usage "\n\n" +//usage: "Reset security contexts of files in pathname\n" +//usage: "\n -i Ignore files that don't exist" +//usage: "\n -f FILE File with list of files to process" +//usage: "\n -e DIR Directory to exclude" +//usage: "\n -R,-r Recurse" +//usage: "\n -n Don't change any file labels" +//usage: "\n -o FILE Save list of files with incorrect context" +//usage: "\n -v Verbose" +//usage: "\n -vv Show changed labels" +//usage: "\n -F Force reset of context to match file_context" +//usage: "\n for customizable files, or the user section," +//usage: "\n if it has changed" + #include "libbb.h" #if ENABLE_FEATURE_SETFILES_CHECK_OPTION #include @@ -118,7 +158,6 @@ static void add_exclude(const char *directory) if (directory == NULL || directory[0] != '/') { bb_error_msg_and_die("full path required for exclude: %s", directory); - } if (lstat(directory, &sb)) { bb_error_msg("directory \"%s\" not found, ignoring", directory); @@ -212,7 +251,6 @@ static int match(const char *name, struct stat *sb, char **con) name = path; if (excludeCtr > 0 && exclude(name)) goto err; - } else { char *p; p = realpath(name, path); @@ -459,10 +497,11 @@ static int process_one(char *name) if (S_ISDIR(sb.st_mode) && recurse) { if (recursive_action(name, - ACTION_RECURSE, - apply_spec, - apply_spec, - NULL, 0) != TRUE) { + ACTION_RECURSE, + apply_spec, + apply_spec, + NULL, 0) != TRUE + ) { bb_error_msg("error while labeling %s", name); goto err; } @@ -545,7 +584,7 @@ int setfiles_main(int argc UNUSED_PARAM, char **argv) flags = getopt32(argv, "de:f:ilnpqr:svo:FW" IF_FEATURE_SETFILES_CHECK_OPTION("c:"), &exclude_dir, &input_filename, &rootpath, &out_filename, - IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,) + IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,) &verbose); } argv += optind; @@ -561,8 +600,8 @@ int setfiles_main(int argc UNUSED_PARAM, char **argv) fclose(policystream); /* Only process the specified file_contexts file, not - any .homedirs or .local files, and do not perform - context translations. */ + * any .homedirs or .local files, and do not perform + * context translations. */ set_matchpathcon_flags(MATCHPATHCON_BASEONLY | MATCHPATHCON_NOTRANS | MATCHPATHCON_VALIDATE); @@ -592,8 +631,8 @@ int setfiles_main(int argc UNUSED_PARAM, char **argv) if (applet_name[0] == 's') { /* setfiles */ /* Use our own invalid context checking function so that - we can support either checking against the active policy or - checking against a binary policy file. */ + * we can support either checking against the active policy or + * checking against a binary policy file. */ set_matchpathcon_canoncon(&canoncon); if (!argv[0]) bb_show_usage();