diff -drup openrc-0.7.0/work/openrc-0.7.0/src/rc/Makefile openrc-0.7.0-r1/work/openrc-0.7.0/src/rc/Makefile --- openrc-0.7.0/work/openrc-0.7.0/src/rc/Makefile 2011-01-12 20:14:17.000000000 -0600 +++ openrc-0.7.0-r1/work/openrc-0.7.0/src/rc/Makefile 2011-01-28 23:15:06.396999898 -0600 @@ -47,6 +47,21 @@ include ${MK}/${MKPAM}.mk ${SRCS}: version.h +#create symlinks to rc if not an SELINUX system, otherwise create a wrapper +#script to call rc with the proper name of the applet to execute. +#$1 is the path+name of the target to link to (usually 'rc' or '/sbin/rc') +#$2 contains the path+name of the link +define make-links + for x in $1; do \ + if test -n "${SELINUX}"; then \ + printf '#!/bin/sh\nexec $2 --applet %s "$$@"\n' >$3$$x; \ + chmod a+rx $3$$x; \ + else \ + ln -sf $2 $3$$x; \ + fi; \ + done; +endef + .PHONY: version.h.tmp version.h.tmp: echo "#define VERSION \"${VERSION}${GITVER}\"" >$@ @@ -61,13 +76,13 @@ install: all ${INSTALL} -d ${DESTDIR}${SBINDIR} ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${SBINDIR} ${INSTALL} -d ${DESTDIR}${BINDIR} - for x in ${BINLINKS}; do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${BINDIR}/$$x; done + $(call make-links,BINLINKS,${SBINDIR}/${PROG},${DESTDIR}${BINDIR}/) ${INSTALL} -d ${DESTDIR}${SBINDIR} - for x in ${SBINLINKS}; do ln -fs ${PROG} ${DESTDIR}${SBINDIR}/$$x; done + $(call make-links,SBINLINKS,${PROG},${DESTDIR}${SBINDIR}/) ${INSTALL} -d ${DESTDIR}${LINKDIR}/bin - for x in $(RC_BINLINKS); do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/bin/$$x; done + $(call make-links,RC_BINLINKS,${SBINDIR}/${PROG},${DESTDIR}${LINKDIR}/bin/) ${INSTALL} -d ${DESTDIR}${LINKDIR}/sbin - for x in ${RC_SBINLINKS}; do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/sbin/$$x; done + $(call make-links,RC_SBINLINKS,${SBINDIR/${PROG},${DESTDIR}${LINKDIR}/sbin/) if test "${MKPAM}" = pam; then \ ${INSTALL} -d ${DESTDIR}${PAMDIR}; \ ${INSTALL} -m ${PAMMODE} start-stop-daemon.pam ${DESTDIR}${PAMDIR}/start-stop-daemon; \ diff -drup openrc-0.7.0/work/openrc-0.7.0/src/rc/rc.c openrc-0.7.0-r1/work/openrc-0.7.0/src/rc/rc.c --- openrc-0.7.0/work/openrc-0.7.0/src/rc/rc.c 2011-01-12 20:14:17.000000000 -0600 +++ openrc-0.7.0-r1/work/openrc-0.7.0/src/rc/rc.c 2011-01-28 22:53:50.078999994 -0600 @@ -773,11 +773,12 @@ handle_bad_signal(int sig) #endif #include "_usage.h" -#define getoptstring "o:s:S" getoptstring_COMMON +#define getoptstring "o:s:S:a" getoptstring_COMMON static const struct option longopts[] = { { "override", 1, NULL, 'o' }, { "service", 1, NULL, 's' }, { "sys", 0, NULL, 'S' }, + { "applet", 1, NULL, 'a' }, longopts_COMMON }; static const char * const longopts_help[] = { @@ -785,6 +786,7 @@ static const char * const longopts_help[ "when leaving single user or boot runlevels", "runs the service specified with the rest\nof the arguments", "output the RC system type, if any", + "runs the applet specified by the next argument", longopts_help_COMMON }; #include "_usage.c" @@ -835,7 +837,24 @@ main(int argc, char **argv) } /* Run our built in applets. If we ran one, we don't return. */ - run_applets(argc, argv); + { + //make these local vars + int localargc = argc; + char **localargv = argv; + if(-1 != (opt = getopt_long(argc, argv, getoptstring, longopts, + (int *)0))) { + if(opt == 'a' && argc >= 3) { + //pass modified argc,argv, because the applets + //expect their arguments starting at argv[1] + localargv = argv + 2; + localargc = argc - 2; + applet = argv[2]; + } + } + + optind = 0; //reset getopt_long + run_applets(localargc, localargv); + } argc--; argv++; @@ -852,7 +871,7 @@ main(int argc, char **argv) argc++; argv--; while ((opt = getopt_long(argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *)0)) != -1) { switch (opt) { case 'o': @@ -890,8 +909,11 @@ main(int argc, char **argv) } exit(EXIT_SUCCESS); /* NOTREACHED */ - case_RC_COMMON_GETOPT - } + case 'a': + /* Do nothing, actual logic in run_applets, this + is a placeholder */ + case_RC_COMMON_GETOPT + } } newlevel = argv[optind++];