public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Michael Tremer <michael.tremer@ipfire.org>
To: development@lists.ipfire.org
Cc: Michael Tremer <michael.tremer@ipfire.org>
Subject: [PATCH 2/6] misc-progs: Add lldpdctrl
Date: Thu,  6 Nov 2025 16:46:52 +0000	[thread overview]
Message-ID: <20251106164907.1484873-3-michael.tremer@ipfire.org> (raw)
In-Reply-To: <20251106164907.1484873-1-michael.tremer@ipfire.org>

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 config/rootfiles/common/misc-progs |  1 +
 src/misc-progs/Makefile            |  2 +-
 src/misc-progs/lldpdctrl.c         | 35 ++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 src/misc-progs/lldpdctrl.c

diff --git a/config/rootfiles/common/misc-progs b/config/rootfiles/common/misc-progs
index b92a1e32a..2c846878a 100644
--- a/config/rootfiles/common/misc-progs
+++ b/config/rootfiles/common/misc-progs
@@ -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
diff --git a/src/misc-progs/Makefile b/src/misc-progs/Makefile
index 9d380c158..4c994638a 100644
--- a/src/misc-progs/Makefile
+++ b/src/misc-progs/Makefile
@@ -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
index 000000000..8ae0d9d97
--- /dev/null
+++ b/src/misc-progs/lldpdctrl.c
@@ -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);
+}
-- 
2.47.3



  parent reply	other threads:[~2025-11-06 16:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06 16:46 New Feature: LLDP Michael Tremer
2025-11-06 16:46 ` [PATCH 1/6] lldpd: New package Michael Tremer
2025-11-06 21:45   ` Adolf Belka
2025-11-07 14:10     ` Michael Tremer
2025-11-06 16:46 ` Michael Tremer [this message]
2025-11-06 16:46 ` [PATCH 3/6] cfgroot: Create /var/ipfire/lldp/settings Michael Tremer
2025-11-06 16:46 ` [PATCH 4/6] web-user-interface: Add lldp.cgi Michael Tremer
2025-11-06 16:46 ` [PATCH 5/6] web-user-interface: Add LLDP to the network menu Michael Tremer
2025-11-06 16:46 ` [PATCH 6/6] initscripts: Add an initscript for lldpd Michael Tremer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251106164907.1484873-3-michael.tremer@ipfire.org \
    --to=michael.tremer@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox