From 66d2c530cee0ea5a7ccb195cbf0a48e874bae842 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 18 Mar 2008 19:07:42 +0000 Subject: [PATCH] Port of the dyndns.com update client ndyndns. Signed off by: Conrad Hirano SVN-Revision: 10615 --- net/ndyndns/Makefile | 50 ++++++++ net/ndyndns/files/ndyndns.conf.sample | 4 + net/ndyndns/files/ndyndns.default | 3 + net/ndyndns/files/ndyndns.init | 18 +++ net/ndyndns/patches/ndyndns.patch | 163 ++++++++++++++++++++++++++ 5 files changed, 238 insertions(+) create mode 100644 net/ndyndns/Makefile create mode 100644 net/ndyndns/files/ndyndns.conf.sample create mode 100644 net/ndyndns/files/ndyndns.default create mode 100644 net/ndyndns/files/ndyndns.init create mode 100644 net/ndyndns/patches/ndyndns.patch diff --git a/net/ndyndns/Makefile b/net/ndyndns/Makefile new file mode 100644 index 0000000000..096e5d269c --- /dev/null +++ b/net/ndyndns/Makefile @@ -0,0 +1,50 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ndyndns +PKG_VERSION:=1.12 +PKG_RELEASE:=1 + +PKG_SOURCE:=ndyndns-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://ndyndns.googlecode.com/files +PKG_MD5SUM:=1ca356cf366cd617fe3fb5fad9eb961b + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) +PKG_FIXUP = libtool + +include $(INCLUDE_DIR)/package.mk + +MAKE_FLAGS:=PLATFORM=linux + +define Package/ndyndns + SECTION:=net + CATEGORY:=Network + TITLE:=DynDNS.com update daemon + URL:=http://ndyndns.googlecode.com/ + DEPENDS:=+libcurl +libopenssl +endef + +define Package/ndyndns/description + The ndyndns daemon is an update client for DynDNS.com. It + checks for an IP address change every two minutes, avoids + unnecessary updates, reports errors, logs to syslog, and + generally complies with everything required of a proper dyndns + client. +endef + +define Package/ndyndns/conffiles +/etc/ndyndns/ndyndns.conf.sample +/etc/default/ndyndns +endef + +define Package/ndyndns/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/ndyndns $(1)/usr/sbin + $(INSTALL_DIR) $(1)/etc/default + $(INSTALL_BIN) files/$(PKG_NAME).default $(1)/etc/default/$(PKG_NAME) + $(INSTALL_DIR) $(1)/etc/init.d/ + $(INSTALL_BIN) files/$(PKG_NAME).init $(1)/etc/init.d/$(PKG_NAME) + $(INSTALL_DIR) $(1)/etc/$(PKG_NAME) + $(INSTALL_CONF) files/$(PKG_NAME).conf.sample $(1)/etc/$(PKG_NAME) +endef + +$(eval $(call BuildPackage,ndyndns)) diff --git a/net/ndyndns/files/ndyndns.conf.sample b/net/ndyndns/files/ndyndns.conf.sample new file mode 100644 index 0000000000..3f1f7f8142 --- /dev/null +++ b/net/ndyndns/files/ndyndns.conf.sample @@ -0,0 +1,4 @@ +username=user +password=password +hostname=hostname.dyndns.org +wildcard diff --git a/net/ndyndns/files/ndyndns.default b/net/ndyndns/files/ndyndns.default new file mode 100644 index 0000000000..190479431c --- /dev/null +++ b/net/ndyndns/files/ndyndns.default @@ -0,0 +1,3 @@ +CHROOT="/etc/ndyndns" +CONFIG="/etc/ndyndns/ndyndns.conf" +OPTIONS="" diff --git a/net/ndyndns/files/ndyndns.init b/net/ndyndns/files/ndyndns.init new file mode 100644 index 0000000000..113d19ca00 --- /dev/null +++ b/net/ndyndns/files/ndyndns.init @@ -0,0 +1,18 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2007 OpenWrt.org + +START=80 +DEFAULT=/etc/default/ndyndns + +start() { + [ -f $DEFAULT ] && . $DEFAULT + + . /etc/functions.sh + include /lib/network + scan_interfaces + /usr/sbin/ndyndns -c $CHROOT -f $CONFIG -i $(config_get wan ifname) $OPTIONS +} + +stop() { + killall ndyndns +} diff --git a/net/ndyndns/patches/ndyndns.patch b/net/ndyndns/patches/ndyndns.patch new file mode 100644 index 0000000000..8e084cd657 --- /dev/null +++ b/net/ndyndns/patches/ndyndns.patch @@ -0,0 +1,163 @@ +diff -Naur old/Makefile.in new/Makefile.in +--- old/Makefile.in 2007-09-13 10:56:00.000000000 -0700 ++++ new/Makefile.in 2008-02-03 04:07:13.000000000 -0800 +@@ -1,11 +1,9 @@ + #CC = gcc -Wall -Wpointer-arith -Wstrict-prototypes -pedantic + CC = @CC@ +-dnslib = -lnss_dns + objects = log.o nstrl.o util.o chroot.o pidfile.o signals.o strlist.o checkip.o $(PLATFORM).o cfg.o ndyndns.o +-CURLINC = @CURLINC@ + CURLLIB = @CURLLIB@ + VERSION = @VERSION@ +-CFLAGS = @CFLAGS@ -Wall -Wpointer-arith -Wstrict-prototypes -pedantic $(CURLINC) ++CFLAGS += -Wall -Wpointer-arith -Wstrict-prototypes -pedantic + PLATFORM = @PLATFORM@ + prefix = @prefix@ + exec_prefix = @exec_prefix@ +@@ -16,7 +14,7 @@ + all: ndyndns + + ndyndns : $(objects) +- $(CC) $(LDFLAGS) $(dnslib) $(CURLLIB) -o ndyndns $(objects) ++ $(CC) $(LDFLAGS) $(CURLLIB) -o ndyndns $(objects) + + ndyndns.o : log.h nstrl.h util.h chroot.h pidfile.h signals.h strlist.h checkip.h $(PLATFORM).h cfg.h + $(CC) $(CFLAGS) -c -o $@ ndyndns.c +diff -Naur old/chroot.c new/chroot.c +--- old/chroot.c 2007-03-13 15:54:12.000000000 -0700 ++++ new/chroot.c 2008-02-03 04:10:21.000000000 -0800 +@@ -18,8 +18,6 @@ + #include + #include + #include +-#include +-#include + + #include "defines.h" + #include "log.h" +@@ -60,24 +58,4 @@ + log_line("Failed to chdir(%s). Not invoking job.", path); + exit(EXIT_FAILURE); + } +- +- ret = chroot(path); +- if (ret) { +- log_line("Failed to chroot(%s). Not invoking job.", path); +- exit(EXIT_FAILURE); +- } + } +- +-void drop_root(uid_t uid, gid_t gid) +-{ +- if (uid == 0 || gid == 0) { +- log_line("FATAL - drop_root: attempt to drop root to root?\n"); +- exit(EXIT_FAILURE); +- } +- +- if (setregid(gid, gid) == -1 || setreuid(uid, uid) == -1) { +- log_line("FATAL - drop_root: failed to drop root!\n"); +- exit(EXIT_FAILURE); +- } +-} +- +diff -Naur old/ndyndns.c new/ndyndns.c +--- old/ndyndns.c 2007-09-19 00:04:13.000000000 -0700 ++++ new/ndyndns.c 2008-02-03 04:10:21.000000000 -0800 +@@ -32,8 +32,6 @@ + #include + #include + #include +-#include +-#include + + #include + #include +@@ -728,12 +726,9 @@ + } + + int main(int argc, char** argv) { +- int c, t, uid = 0, gid = 0; ++ int c, t; + char pidfile[MAX_PATH_LENGTH] = PID_FILE_DEFAULT; + char conffile[MAX_PATH_LENGTH] = CONF_FILE_DEFAULT; +- char *p; +- struct passwd *pws; +- struct group *grp; + + + while (1) { +@@ -745,8 +740,6 @@ + {"quiet", 0, 0, 'q'}, + {"chroot", 1, 0, 'c'}, + {"file", 1, 0, 'f'}, +- {"user", 1, 0, 'u'}, +- {"group", 1, 0, 'g'}, + {"interface", 1, 0, 'i'}, + {"remote", 0, 0, 'r'}, + {"help", 0, 0, 'h'}, +@@ -754,7 +747,7 @@ + {0, 0, 0, 0} + }; + +- c = getopt_long (argc, argv, "rdnp:qc:f:u:g:i:hv", long_options, &option_index); ++ c = getopt_long (argc, argv, "rdnp:qc:f:i:hv", long_options, &option_index); + if (c == -1) break; + + switch (c) { +@@ -771,8 +764,6 @@ + " -f, --file configuration file\n" + " -p, --pidfile pidfile path\n"); + printf( +-" -u, --user user name that ndyndns should run as\n" +-" -g, --group group name that ndyndns should run as\n" + " -i, --interface interface ip to check (default: ppp0)\n" + " -r, --remote get ip from remote dyndns host (overrides -i)\n" + " -h, --help print this help and exit\n" +@@ -817,39 +808,12 @@ + strlcpy(pidfile, optarg, sizeof pidfile); + break; + +- case 'u': +- t = (unsigned int) strtol(optarg, &p, 10); +- if (*p != '\0') { +- pws = getpwnam(optarg); +- if (pws) { +- uid = (int)pws->pw_uid; +- if (!gid) +- gid = (int)pws->pw_gid; +- } else suicide("FATAL - Invalid uid specified.\n"); +- } else +- uid = t; +- break; +- +- case 'g': +- t = (unsigned int) strtol(optarg, &p, 10); +- if (*p != '\0') { +- grp = getgrnam(optarg); +- if (grp) { +- gid = (int)grp->gr_gid; +- } else suicide("FATAL - Invalid gid specified.\n"); +- } else +- gid = t; +- break; +- + case 'i': + strlcpy(ifname, optarg, sizeof ifname); + break; + } + } + +- if (getuid()) +- suicide("FATAL - I need root for chroot!\n"); +- + if (gflags_detach) + if (daemon(0,0)) + suicide("FATAL - detaching fork failed\n"); +@@ -870,7 +834,6 @@ + + /* Note that failure cases are handled by called fns. */ + imprison(get_chroot()); +- drop_root(uid, gid); + + /* Cover our tracks... */ + wipe_chroot(); -- 2.30.2