summaryrefslogtreecommitdiff
path: root/package/openntpd
diff options
context:
space:
mode:
authorwbx <wbx@hydrogenium.(none)>2009-05-17 14:41:34 +0200
committerwbx <wbx@hydrogenium.(none)>2009-05-17 14:41:34 +0200
commit219a6dab8995aad9ac4860cc1a84d6f3509a03a4 (patch)
treeb9c0f3c43aebba2fcfef777592d0add39f2072f4 /package/openntpd
Initial import
Diffstat (limited to 'package/openntpd')
-rw-r--r--package/openntpd/Config.in9
-rw-r--r--package/openntpd/Makefile35
-rw-r--r--package/openntpd/extra/openbsd-compat/port-linux.c107
-rw-r--r--package/openntpd/files/ntpd.conf8
-rw-r--r--package/openntpd/files/ntpd.init27
-rw-r--r--package/openntpd/ipkg/openntpd.conffiles1
-rw-r--r--package/openntpd/ipkg/openntpd.control7
-rw-r--r--package/openntpd/ipkg/openntpd.postinst7
-rw-r--r--package/openntpd/patches/patch-client_c17
-rw-r--r--package/openntpd/patches/patch-configure_ac18
-rw-r--r--package/openntpd/patches/patch-defines_h17
-rw-r--r--package/openntpd/patches/patch-ntpd_h47
-rw-r--r--package/openntpd/patches/patch-openbsd-compat_Makefile_in15
-rw-r--r--package/openntpd/patches/patch-openbsd-compat_openbsd-compat_h18
14 files changed, 333 insertions, 0 deletions
diff --git a/package/openntpd/Config.in b/package/openntpd/Config.in
new file mode 100644
index 000000000..c9d29a6fd
--- /dev/null
+++ b/package/openntpd/Config.in
@@ -0,0 +1,9 @@
+config ADK_PACKAGE_OPENNTPD
+ prompt "openntpd.......................... A free and easy to use NTP (Network Time Protocol) implementation"
+ tristate
+ default n
+ help
+ NTP server
+
+ http://www.openntpd.org/
+
diff --git a/package/openntpd/Makefile b/package/openntpd/Makefile
new file mode 100644
index 000000000..a068f83d5
--- /dev/null
+++ b/package/openntpd/Makefile
@@ -0,0 +1,35 @@
+# $Id$
+#-
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+include ${TOPDIR}/rules.mk
+
+PKG_NAME:= openntpd
+PKG_VERSION:= 3.9p1
+PKG_RELEASE:= 17
+PKG_MD5SUM:= afc34175f38d08867c1403d9008600b3
+
+MASTER_SITES:= ftp://ftp.openbsd.org/pub/OpenBSD/OpenNTPD/ \
+ ftp://ftp.de.openbsd.org/pub/unix/OpenBSD/OpenNTPD/ \
+ ftp://ftp.fr.openbsd.org/pub/OpenBSD/OpenNTPD/ \
+ ftp://ftp.sunet.se/pub/OpenBSD/OpenNTPD/
+
+include ${TOPDIR}/mk/package.mk
+
+$(eval $(call PKG_template,OPENNTPD,openntpd,${PKG_VERSION}-${PKG_RELEASE},${ARCH}))
+
+CONFIGURE_STYLE:= gnu
+CONFIGURE_ARGS+= --with-privsep-user=ntp \
+ --with-adjtimex
+BUILD_STYLE:= auto
+
+do-install:
+ ${INSTALL_DIR} ${IDIR_OPENNTPD}/etc
+ ${INSTALL_DATA} ./files/ntpd.conf ${IDIR_OPENNTPD}/etc/
+ ${INSTALL_DIR} ${IDIR_OPENNTPD}/etc/init.d
+ ${INSTALL_DATA} ./files/ntpd.init ${IDIR_OPENNTPD}/etc/init.d/ntpd
+ ${INSTALL_DIR} ${IDIR_OPENNTPD}/usr/sbin/
+ ${INSTALL_BIN} ${WRKBUILD}/ntpd ${IDIR_OPENNTPD}/usr/sbin/
+
+include ${TOPDIR}/mk/pkg-bottom.mk
diff --git a/package/openntpd/extra/openbsd-compat/port-linux.c b/package/openntpd/extra/openbsd-compat/port-linux.c
new file mode 100644
index 000000000..f210d4a6d
--- /dev/null
+++ b/package/openntpd/extra/openbsd-compat/port-linux.c
@@ -0,0 +1,107 @@
+/* $Id: port-linux.c 1793 2007-01-28 20:55:08Z tg $ */
+
+/* part of the adjtime-linux patch */
+
+/*
+ * Copyright (c) 2004 Darren Tucker <dtucker at zip com au>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "includes.h"
+
+#ifdef USE_ADJTIMEX
+#include <sys/timex.h>
+#include <errno.h>
+#ifdef adjtime
+# undef adjtime
+#endif
+
+#include "ntpd.h"
+
+/* scale factor used by adjtimex freq param. 1 ppm = 65536 */
+#define ADJTIMEX_FREQ_SCALE 65536
+
+/* maximum change to skew per adjustment, in PPM */
+#define MAX_SKEW_DELTA 5.0
+
+int
+_compat_adjtime(const struct timeval *delta, struct timeval *olddelta)
+{
+ static struct timeval tlast = {0,0};
+ static double tskew = 0;
+ static int synced = -1;
+ struct timeval tnow, tdelta;
+ double skew = 0, newskew, deltaskew, adjust, interval = 0;
+ struct timex tmx;
+ int result, saved_errno;
+
+ gettimeofday(&tnow, NULL);
+ adjust = (double)delta->tv_sec;
+ adjust += (double)delta->tv_usec / 1000000;
+
+ /* Even if the caller doesn't care about the olddelta, we do */
+ if (olddelta == NULL)
+ olddelta = &tdelta;
+
+ result = adjtime(delta, olddelta);
+ saved_errno = errno;
+
+ if (olddelta->tv_sec == 0 && olddelta->tv_usec == 0 &&
+ synced != INT_MAX)
+ synced++;
+ else
+ synced = 0;
+
+ /*
+ * do skew calculations if we have synced
+ */
+ if (synced == 0 ) {
+ tmx.modes = 0;
+ if (adjtimex(&tmx) == -1)
+ log_warn("adjtimex get failed");
+ else
+ tskew = (double)tmx.freq / ADJTIMEX_FREQ_SCALE;
+ } else if (synced >= 1) {
+ interval = (double)(tnow.tv_sec - tlast.tv_sec);
+ interval += (double)(tnow.tv_usec - tlast.tv_usec) / 1000000;
+
+ skew = (adjust * 1000000) / interval;
+ newskew = ((tskew * synced) + skew) / synced;
+ deltaskew = newskew - tskew;
+
+ if (deltaskew > MAX_SKEW_DELTA) {
+ log_info("skew change %0.3lf exceeds limit", deltaskew);
+ tskew += MAX_SKEW_DELTA;
+ } else if (deltaskew < -MAX_SKEW_DELTA) {
+ log_info("skew change %0.3lf exceeds limit", deltaskew);
+ tskew -= MAX_SKEW_DELTA;
+ } else {
+ tskew = newskew;
+ }
+
+ /* Adjust the kernel skew. */
+ tmx.freq = (long)(tskew * ADJTIMEX_FREQ_SCALE);
+ tmx.modes = ADJ_FREQUENCY;
+ if (adjtimex(&tmx) == -1)
+ log_warn("adjtimex set freq failed");
+ }
+
+ log_debug("interval %0.3lf skew %0.3lf total skew %0.3lf", interval,
+ skew, tskew);
+
+ tlast = tnow;
+ errno = saved_errno;
+ return result;
+}
+#endif
diff --git a/package/openntpd/files/ntpd.conf b/package/openntpd/files/ntpd.conf
new file mode 100644
index 000000000..d20963472
--- /dev/null
+++ b/package/openntpd/files/ntpd.conf
@@ -0,0 +1,8 @@
+# Addresses to listen on
+listen on 0.0.0.0
+# enable this for IPv6 support
+#listen on ::
+
+# use a random selection of 8 public stratum 2 servers
+# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers
+servers pool.ntp.org
diff --git a/package/openntpd/files/ntpd.init b/package/openntpd/files/ntpd.init
new file mode 100644
index 000000000..2eab0668c
--- /dev/null
+++ b/package/openntpd/files/ntpd.init
@@ -0,0 +1,27 @@
+#!/bin/sh
+#FWINIT 55
+. /etc/rc.conf
+
+case $1 in
+autostop) ;;
+autostart)
+ [[ $ntpd_flags = NO ]] && exit 0
+ exec sh $0 start
+ ;;
+start)
+ mkdir -p /tmp/.ntp
+ /usr/sbin/ntpd $ntpd_flags
+ ;;
+stop)
+ kill $(pidof ntpd|cut -d ' ' -f 3)
+ ;;
+restart)
+ sh $0 stop
+ sh $0 start
+ ;;
+*)
+ echo "Usage: $0 {start | stop | restart}"
+ exit 1
+ ;;
+esac
+exit $?
diff --git a/package/openntpd/ipkg/openntpd.conffiles b/package/openntpd/ipkg/openntpd.conffiles
new file mode 100644
index 000000000..81306c3c9
--- /dev/null
+++ b/package/openntpd/ipkg/openntpd.conffiles
@@ -0,0 +1 @@
+/etc/ntpd.conf
diff --git a/package/openntpd/ipkg/openntpd.control b/package/openntpd/ipkg/openntpd.control
new file mode 100644
index 000000000..05e16a888
--- /dev/null
+++ b/package/openntpd/ipkg/openntpd.control
@@ -0,0 +1,7 @@
+Package: openntpd
+Priority: optional
+Section: net
+Description: OpenNTPD is a FREE, easy to use implementation of NTP
+ (the Network Time Protocol). It provides the ability to sync the
+ local clock to remote NTP servers and can act as NTP server itself,
+ redistributing the local clock.
diff --git a/package/openntpd/ipkg/openntpd.postinst b/package/openntpd/ipkg/openntpd.postinst
new file mode 100644
index 000000000..53bc8c387
--- /dev/null
+++ b/package/openntpd/ipkg/openntpd.postinst
@@ -0,0 +1,7 @@
+#!/bin/sh
+. $IPKG_INSTROOT/etc/functions.sh
+gid=$(get_next_gid)
+add_group ntp $gid
+add_user ntp $(get_next_uid) $gid /tmp/.ntp
+add_service ntp 123/udp
+add_rcconf 'e.g. "-s"' ntpd_flags
diff --git a/package/openntpd/patches/patch-client_c b/package/openntpd/patches/patch-client_c
new file mode 100644
index 000000000..37c0c89a7
--- /dev/null
+++ b/package/openntpd/patches/patch-client_c
@@ -0,0 +1,17 @@
+$Id$
+
+ bugfix from MirBSD ntpd: do not hardcode the number
+ of required adjustment offsets, use the constant
+ instead, MirOS commitid 10047041D2145A88E16
+
+--- openntpd-3.9p1.orig/client.c Sun May 14 05:28:58 2006
++++ openntpd-3.9p1/client.c Mon Oct 8 12:08:30 2007
+@@ -314,7 +314,7 @@ client_update(struct ntp_peer *p)
+ best = i;
+ }
+
+- if (good < 8)
++ if (good < OFFSET_ARRAY_SIZE)
+ return (-1);
+
+ memcpy(&p->update, &p->reply[best], sizeof(p->update));
diff --git a/package/openntpd/patches/patch-configure_ac b/package/openntpd/patches/patch-configure_ac
new file mode 100644
index 000000000..aa98cb71d
--- /dev/null
+++ b/package/openntpd/patches/patch-configure_ac
@@ -0,0 +1,18 @@
+$Id$
+
+ part of the "adjtime-linux" patch
+
+--- openntpd-3.9p1.orig/configure.ac 2006-05-14 05:29:23.000000000 +0000
++++ openntpd-3.9p1/configure.ac 2007-01-28 20:49:48.000000000 +0000
+@@ -617,6 +617,11 @@ else
+ fi
+ AC_SUBST(mansubdir)
+
++AC_ARG_WITH(adjtimex,
++ [ --with-adjtimex Use adjtimex to adjust kernel skew],
++ [ AC_DEFINE(USE_ADJTIMEX, [], [Use adjust skew with adjtimex (experimental)]) ]
++)
++
+ # Search for OpenSSL if required.
+ if test "$ac_cv_func_arc4random" != "yes" && test "x$builtin_arc4random" != "xyes"; then
+ saved_CPPFLAGS="$CPPFLAGS"
diff --git a/package/openntpd/patches/patch-defines_h b/package/openntpd/patches/patch-defines_h
new file mode 100644
index 000000000..9e2b35bf1
--- /dev/null
+++ b/package/openntpd/patches/patch-defines_h
@@ -0,0 +1,17 @@
+$Id$
+
+ part of the "adjtime-linux" patch
+
+--- openntpd-3.9p1.orig/defines.h 2006-05-14 05:29:21.000000000 +0000
++++ openntpd-3.9p1/defines.h 2007-01-28 20:49:48.000000000 +0000
+@@ -20,6 +20,10 @@
+ # define setproctitle(x)
+ #endif
+
++#ifdef USE_ADJTIMEX
++# define adjtime(a,b) (_compat_adjtime((a),(b)))
++#endif
++
+ #if !defined(SA_LEN)
+ # if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
+ # define SA_LEN(x) ((x)->sa_len)
diff --git a/package/openntpd/patches/patch-ntpd_h b/package/openntpd/patches/patch-ntpd_h
new file mode 100644
index 000000000..9189d6204
--- /dev/null
+++ b/package/openntpd/patches/patch-ntpd_h
@@ -0,0 +1,47 @@
+$Id$
+
+ ‣ OFFSET_ARRAY_SIZE
+ pull in the following diff from MirBSD:
+ | Commit ID: 100470A1C1009540C55
+ | CVSROOT: /cvs
+ | Module name: src
+ | Changes by: tg@herc.mirbsd.org 2007/10/08 12:04:34 UTC
+ |
+ | Modified files:
+ | usr.sbin/ntpd : ntpd.h
+ |
+ | Log message:
+ | reduce the number of probes in the clock filter down to 4, so that adjtime
+ | is called at least approx. 3 times a hour, greatly helping us to reduce the
+ | size of the spikes for systems with clock drift (but increasing susceptibi-
+ | lity to latency-induced low-quality responses)
+ |
+ | tested on herc/rant with a value of 3 (adjust about 4 times an hour)
+ |
+ | XXX this should be made an ntpd.conf option instead of a define ASAP
+ | XXX this should be reverted once we have adjfreq(2)
+ but we use 3 here due to employment of adjtimex() which reduces
+ usability of older deltas
+
+ ‣ SETTIME_MIN_OFFSET
+ reduce the minimum required time offset for 'ntpd -s' to
+ use settimeofday() instead of adjtime(), in order to provide
+ a faster time setting at start, since adjusting can take ages
+
+--- openntpd-3.9p1.orig/ntpd.h Sun May 14 05:28:58 2006
++++ openntpd-3.9p1/ntpd.h Mon Oct 8 12:17:58 2007
+@@ -55,8 +55,12 @@
+ #define QSCALE_OFF_MAX 0.50
+
+ #define QUERYTIME_MAX 15 /* single query might take n secs max */
+-#define OFFSET_ARRAY_SIZE 8
+-#define SETTIME_MIN_OFFSET 180 /* min offset for settime at start */
++#ifdef USE_ADJTIMEX
++#define OFFSET_ARRAY_SIZE 3 /* so they get invalidated faster */
++#else
++#define OFFSET_ARRAY_SIZE 4 /* min. 3, recommended 6, max. 8 */
++#endif
++#define SETTIME_MIN_OFFSET 12 /* min offset for settime at start */
+ #define SETTIME_TIMEOUT 15 /* max seconds to wait with -s */
+ #define LOG_NEGLIGEE 128 /* negligible drift to not log (ms) */
+
diff --git a/package/openntpd/patches/patch-openbsd-compat_Makefile_in b/package/openntpd/patches/patch-openbsd-compat_Makefile_in
new file mode 100644
index 000000000..c2660e499
--- /dev/null
+++ b/package/openntpd/patches/patch-openbsd-compat_Makefile_in
@@ -0,0 +1,15 @@
+$Id$
+
+ part of the "adjtime-linux" patch
+
+--- openntpd-3.9p1.orig/openbsd-compat/Makefile.in 2006-05-14 05:29:19.000000000 +0000
++++ openntpd-3.9p1/openbsd-compat/Makefile.in 2007-01-28 20:49:48.000000000 +0000
+@@ -9,7 +9,7 @@ OPENBSD= asprintf.o daemon.o errx.o inet
+ COMPAT= atomicio.o bsd-arc4random.o bsd-misc.o bsd-poll.o \
+ bsd-snprintf.o bsd-getifaddrs.o bsd-setresuid.o \
+ bsd-setresgid.o fake-rfc2553.o
+-PORT= port-qnx.o
++PORT= port-linux.o port-qnx.o
+
+ VPATH=@srcdir@
+ CC=@CC@
diff --git a/package/openntpd/patches/patch-openbsd-compat_openbsd-compat_h b/package/openntpd/patches/patch-openbsd-compat_openbsd-compat_h
new file mode 100644
index 000000000..cdc7cc679
--- /dev/null
+++ b/package/openntpd/patches/patch-openbsd-compat_openbsd-compat_h
@@ -0,0 +1,18 @@
+$Id$
+
+ part of the "adjtime-linux" patch
+
+--- openntpd-3.9p1.orig/openbsd-compat/openbsd-compat.h 2006-05-14 05:29:19.000000000 +0000
++++ openntpd-3.9p1/openbsd-compat/openbsd-compat.h 2007-01-28 20:49:48.000000000 +0000
+@@ -46,6 +46,11 @@ int asprintf(char **, const char *,
+ __attribute__((__format__ (printf, 2, 3)));
+ #endif
+
++#ifdef USE_ADJTIMEX
++# include <sys/time.h>
++int _compat_adjtime(const struct timeval *, struct timeval *);
++#endif
++
+ #ifndef HAVE_INET_PTON
+ int inet_pton(int, const char *, void *);
+ #endif