]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
tor: Add torctrl binary.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 31 Jul 2013 10:52:26 +0000 (12:52 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 31 Jul 2013 10:52:26 +0000 (12:52 +0200)
src/initscripts/init.d/tor
src/misc-progs/Makefile
src/misc-progs/torctrl.c [new file with mode: 0644]

index 6ae03130ef1559c6f222780b4fcb4a449a1d7750..82dab68bd9276487ca084f863973a1be12de8a86 100644 (file)
@@ -35,12 +35,21 @@ case "${1}" in
                ${0} start
                ;;
 
                ${0} start
                ;;
 
+       reload-or-restart)
+               # Reload the process if it is already running. Otherwise, restart.
+               if pidofproc -s /usr/bin/tor; then
+                       $0 reload
+               else
+                       $0 restart
+               fi
+               ;;
+
        status)
                statusproc /usr/bin/tor
                ;;
 
        *)
        status)
                statusproc /usr/bin/tor
                ;;
 
        *)
-               echo "Usage: ${0} {start|stop|reload|restart|status}"
+               echo "Usage: ${0} {start|stop|reload|restart|reload-or-restart|status}"
                exit 1
                ;;
 esac
                exit 1
                ;;
 esac
index 2ec7878b526b785eff7ab2a674596011bb486bb2..df5a3703846d548976aed0707f8c8ad328e9d6b1 100644 (file)
@@ -33,7 +33,7 @@ SUID_PROGS = setdmzholes setportfw setxtaccess \
        redctrl syslogdctrl extrahdctrl sambactrl upnpctrl tripwirectrl \
        smartctrl clamavctrl addonctrl pakfire mpfirectrl wlanapctrl \
        setaliases urlfilterctrl updxlratorctrl fireinfoctrl rebuildroutes \
        redctrl syslogdctrl extrahdctrl sambactrl upnpctrl tripwirectrl \
        smartctrl clamavctrl addonctrl pakfire mpfirectrl wlanapctrl \
        setaliases urlfilterctrl updxlratorctrl fireinfoctrl rebuildroutes \
-       getconntracktable wirelessclient dnsmasqctrl
+       getconntracktable wirelessclient dnsmasqctrl torctrl
 SUID_UPDX = updxsetperms
 
 install : all
 SUID_UPDX = updxsetperms
 
 install : all
@@ -164,3 +164,6 @@ wirelessclient: wirelessclient.c setuid.o ../install+setup/libsmooth/varval.o
 
 dnsmasqctrl: dnsmasqctrl.c setuid.o ../install+setup/libsmooth/varval.o
        $(COMPILE) -I../install+setup/libsmooth/ dnsmasqctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@
 
 dnsmasqctrl: dnsmasqctrl.c setuid.o ../install+setup/libsmooth/varval.o
        $(COMPILE) -I../install+setup/libsmooth/ dnsmasqctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@
+
+torctrl: toctrl.c setuid.o ../install+setup/libsmooth/varval.o
+       $(COMPILE) -I../install+setup/libsmooth/ torctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@
diff --git a/src/misc-progs/torctrl.c b/src/misc-progs/torctrl.c
new file mode 100644 (file)
index 0000000..686a8da
--- /dev/null
@@ -0,0 +1,32 @@
+/* This file is part of the IPFire Firewall.
+ *
+ * This program is distributed under the terms of the GNU General Public
+ * Licence.  See the file COPYING for details.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include "setuid.h"
+
+int main(int argc, char *argv[]) {
+       if (!(initsetuid()))
+               exit(1);
+
+       if (argc < 2) {
+               fprintf(stderr, "\nNo argument given.\n\ntorctrl (restart)\n\n");
+               exit(1);
+       }
+
+       if (strcmp(argv[1], "restart") == 0) {
+               safe_system("/etc/rc.d/init.d/tor reload-or-restart");
+       } else {
+               fprintf(stderr, "\nBad argument given.\n\ntorctrl (restart)\n\n");
+               exit(1);
+       }
+
+       return 0;
+}