summaryrefslogtreecommitdiff
path: root/src/rc/rc-applets.c
diff options
context:
space:
mode:
authorWilliam Hubbs <williamh@gentoo.org>2011-02-15 08:50:44 -0600
committerWilliam Hubbs <williamh@gentoo.org>2011-02-16 09:00:38 -0600
commitb512d0db98b73bfe2bbeac84c19db039dc256c4f (patch)
tree087d4fe41c4f65e6bff8ac730d9a4516ceb1a1ed /src/rc/rc-applets.c
parent73d1a8698e101b1dcf589b27b35ac9b09ea6d02c (diff)
downloadopenrc-b512d0db98b73bfe2bbeac84c19db039dc256c4f.tar.gz
openrc-b512d0db98b73bfe2bbeac84c19db039dc256c4f.tar.bz2
openrc-b512d0db98b73bfe2bbeac84c19db039dc256c4f.tar.xz
new implementation of applet option
This reworks the implementation of the --applet option so that it is processed in run_applets() and does not require two calls to the getopts_long() function. It is based on code by Robin Johnson and Chris Richards. X-Gentoo-Bug: 351712 X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=351712
Diffstat (limited to 'src/rc/rc-applets.c')
-rw-r--r--src/rc/rc-applets.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index 8381113..6068cb6 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -429,6 +429,17 @@ run_applets(int argc, char **argv)
char *p;
pid_t pid = 0;
+ /* Bug 351712: We need an extra way to explicitly select an applet OTHER
+ * than trusting argv[0], as argv[0] is not going to be the applet value if
+ * we are doing SELinux context switching. For this, we allow calls such as
+ * 'rc --applet APPLET', and shift ALL of argv down by two array items. */
+ if (strcmp(applet, "rc") == 0 && argc >= 3 &&
+ (strcmp(argv[1],"--applet") == 0 || strcmp(argv[1], "-a") == 0)) {
+ applet = argv[2];
+ argv += 2;
+ argc -= 2;
+ }
+
/* These are designed to be applications in their own right */
if (strcmp(applet, "fstabinfo") == 0)
exit(fstabinfo(argc, argv));