aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-07-25 17:39:46 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-07-25 17:39:46 +0000
commit972fa099e6b830f7888adf5882ebad6530369b0a (patch)
tree18e8b5609d707e27be87ecfb7ff15dea482cb689
parent7ce7594fa31c64f49f9e6730c605879e0f3e7ac8 (diff)
downloadbusybox-w32-972fa099e6b830f7888adf5882ebad6530369b0a.tar.gz
busybox-w32-972fa099e6b830f7888adf5882ebad6530369b0a.tar.bz2
busybox-w32-972fa099e6b830f7888adf5882ebad6530369b0a.zip
setfiles: small code size reduction (Yuichi Nakamura <ynakam@hitachisoft.jp>)
-rw-r--r--selinux/setfiles.c67
1 files changed, 9 insertions, 58 deletions
diff --git a/selinux/setfiles.c b/selinux/setfiles.c
index d9fb50725..352c0f224 100644
--- a/selinux/setfiles.c
+++ b/selinux/setfiles.c
@@ -25,14 +25,6 @@ struct globals {
25 int excludeCtr; 25 int excludeCtr;
26 int errors; 26 int errors;
27 int verbose; /* getopt32 uses it, has to be int */ 27 int verbose; /* getopt32 uses it, has to be int */
28 //smallint force;
29 //smallint progress;
30 //smallint debug;
31 //smallint dry_run;
32 //smallint quiet;
33 //smallint ignore_enoent;
34 //smallint take_log;
35 //smallint warn_no_match;
36 smallint recurse; /* Recursive descent */ 28 smallint recurse; /* Recursive descent */
37 smallint follow_mounts; 29 smallint follow_mounts;
38 /* Behavior flags determined based on setfiles vs. restorecon */ 30 /* Behavior flags determined based on setfiles vs. restorecon */
@@ -60,14 +52,6 @@ void BUG_setfiles_globals_too_big(void);
60#define excludeCtr (G.excludeCtr ) 52#define excludeCtr (G.excludeCtr )
61#define errors (G.errors ) 53#define errors (G.errors )
62#define verbose (G.verbose ) 54#define verbose (G.verbose )
63//#define force (G.force )
64//#define progress (G.progress )
65//#define debug (G.debug )
66//#define dry_run (G.dry_run )
67//#define quiet (G.quiet )
68//#define ignore_enoent (G.ignore_enoent )
69//#define take_log (G.take_log )
70//#define warn_no_match (G.warn_no_match )
71#define recurse (G.recurse ) 55#define recurse (G.recurse )
72#define follow_mounts (G.follow_mounts ) 56#define follow_mounts (G.follow_mounts )
73#define expand_realpath (G.expand_realpath ) 57#define expand_realpath (G.expand_realpath )
@@ -128,27 +112,26 @@ static void inc_err(void)
128 } 112 }
129} 113}
130 114
131static bool add_exclude(const char *const directory) 115static void add_exclude(const char *const directory)
132{ 116{
133 struct stat sb; 117 struct stat sb;
134 size_t len; 118 size_t len;
135 119
136 if (directory == NULL || directory[0] != '/') { 120 if (directory == NULL || directory[0] != '/') {
137 bb_error_msg("full path required for exclude: %s", directory); 121 bb_error_msg_and_die("full path required for exclude: %s", directory);
138 return 1; 122
139 } 123 }
140 if (lstat(directory, &sb)) { 124 if (lstat(directory, &sb)) {
141 bb_error_msg("directory \"%s\" not found, ignoring", directory); 125 bb_error_msg("directory \"%s\" not found, ignoring", directory);
142 return 0; 126 return;
143 } 127 }
144 if ((sb.st_mode & S_IFDIR) == 0) { 128 if ((sb.st_mode & S_IFDIR) == 0) {
145 bb_error_msg("\"%s\" is not a directory: mode %o, ignoring", 129 bb_error_msg("\"%s\" is not a directory: mode %o, ignoring",
146 directory, sb.st_mode); 130 directory, sb.st_mode);
147 return 0; 131 return;
148 } 132 }
149 if (excludeCtr == MAX_EXCLUDES) { 133 if (excludeCtr == MAX_EXCLUDES) {
150 bb_error_msg("maximum excludes %d exceeded", MAX_EXCLUDES); 134 bb_error_msg_and_die("maximum excludes %d exceeded", MAX_EXCLUDES);
151 return 1;
152 } 135 }
153 136
154 len = strlen(directory); 137 len = strlen(directory);
@@ -157,8 +140,6 @@ static bool add_exclude(const char *const directory)
157 } 140 }
158 excludeArray[excludeCtr].directory = xstrndup(directory, len); 141 excludeArray[excludeCtr].directory = xstrndup(directory, len);
159 excludeArray[excludeCtr++].size = len; 142 excludeArray[excludeCtr++].size = len;
160
161 return 0;
162} 143}
163 144
164static bool exclude(const char *file) 145static bool exclude(const char *file)
@@ -593,39 +574,15 @@ int setfiles_main(int argc, char **argv)
593 } 574 }
594#endif 575#endif
595 576
596 //if (flags & OPT_d) { 577 while (exclude_dir)
597 // debug = 1; 578 add_exclude(llist_pop(&exclude_dir));
598 //} 579
599 if (flags & OPT_e) {
600 if (exclude_dir == NULL) {
601 bb_show_usage();
602 }
603 while (exclude_dir) {
604 if (add_exclude(llist_pop(&exclude_dir)))
605 exit(1);
606 }
607 }
608 //if (flags & OPT_i) {
609 // ignore_enoent = 1;
610 //}
611 //if (flags & OPT_l) {
612 // take_log = 1;
613 //}
614 //if (flags & OPT_F) {
615 // force = 1;
616 //}
617 //if (flags & OPT_n) {
618 // dry_run = 1;
619 //}
620 if (flags & OPT_o) { 580 if (flags & OPT_o) {
621 outfile = stdout; 581 outfile = stdout;
622 if (NOT_LONE_CHAR(out_filename, '-')) { 582 if (NOT_LONE_CHAR(out_filename, '-')) {
623 outfile = xfopen(out_filename, "w"); 583 outfile = xfopen(out_filename, "w");
624 } 584 }
625 } 585 }
626 //if (flags & OPT_q) {
627 // quiet = 1;
628 //}
629 if (applet_name[0] == 'r') { /* restorecon */ 586 if (applet_name[0] == 'r') { /* restorecon */
630 if (flags & (OPT_r | OPT_R)) 587 if (flags & (OPT_r | OPT_R))
631 recurse = 1; 588 recurse = 1;
@@ -638,12 +595,6 @@ int setfiles_main(int argc, char **argv)
638 input_filename = "-"; 595 input_filename = "-";
639 add_assoc = 0; 596 add_assoc = 0;
640 } 597 }
641 //if (flags & OPT_p) {
642 // progress = 1;
643 //}
644 //if (flags & OPT_W) {
645 // warn_no_match = 1;
646 //}
647 598
648 if (applet_name[0] == 's') { /* setfiles */ 599 if (applet_name[0] == 's') { /* setfiles */
649 /* Use our own invalid context checking function so that 600 /* Use our own invalid context checking function so that