[2/2] New binary: optionsfwctrl - needed for new firewall DNS/NTP options
Commit Message
Signed-off-by: Matthias Fischer <matthias.fischer@ipfire.org>
---
config/rootfiles/common/misc-progs | 1 +
src/misc-progs/Makefile | 2 +-
src/misc-progs/optionsfwctrl.c | 36 ++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
create mode 100644 src/misc-progs/optionsfwctrl.c
@@ -18,6 +18,7 @@ usr/local/bin/launch-ether-wake
usr/local/bin/logwatch
#usr/local/bin/mpfirectrl
usr/local/bin/openvpnctrl
+usr/local/bin/optionsfwctrl
usr/local/bin/pakfire
usr/local/bin/qosctrl
usr/local/bin/rebuildhosts
@@ -26,7 +26,7 @@ PROGS = iowrap
SUID_PROGS = squidctrl sshctrl ipfirereboot \
ipsecctrl timectrl dhcpctrl suricatactrl \
applejuicectrl rebuildhosts backupctrl collectdctrl \
- logwatch wioscan wiohelper openvpnctrl firewallctrl \
+ logwatch wioscan wiohelper openvpnctrl firewallctrl optionsfwctrl \
wirelessctrl getipstat qosctrl launch-ether-wake \
redctrl syslogdctrl extrahdctrl sambactrl upnpctrl \
smartctrl clamavctrl addonctrl pakfire mpfirectrl wlanapctrl \
new file mode 100644
@@ -0,0 +1,36 @@
+/* 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 <fcntl.h>
+#include "setuid.h"
+
+int main(int argc, char *argv[]) {
+
+ if (!(initsetuid()))
+ exit(1);
+
+ if (argc < 2) {
+ fprintf(stderr, "\nNo argument given.\n\noptionsfwctrl restart|reload\n\n");
+ exit(1);
+ }
+
+ if (strcmp(argv[1], "restart") == 0) {
+ safe_system("/etc/rc.d/init.d/firewall restart");
+ } else if (strcmp(argv[1], "reload") == 0) {
+ safe_system("/etc/rc.d/init.d/firewall reload");
+ } else {
+ fprintf(stderr, "\nBad argument given.\n\noptionsfwctrl restart|reload\n\n");
+ exit(1);
+ }
+
+ return 0;
+}