Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/selinux
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (14 years ago)
- Location:
- branches/2.2.9/mindi-busybox/selinux
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/selinux/Config.in
r1765 r2725 1 # DO NOT EDIT. This file is generated from Config.src 1 2 # 2 3 # For a description of the syntax of this configuration file, … … 4 5 # 5 6 6 menu "S elinux Utilities"7 menu "SELinux Utilities" 7 8 depends on SELINUX 9 10 8 11 9 12 config CHCON … … 17 20 bool "Enable long options" 18 21 default y 19 depends on CHCON && GETOPT_LONG22 depends on CHCON && LONG_OPTS 20 23 help 21 24 Support long options for the chcon applet. … … 68 71 bool "Enable long options" 69 72 default y 70 depends on RUNCON && GETOPT_LONG73 depends on RUNCON && LONG_OPTS 71 74 help 72 75 Support long options for the runcon applet. … … 105 108 the specified binary policy) for setfiles. Requires libsepol. 106 109 110 config SETSEBOOL 111 bool "setsebool" 112 default n 113 depends on SELINUX 114 help 115 Enable support for change boolean. 116 semanage and -P option is not supported yet. 117 118 config SESTATUS 119 bool "sestatus" 120 default n 121 depends on SELINUX 122 help 123 Displays the status of SELinux. 124 107 125 endmenu 108 -
branches/2.2.9/mindi-busybox/selinux/Kbuild
r1765 r2725 1 # DO NOT EDIT. This file is generated from Kbuild.src 1 2 # Makefile for busybox 2 3 # … … 4 5 # Copyright (C) 2007 by KaiGai Kohei <kaigai@kaigai.gr.jp> 5 6 # 6 # Licensed under the GPL v2, see the file LICENSE in this tarball.7 # Licensed under GPLv2, see file LICENSE in this source tree. 7 8 8 9 lib-y:= 10 11 9 12 lib-$(CONFIG_CHCON) += chcon.o 10 13 lib-$(CONFIG_GETENFORCE) += getenforce.o … … 17 20 lib-$(CONFIG_SETFILES) += setfiles.o 18 21 lib-$(CONFIG_RESTORECON) += setfiles.o 22 lib-$(CONFIG_SETSEBOOL) += setsebool.o 23 lib-$(CONFIG_SESTATUS) += sestatus.o -
branches/2.2.9/mindi-busybox/selinux/chcon.c
r1765 r2725 5 5 * 6 6 * Copyright (C) 2006 - 2007 KaiGai Kohei <kaigai@kaigai.gr.jp> 7 * 8 * Licensed under GPLv2, see file LICENSE in this source tree. 7 9 */ 8 10 #include <getopt.h> … … 29 31 static char *specified_context = NULL; 30 32 31 static int change_filedir_context(const char *fname, struct stat *stbuf, void *userData, int depth) 33 static int FAST_FUNC change_filedir_context( 34 const char *fname, 35 struct stat *stbuf UNUSED_PARAM, 36 void *userData UNUSED_PARAM, 37 int depth UNUSED_PARAM) 32 38 { 33 39 context_t context = NULL; … … 44 50 if (status < 0 && errno != ENODATA) { 45 51 if ((option_mask32 & OPT_QUIET) == 0) 46 bb_error_msg("can not obtain security context: %s", fname);52 bb_error_msg("can't obtain security context: %s", fname); 47 53 goto skip; 48 54 } 49 55 50 56 if (file_context == NULL && specified_context == NULL) { 51 bb_error_msg("can not apply partial context to unlabeled file %s", fname);57 bb_error_msg("can't apply partial context to unlabeled file %s", fname); 52 58 goto skip; 53 59 } … … 57 63 user, role, type, range); 58 64 if (!context) { 59 bb_error_msg("can not compute security context from %s", file_context);65 bb_error_msg("can't compute security context from %s", file_context); 60 66 goto skip; 61 67 } … … 70 76 context_string = context_str(context); 71 77 if (!context_string) { 72 bb_error_msg("can not obtain security context in text expression");78 bb_error_msg("can't obtain security context in text expression"); 73 79 goto skip; 74 80 } … … 85 91 printf(!fail 86 92 ? "context of %s changed to %s\n" 87 : " failed tochange context of %s to %s\n",93 : "can't change context of %s to %s\n", 88 94 fname, context_string); 89 95 } … … 91 97 rc = TRUE; 92 98 } else if ((option_mask32 & OPT_QUIET) == 0) { 93 bb_error_msg(" failed tochange context of %s to %s",99 bb_error_msg("can't change context of %s to %s", 94 100 fname, context_string); 95 101 } … … 121 127 #endif 122 128 123 int chcon_main(int argc, char **argv) ;124 int chcon_main(int argc , char **argv)129 int chcon_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 130 int chcon_main(int argc UNUSED_PARAM, char **argv) 125 131 { 126 132 char *reference_file; -
branches/2.2.9/mindi-busybox/selinux/getenforce.c
r1765 r2725 5 5 * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp> 6 6 * 7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 8 */ 8 9 9 10 #include "libbb.h" 10 11 11 int getenforce_main(int argc, char **argv) ;12 int getenforce_main(int argc , char **argv)12 int getenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 13 int getenforce_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 13 14 { 14 15 int rc; -
branches/2.2.9/mindi-busybox/selinux/getsebool.c
r1765 r2725 5 5 * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp> 6 6 * 7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 8 */ 8 9 9 10 #include "libbb.h" 10 11 11 int getsebool_main(int argc, char **argv) ;12 int getsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 12 13 int getsebool_main(int argc, char **argv) 13 14 { … … 25 26 rc = security_get_boolean_names(&names, &len); 26 27 if (rc) 27 bb_perror_msg_and_die("can not get boolean names");28 bb_perror_msg_and_die("can't get boolean names"); 28 29 29 30 if (!len) { … … 54 55 if (pending != active) 55 56 printf(" pending: %s", (pending ? "on" : "off")); 56 putchar('\n');57 bb_putchar('\n'); 57 58 } 58 59 -
branches/2.2.9/mindi-busybox/selinux/load_policy.c
r1765 r2725 1 1 /* 2 2 * load_policy 3 * This implementation is based on old load_policy to be small.4 3 * Author: Yuichi Nakamura <ynakam@hitachisoft.jp> 4 * 5 * Licensed under GPLv2, see file LICENSE in this source tree. 5 6 */ 6 7 #include "libbb.h" 7 8 8 int load_policy_main(int argc, char **argv) ;9 int load_policy_main(int argc , char **argv)9 int load_policy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 10 int load_policy_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 10 11 { 11 int fd; 12 struct stat st; 13 void *data; 14 if (argc != 2) { 12 int rc; 13 14 if (argv[1]) { 15 15 bb_show_usage(); 16 16 } 17 17 18 fd = xopen(argv[1], O_RDONLY); 19 if (fstat(fd, &st) < 0) { 20 bb_perror_msg_and_die("can't fstat"); 21 } 22 data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); 23 if (data == MAP_FAILED) { 24 bb_perror_msg_and_die("can't mmap"); 25 } 26 if (security_load_policy(data, st.st_size) < 0) { 18 rc = selinux_mkload_policy(1); 19 if (rc < 0) { 27 20 bb_perror_msg_and_die("can't load policy"); 28 21 } -
branches/2.2.9/mindi-busybox/selinux/matchpathcon.c
r1765 r2725 4 4 * Port to busybox: KaiGai Kohei <kaigai@kaigai.gr.jp> 5 5 * 6 * Licensed under GPLv2, see file LICENSE in this source tree. 6 7 */ 7 8 #include "libbb.h" … … 18 19 printf("%s\t%s\n", path, buf); 19 20 else 20 p rintf("%s\n",buf);21 puts(buf); 21 22 22 23 freecon(buf); … … 30 31 #define OPT_VERIFY (1<<4) /* -V */ 31 32 32 int matchpathcon_main(int argc, char **argv) ;33 int matchpathcon_main(int argc , char **argv)33 int matchpathcon_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 34 int matchpathcon_main(int argc UNUSED_PARAM, char **argv) 34 35 { 35 36 int error = 0; -
branches/2.2.9/mindi-busybox/selinux/runcon.c
r1765 r2725 26 26 * Port to busybox: KaiGai Kohei <kaigai@kaigai.gr.jp> 27 27 * - based on coreutils-5.97 (in Fedora Core 6) 28 * 29 * Licensed under GPLv2, see file LICENSE in this source tree. 28 30 */ 29 31 #include <getopt.h> … … 40 42 41 43 if (getcon(&cur_context)) 42 bb_error_msg_and_die("can not get current context");44 bb_error_msg_and_die("can't get current context"); 43 45 44 46 if (compute_trans) { … … 46 48 47 49 if (getfilecon(command, &file_context) < 0) 48 bb_error_msg_and_die("can not retrieve attributes of '%s'",50 bb_error_msg_and_die("can't retrieve attributes of '%s'", 49 51 command); 50 52 if (security_compute_create(cur_context, file_context, … … 58 60 bb_error_msg_and_die("'%s' is not a valid context", cur_context); 59 61 if (user && context_user_set(con, user)) 60 bb_error_msg_and_die(" failed toset new user '%s'", user);62 bb_error_msg_and_die("can't set new user '%s'", user); 61 63 if (type && context_type_set(con, type)) 62 bb_error_msg_and_die(" failed toset new type '%s'", type);64 bb_error_msg_and_die("can't set new type '%s'", type); 63 65 if (range && context_range_set(con, range)) 64 bb_error_msg_and_die(" failed toset new range '%s'", range);66 bb_error_msg_and_die("can't set new range '%s'", range); 65 67 if (role && context_role_set(con, role)) 66 bb_error_msg_and_die(" failed toset new role '%s'", role);68 bb_error_msg_and_die("can't set new role '%s'", role); 67 69 68 70 return con; … … 88 90 #define OPTS_CONTEXT_COMPONENT (OPTS_ROLE | OPTS_TYPE | OPTS_USER | OPTS_RANGE) 89 91 90 int runcon_main(int argc, char **argv) ;91 int runcon_main(int argc , char **argv)92 int runcon_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 93 int runcon_main(int argc UNUSED_PARAM, char **argv) 92 94 { 93 95 char *role = NULL; … … 128 130 129 131 if (setexeccon(context_str(con))) 130 bb_error_msg_and_die("can not set up security context '%s'",132 bb_error_msg_and_die("can't set up security context '%s'", 131 133 context_str(con)); 132 134 133 135 execvp(argv[0], argv); 134 135 bb_perror_msg_and_die("cannot execute '%s'", argv[0]); 136 bb_perror_msg_and_die("can't execute '%s'", argv[0]); 136 137 } -
branches/2.2.9/mindi-busybox/selinux/selinuxenabled.c
r1765 r2725 5 5 * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp> 6 6 * 7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 8 */ 8 9 #include "libbb.h" 9 10 10 int selinuxenabled_main(int argc, char **argv) ;11 int selinuxenabled_main(int argc , char **argv)11 int selinuxenabled_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 12 int selinuxenabled_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 12 13 { 13 14 return !is_selinux_enabled(); -
branches/2.2.9/mindi-busybox/selinux/setenforce.c
r1765 r2725 5 5 * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp> 6 6 * 7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 8 */ 8 9 … … 20 21 }; 21 22 22 int setenforce_main(int argc, char **argv) ;23 int setenforce_main(int argc , char **argv)23 int setenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 24 int setenforce_main(int argc UNUSED_PARAM, char **argv) 24 25 { 25 26 int i, rc; 26 27 27 if ( argc != 2)28 if (!argv[1] || argv[2]) 28 29 bb_show_usage(); 29 30 -
branches/2.2.9/mindi-busybox/selinux/setfiles.c
r1765 r2725 36 36 int nerr; 37 37 struct edir excludeArray[MAX_EXCLUDES]; 38 }; 39 38 } FIX_ALIASING; 40 39 #define G (*(struct globals*)&bb_common_bufsiz1) 41 40 void BUG_setfiles_globals_too_big(void); … … 100 99 101 100 102 static void qprintf(const char *fmt , ...)101 static void qprintf(const char *fmt UNUSED_PARAM, ...) 103 102 { 104 103 /* quiet, do nothing */ … … 113 112 } 114 113 115 static void add_exclude(const char * constdirectory)114 static void add_exclude(const char *directory) 116 115 { 117 116 struct stat sb; … … 120 119 if (directory == NULL || directory[0] != '/') { 121 120 bb_error_msg_and_die("full path required for exclude: %s", directory); 122 123 121 } 124 122 if (lstat(directory, &sb)) { … … 285 283 count = (count % (80*0x400)); 286 284 if (count == 0) 287 fputc('\n', stdout);288 fputc('*', stdout);289 fflush (stdout);285 bb_putchar('\n'); 286 bb_putchar('*'); 287 fflush_all(); 290 288 } 291 289 } … … 348 346 if (verbose > 1 || !user_only_changed) { 349 347 bb_info_msg("%s: reset %s context %s->%s", 350 applet_name, my_file, context ? : "", newcon);348 applet_name, my_file, context ? context : "", newcon); 351 349 } 352 350 } … … 392 390 * the directory traversal. 393 391 */ 394 static int apply_spec(const char *file, 395 struct stat *sb, void *userData, int depth) 392 static int FAST_FUNC apply_spec( 393 const char *file, 394 struct stat *sb, 395 void *userData UNUSED_PARAM, 396 int depth UNUSED_PARAM) 396 397 { 397 398 if (!follow_mounts) { … … 487 488 } 488 489 489 int setfiles_main(int argc, char **argv) ;490 int setfiles_main(int argc , char **argv)490 int setfiles_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 491 int setfiles_main(int argc UNUSED_PARAM, char **argv) 491 492 { 492 493 struct stat sb; … … 542 543 } else { /* setfiles */ 543 544 flags = getopt32(argv, "de:f:ilnpqr:svo:FW" 544 USE_FEATURE_SETFILES_CHECK_OPTION("c:"),545 IF_FEATURE_SETFILES_CHECK_OPTION("c:"), 545 546 &exclude_dir, &input_filename, &rootpath, &out_filename, 546 USE_FEATURE_SETFILES_CHECK_OPTION(&policyfile,)547 IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,) 547 548 &verbose); 548 549 } 550 argv += optind; 549 551 550 552 #if ENABLE_FEATURE_SETFILES_CHECK_OPTION … … 552 554 FILE *policystream; 553 555 554 policystream = xfopen (policyfile, "r");556 policystream = xfopen_for_read(policyfile); 555 557 if (sepol_set_policydb_from_file(policystream) < 0) { 556 558 bb_error_msg_and_die("sepol_set_policydb_from_file on %s", policyfile); … … 573 575 outfile = stdout; 574 576 if (NOT_LONE_CHAR(out_filename, '-')) { 575 outfile = xfopen (out_filename, "w");577 outfile = xfopen_for_write(out_filename); 576 578 } 577 579 } … … 593 595 checking against a binary policy file. */ 594 596 set_matchpathcon_canoncon(&canoncon); 595 if ( argc == 1)597 if (!argv[0]) 596 598 bb_show_usage(); 597 if (stat(argv[optind], &sb) < 0) { 598 bb_perror_msg_and_die("%s", argv[optind]); 599 } 599 xstat(argv[0], &sb); 600 600 if (!S_ISREG(sb.st_mode)) { 601 bb_error_msg_and_die("spec file %s is not a regular file", argv[ optind]);601 bb_error_msg_and_die("spec file %s is not a regular file", argv[0]); 602 602 } 603 603 /* Load the file contexts configuration and check it. */ 604 rc = matchpathcon_init(argv[ optind]);604 rc = matchpathcon_init(argv[0]); 605 605 if (rc < 0) { 606 bb_perror_msg_and_die("%s", argv[optind]); 607 } 608 609 optind++; 610 606 bb_simple_perror_msg_and_die(argv[0]); 607 } 611 608 if (nerr) 612 exit(1); 609 exit(EXIT_FAILURE); 610 argv++; 613 611 } 614 612 … … 618 616 619 617 if (NOT_LONE_CHAR(input_filename, '-')) 620 f = xfopen (input_filename, "r");618 f = xfopen_for_read(input_filename); 621 619 while ((len = getline(&buf, &buf_len, f)) > 0) { 622 620 buf[len - 1] = '\0'; … … 626 624 fclose_if_not_stdin(f); 627 625 } else { 628 if ( optind >= argc)626 if (!argv[0]) 629 627 bb_show_usage(); 630 for (i = optind; i < argc; i++) {628 for (i = 0; argv[i]; i++) { 631 629 errors |= process_one(argv[i]); 632 630 }
Note:
See TracChangeset
for help on using the changeset viewer.