]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
misc-progs: Add lldpdctrl
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Nov 2025 16:46:52 +0000 (16:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 7 Nov 2025 11:22:05 +0000 (11:22 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/rootfiles/common/misc-progs
src/misc-progs/Makefile
src/misc-progs/lldpdctrl.c [new file with mode: 0644]

index b92a1e32af5a195f03f48a22eb20b3db003a2e15..2c846878add58b20044f8c15fc43eae74dbe3c44 100644 (file)
@@ -13,6 +13,7 @@ usr/local/bin/getipstat
 #usr/local/bin/iowrap
 usr/local/bin/ipfirereboot
 usr/local/bin/ipsecctrl
+usr/local/bin/lldpdctrl
 usr/local/bin/logwatch
 #usr/local/bin/mpfirectrl
 usr/local/bin/openvpnctrl
index 9d380c158eb80add4070a20c4e42880c1bdfa6a4..4c994638a8ec437992e82cfed935dcf53d46b9ed 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 unboundctrl \
-       captivectrl wireguardctrl
+       captivectrl wireguardctrl lldpdctrl
 
 OBJS = $(patsubst %,%.o,$(PROGS) $(SUID_PROGS))
 
diff --git a/src/misc-progs/lldpdctrl.c b/src/misc-progs/lldpdctrl.c
new file mode 100644 (file)
index 0000000..8ae0d9d
--- /dev/null
@@ -0,0 +1,35 @@
+/* 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], "start") == 0)
+               return run("/etc/rc.d/init.d/lldpd", argv + 1);
+
+       else if (strcmp(argv[1], "stop") == 0)
+               return run("/etc/rc.d/init.d/lldpd", argv + 1);
+
+       else if (strcmp(argv[1], "restart") == 0)
+               return run("/etc/rc.d/init.d/lldpd", argv + 1);
+       fprintf(stderr, "Invalid command\n");
+       exit(1);
+}