From 1a8999b3d61d23094485c9d43385be35676d0a26 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sun, 26 Apr 2015 16:48:45 +0200 Subject: [PATCH] ddnsctrl: New binary. This helper binary is used to grand the ddns update client super user rights, when launched out of the webinterface. --- config/rootfiles/common/misc-progs | 1 + src/misc-progs/Makefile | 2 +- src/misc-progs/ddnsctrl.c | 37 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/misc-progs/ddnsctrl.c diff --git a/config/rootfiles/common/misc-progs b/config/rootfiles/common/misc-progs index f33d08c61a..349aac76cb 100644 --- a/config/rootfiles/common/misc-progs +++ b/config/rootfiles/common/misc-progs @@ -3,6 +3,7 @@ usr/local/bin/addonctrl usr/local/bin/backupctrl #usr/local/bin/clamavctrl usr/local/bin/collectdctrl +usr/local/bin/ddnsctrl usr/local/bin/dhcpctrl usr/local/bin/dnsmasqctrl usr/local/bin/extrahdctrl diff --git a/src/misc-progs/Makefile b/src/misc-progs/Makefile index 43e6a9081e..e4bf049728 100644 --- a/src/misc-progs/Makefile +++ b/src/misc-progs/Makefile @@ -31,7 +31,7 @@ SUID_PROGS = squidctrl sshctrl ipfirereboot \ redctrl syslogdctrl extrahdctrl sambactrl upnpctrl tripwirectrl \ smartctrl clamavctrl addonctrl pakfire mpfirectrl wlanapctrl \ setaliases urlfilterctrl updxlratorctrl fireinfoctrl rebuildroutes \ - getconntracktable wirelessclient dnsmasqctrl torctrl + getconntracktable wirelessclient dnsmasqctrl torctrl ddnsctrl SUID_UPDX = updxsetperms OBJS = $(patsubst %,%.o,$(PROGS) $(SUID_PROGS)) diff --git a/src/misc-progs/ddnsctrl.c b/src/misc-progs/ddnsctrl.c new file mode 100644 index 0000000000..7c41033222 --- /dev/null +++ b/src/misc-progs/ddnsctrl.c @@ -0,0 +1,37 @@ +/* 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 +#include + +#include "setuid.h" + +const char *conffile = "/var/ipfire/ddns/ddns.conf"; + +int main(int argc, char *argv[]) { + char cmd[STRING_SIZE]; + + if (!(initsetuid())) + exit(1); + + if (argc < 2) { + fprintf(stderr, "\nNo argument given.\n\nddnsctrl (update-all)\n\n"); + exit(1); + } + + if (strcmp(argv[1], "update-all") == 0) { + snprintf(cmd, sizeof(cmd), "/usr/bin/ddns --config %s update-all >/dev/null 2>&1", conffile); + safe_system(cmd); + } else { + fprintf(stderr, "\nBad argument given.\n\nddnsctrl (update-all)\n\n"); + exit(1); + } + + return 0; +} -- 2.39.5