]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
misc-progs: dnsctrl: Tool to reload the DNS system
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 May 2026 15:37:10 +0000 (15:37 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 May 2026 15:37:10 +0000 (15:37 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/rootfiles/common/misc-progs
src/misc-progs/Makefile
src/misc-progs/dnsctrl.c [new file with mode: 0644]

index 996eba42a6aabee493600e2763a5a1e6422d6457..94d213e19a9f7587aeaf941a2e105fa11f7593bb 100644 (file)
@@ -5,6 +5,7 @@ usr/local/bin/captivectrl
 usr/local/bin/collectdctrl
 usr/local/bin/ddnsctrl
 usr/local/bin/dhcpctrl
+usr/local/bin/dnsctrl
 usr/local/bin/extrahdctrl
 usr/local/bin/fireinfoctrl
 usr/local/bin/firewallctrl
index fe4f28cf431b5429bca1a4948712dddba2bfe053..6229c8b17da14f1d9854b4c3f9d3ae422c5d8ac6 100644 (file)
@@ -32,7 +32,7 @@ SUID_PROGS = squidctrl sshctrl ipfirereboot \
        smartctrl clamavctrl addonctrl pakfire wlanapctrl \
        setaliases urlfilterctrl updxlratorctrl fireinfoctrl rebuildroutes \
        getconntracktable wirelessclient torctrl ddnsctrl \
-       captivectrl wireguardctrl lldpdctrl
+       captivectrl wireguardctrl lldpdctrl dnsctrl
 
 OBJS = $(patsubst %,%.o,$(PROGS) $(SUID_PROGS))
 
diff --git a/src/misc-progs/dnsctrl.c b/src/misc-progs/dnsctrl.c
new file mode 100644 (file)
index 0000000..8f49551
--- /dev/null
@@ -0,0 +1,34 @@
+/* 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 <stdio.h>
+#include <string.h>
+
+#include "setuid.h"
+
+int main(int argc, char** argv) {
+       // Become root
+       if (!initsetuid())
+               exit(1);
+
+       // Check if we have enough arguments
+       if (argc < 2) {
+               fprintf(stderr, "\nNot enough arguments.\n\n");
+               exit(1);
+       }
+
+       if (strcmp(argv[1], "reload") == 0) {
+               char* args[] = {
+                       "reload", NULL,
+               };
+
+               return run("/etc/rc.d/init.d/knot-resolver", args);
+       }
+       fprintf(stderr, "Invalid command\n");
+       exit(1);
+}