diff --git a/config/rootfiles/common/misc-progs b/config/rootfiles/common/misc-progs index e13faf825..286f5a51f 100644 --- a/config/rootfiles/common/misc-progs +++ b/config/rootfiles/common/misc-progs @@ -35,6 +35,7 @@ usr/local/bin/updxlratorctrl usr/local/bin/urlfilterctrl #usr/local/bin/wiohelper #usr/local/bin/wioscan +usr/local/bin/wireguardctrl usr/local/bin/wirelessclient usr/local/bin/wirelessctrl #usr/local/bin/wlanapctrl diff --git a/src/misc-progs/Makefile b/src/misc-progs/Makefile index bb7507dc6..fdd564db7 100644 --- a/src/misc-progs/Makefile +++ b/src/misc-progs/Makefile @@ -32,7 +32,7 @@ SUID_PROGS = squidctrl sshctrl ipfirereboot \ smartctrl clamavctrl addonctrl pakfire mpfirectrl wlanapctrl \ setaliases urlfilterctrl updxlratorctrl fireinfoctrl rebuildroutes \ getconntracktable wirelessclient torctrl ddnsctrl unboundctrl \ - captivectrl ddosctrl loxilbctrl keepalivedctrl haproxyctrl \ + captivectrl wireguardctrl ddosctrl loxilbctrl keepalivedctrl haproxyctrl \ xdpdnsctrl xdpsnictrl xdpgeoipctrl OBJS = $(patsubst %,%.o,$(PROGS) $(SUID_PROGS)) diff --git a/src/misc-progs/wireguardctrl.c b/src/misc-progs/wireguardctrl.c new file mode 100644 index 000000000..24580c2eb --- /dev/null +++ b/src/misc-progs/wireguardctrl.c @@ -0,0 +1,44 @@ +/* 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 +#include + +#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/wireguard", argv + 1); + + } else if (strcmp(argv[1], "stop") == 0) { + return run("/etc/rc.d/init.d/wireguard", argv + 1); + + } else if (strcmp(argv[1], "dump") == 0) { + char* args[] = { + "show", + (argc > 2) ? argv[2] : "wg0", + "dump", + NULL, + }; + + return run("/usr/bin/wg", args); + + } + + fprintf(stderr, "Invalid command\n"); + exit(1); +}