libselinux utilities applets - please test

KaiGai Kohei kaigai at kaigai.gr.jp
Wed Feb 7 15:28:07 UTC 2007


Denis, Thanks for merging the series of patches.

> Okay. I applied your patch to svn and did some changes.
> Please review & test - I can't run-test it at the moment
> (my kernel and userspace is not selinux-enabled).
> 
> Patch is attached for easy review. Thanks.
> --
> vda

I found some problems on building SELinux related applets.
The attached patch will fix them.

> diff -urpN busybox.5/selinux/matchpathcon.c busybox.6/selinux/matchpathcon.c
> --- busybox.5/selinux/matchpathcon.c	1970-01-01 01:00:00.000000000 +0100
> +++ busybox.6/selinux/matchpathcon.c	2007-02-06 20:23:46.000000000 +0100

- snip -

Compiler generated a warning message due to missing a prototype definition.
So, I put a prototype definition such as other applets.

> +int matchpathcon_main(int argc, char **argv)
> +{
> +	int error = 0;
> +	unsigned opts;
> +	char *fcontext, *prefix, *path;
> +
> +	opt_complementary = "-1:" /* at least one param reqd */
> +		"f--p:p--f"; /* mutually exclusive */
> +	opts = getopt32(argc, argv, "nNf:p:V", &fcontext, &prefix);
> +	argv += optind;
> +
> +	if (opts & OPT_NOT_TRANS) {
> +		set_matchpathcon_flags(NOTRANS);
                                       ^^^^^^^
It should be MATCHPATHCON_NOTRANS which is defined in selinux/selinux.h.
It's not a constant value to represent a command line option.

> +	}
> +	if (opts & OPT_FCONTEXT) {
> +		if (matchpathcon_init(fcontext))
> +			bb_perror_msg_and_die("error while processing %s", fcontext);
> +	}
> +	if (opts & OPT_PREFIX) {
> +		if (matchpathcon_init_prefix(NULL, prefix))
> +			bb_perror_msg_and_die("error while processing %s", prefix);
> +	}
> +
> +	while((path = *argv++) != NULL) {
> +		security_context_t con;
> +		int rc;
> +
> +		if (!(opts & OPT_VERIFY)) {
> +			error += print_matchpathcon(path, opt & OPT_NOT_PRINT);
It should be 'opts', not 'opt'.

> +			continue;
> +		}
> +
> +		if (selinux_file_context_verify(path, 0)) {
> +			printf("%s verified\n", path);
> +			continue;
> +		}
> +
> +		if (opts & OPT_NOT_TRANS)
> +			rc = lgetfilecon_raw(path, &con);
> +		else
> +			rc = lgetfilecon(path, &con);
> +
> +		if (rc >= 0) {
> +			printf("%s has context %s, should be ", path, con);
> +			error += print_matchpathcon(path, 1);
> +			freecon(con);
> +			continue;
> +		}
> +		printf("actual context unknown: %s, should be ", strerror(errno));
> +		error += print_matchpathcon(path, 1);
> +	}
> +	matchpathcon_fini();
> +	return error;
> +}

Thanks,
-- 
KaiGai Kohei <kaigai at kaigai.gr.jp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox-selinux-fix-build.patch
Type: text/x-patch
Size: 2191 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070208/1acdae87/attachment-0002.bin 


More information about the busybox mailing list