[PATCH 7/8] busybox -- SELinux option support for coreutils: ver3
Denis Vlasenko
vda.linux at googlemail.com
Sat Feb 24 07:01:12 PST 2007
On Friday 23 February 2007 09:48, Yuichi Nakamura wrote:
> [7/8] busybox-coreutils-07-chcon.v3.patch
> - chcon - change security context of file.
>
> Signed-off-by: KaiGai Kohei <kaigai at kaigai.gr.jp>
+#define OPT_QUIET (1<<3) /* 'f' */
+#define OPT_REFERENCE (1<<4) /* '\n' */
+#define OPT_USER (1<<5) /* 'u' */
...
+ {"quiet", 0, NULL, 'f'},
+ {"reference", 1, NULL, '\n' }, /* no short option */
+ {"user", 1, NULL, 'u' },
+ {"role", 1, NULL, 'r' },
+ {"type", 1, NULL, 't' },
+ {"range", 1, NULL, 'l' },
+ {"verbose", 0, NULL, 'v' },
+ {NULL, 0, NULL, 0 },
+};
+#endif
+
+int chcon_main(int argc, char *argv[]);
+int chcon_main(int argc, char *argv[])
+{
+ char *reference_file;
+ char **target_files;
+ int i, opts, errors = 0;
+
+#ifdef CONFIG_FEATURE_CHCON_LONG_OPTIONS
+ applet_long_options = chcon_options;
+#endif
+ opt_complementary = "-1" /* at least 1 param */
+ ":q--v:v--q"; /* 'verbose' and 'quiet' are exclusive */
+ opts = getopt32(argc, argv, "Rchf\n:u:r:t:l:v",
+ &reference_file, &user, &role, &type, &range);
+ if (opts & OPT_REFERENCE) {
+ if (opts & OPT_COMPONENT_SPECIFIED)
+ bb_error_msg_and_die("conflicting security context specifiers given");
Again see wget.c how to not pass '\n' to getopt32.
You can make OPT_REFERENCE and OPT_COMPONENT_SPECIFIED
exclusive by using suitable opt_complementary.
--
vda
More information about the busybox
mailing list