[PATCH 7/8] busybox -- SELinux option support for coreutils: ver3

Bernhard Fischer rep.dot.nop at gmail.com
Thu Mar 8 13:23:08 UTC 2007


On Tue, Feb 27, 2007 at 02:40:22AM +0900, KaiGai Kohei wrote:

>OK, fixed.
>
>* '\n' was replaced by '0xff'
>* Checks for exclusive options were added. chcon applet will will abort
>  if --reference and '-u','-r','-t','-l' are appeared concurrently,

Please move the change_dir_context() function around to remove the
forward decl.

+static context_t compute_context_from_mask(security_context_t context,
+       context_free (new_context);

surplus space
Smaller if you goto ret where
ret:
	return NULL;
}

+       context_string = context_str(context);
+       if (file_context == NULL || strcmp(context_string, file_context) != 0) {

Can context_str() return NULL?

+               int fail = 0;

superfluous set. Remove initialization to 0
+
+               if (opts & OPT_NODEREFERENCE) {
+                       fail = lsetfilecon (fname, context_string);
+               } else {
+                       fail = setfilecon (fname, context_string);
+               }
+               if ((opts & OPT_VERBOSE)
+                   || ((opts & OPT_CHANHES) && !fail)) {
+                       printf(!fail

bb_perror_msg() instead of printf?

+                              ? "context of %s changed to %s\n"
+                              : "failed to change context of %s to
%s\n",
+                              fname, context_string);
+               }

change_dir_context() sounds a bit overdone. Don't we have an opendir
wrapper with diagnostics? Perhaps this is a candidate for
recursive_action() 

Manually inlining compute_context_from_mask() smaller?

Smaller to resuse the global option_mask32 rather than using opts in
chcon_main() ?
+               ":?:f--v:v--f"      /* 'verbose' and 'quiet' are exclusive */
Sounds like there is the word mutual missing.




More information about the busybox mailing list