112 |
} |
} |
113 |
} |
} |
114 |
|
|
115 |
static void add_exclude(const char *const directory) |
static void add_exclude(const char *directory) |
116 |
{ |
{ |
117 |
struct stat sb; |
struct stat sb; |
118 |
size_t len; |
size_t len; |
286 |
if (count == 0) |
if (count == 0) |
287 |
bb_putchar('\n'); |
bb_putchar('\n'); |
288 |
bb_putchar('*'); |
bb_putchar('*'); |
289 |
fflush(stdout); |
fflush_all(); |
290 |
} |
} |
291 |
} |
} |
292 |
|
|
347 |
* same. For "-vv", emit everything. */ |
* same. For "-vv", emit everything. */ |
348 |
if (verbose > 1 || !user_only_changed) { |
if (verbose > 1 || !user_only_changed) { |
349 |
bb_info_msg("%s: reset %s context %s->%s", |
bb_info_msg("%s: reset %s context %s->%s", |
350 |
applet_name, my_file, context ?: "", newcon); |
applet_name, my_file, context ? context : "", newcon); |
351 |
} |
} |
352 |
} |
} |
353 |
|
|
490 |
} |
} |
491 |
|
|
492 |
int setfiles_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
int setfiles_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
493 |
int setfiles_main(int argc, char **argv) |
int setfiles_main(int argc UNUSED_PARAM, char **argv) |
494 |
{ |
{ |
495 |
struct stat sb; |
struct stat sb; |
496 |
int rc, i = 0; |
int rc, i = 0; |
544 |
&exclude_dir, &input_filename, &out_filename, &verbose); |
&exclude_dir, &input_filename, &out_filename, &verbose); |
545 |
} else { /* setfiles */ |
} else { /* setfiles */ |
546 |
flags = getopt32(argv, "de:f:ilnpqr:svo:FW" |
flags = getopt32(argv, "de:f:ilnpqr:svo:FW" |
547 |
USE_FEATURE_SETFILES_CHECK_OPTION("c:"), |
IF_FEATURE_SETFILES_CHECK_OPTION("c:"), |
548 |
&exclude_dir, &input_filename, &rootpath, &out_filename, |
&exclude_dir, &input_filename, &rootpath, &out_filename, |
549 |
USE_FEATURE_SETFILES_CHECK_OPTION(&policyfile,) |
IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,) |
550 |
&verbose); |
&verbose); |
551 |
} |
} |
552 |
|
argv += optind; |
553 |
|
|
554 |
#if ENABLE_FEATURE_SETFILES_CHECK_OPTION |
#if ENABLE_FEATURE_SETFILES_CHECK_OPTION |
555 |
if ((applet_name[0] == 's') && (flags & OPT_c)) { |
if ((applet_name[0] == 's') && (flags & OPT_c)) { |
596 |
we can support either checking against the active policy or |
we can support either checking against the active policy or |
597 |
checking against a binary policy file. */ |
checking against a binary policy file. */ |
598 |
set_matchpathcon_canoncon(&canoncon); |
set_matchpathcon_canoncon(&canoncon); |
599 |
if (argc == 1) |
if (!argv[0]) |
600 |
bb_show_usage(); |
bb_show_usage(); |
601 |
if (stat(argv[optind], &sb) < 0) { |
xstat(argv[0], &sb); |
|
bb_simple_perror_msg_and_die(argv[optind]); |
|
|
} |
|
602 |
if (!S_ISREG(sb.st_mode)) { |
if (!S_ISREG(sb.st_mode)) { |
603 |
bb_error_msg_and_die("spec file %s is not a regular file", argv[optind]); |
bb_error_msg_and_die("spec file %s is not a regular file", argv[0]); |
604 |
} |
} |
605 |
/* Load the file contexts configuration and check it. */ |
/* Load the file contexts configuration and check it. */ |
606 |
rc = matchpathcon_init(argv[optind]); |
rc = matchpathcon_init(argv[0]); |
607 |
if (rc < 0) { |
if (rc < 0) { |
608 |
bb_simple_perror_msg_and_die(argv[optind]); |
bb_simple_perror_msg_and_die(argv[0]); |
609 |
} |
} |
|
|
|
|
optind++; |
|
|
|
|
610 |
if (nerr) |
if (nerr) |
611 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
612 |
|
argv++; |
613 |
} |
} |
614 |
|
|
615 |
if (input_filename) { |
if (input_filename) { |
625 |
if (ENABLE_FEATURE_CLEAN_UP) |
if (ENABLE_FEATURE_CLEAN_UP) |
626 |
fclose_if_not_stdin(f); |
fclose_if_not_stdin(f); |
627 |
} else { |
} else { |
628 |
if (optind >= argc) |
if (!argv[0]) |
629 |
bb_show_usage(); |
bb_show_usage(); |
630 |
for (i = optind; i < argc; i++) { |
for (i = 0; argv[i]; i++) { |
631 |
errors |= process_one(argv[i]); |
errors |= process_one(argv[i]); |
632 |
} |
} |
633 |
} |
} |