diff options
Diffstat (limited to 'abs')
-rw-r--r-- | abs/core/openntpd/PKGBUILD | 54 | ||||
-rw-r--r-- | abs/core/openntpd/linux-adjtimex.patch | 168 | ||||
-rwxr-xr-x | abs/core/openntpd/openntpd | 43 | ||||
-rw-r--r-- | abs/core/openntpd/openntpd.conf | 4 | ||||
-rw-r--r-- | abs/core/openntpd/openntpd.install | 25 | ||||
-rw-r--r-- | abs/core/openntpd/sync_fix_with_adjtime.patch | 24 |
6 files changed, 318 insertions, 0 deletions
diff --git a/abs/core/openntpd/PKGBUILD b/abs/core/openntpd/PKGBUILD new file mode 100644 index 0000000..bcf4e5d --- /dev/null +++ b/abs/core/openntpd/PKGBUILD @@ -0,0 +1,54 @@ +# $Id: PKGBUILD 31923 2010-11-07 21:40:10Z lcarlier $ +# Maintainer: Vesa Kaihlavirta <vegai@iki.fi> +# Contributor: Mark Rosenstand <mark@borkware.net> +# Contributor: Giorgio Lando <patroclo7@gmail.com> (adjtimex patch) + +pkgname=openntpd +pkgver=3.9p1 +pkgrel=13 +pkgdesc="Free, easy to use implementation of the Network Time Protocol." +url="http://www.openntpd.org/" +arch=('i686' 'x86_64') +license=('BSD') +depends=('openssl') +backup=('etc/ntpd.conf' 'etc/conf.d/openntpd') +replaces=('ntp') +install=openntpd.install +source=(ftp://ftp.openbsd.org/pub/OpenBSD/OpenNTPD/$pkgname-$pkgver.tar.gz + 'openntpd' 'openntpd.conf' 'linux-adjtimex.patch') +md5sums=('afc34175f38d08867c1403d9008600b3' + '2422b40f16acf8c92e9051e3e07fc96a' + 'ab38a035cbebe7a52888db6c573944a5' + '6e04eecf89ee794d6f1ae79f03742cf9') + +build() { + cd $srcdir/$pkgname-$pkgver + + patch -Np1 -i ../linux-adjtimex.patch + + # fixes FS#19509 - [openntpd] builds without linux-adjtimex.patch + autoreconf -fi + #autoconf + + ./configure \ + --prefix=/usr \ + --sysconfdir=/etc \ + --with-privsep-user=ntp \ + --with-privsep-path=/var/run/openntpd/ \ + --with-adjtimex + + make || return 1 +} + +package() { + cd $srcdir/$pkgname-$pkgver + + make DESTDIR=$pkgdir install || return 1 + + install -D -m755 $srcdir/openntpd $pkgdir/etc/rc.d/openntpd + install -D -m644 $srcdir/openntpd.conf $pkgdir/etc/conf.d/openntpd + install -D -m644 $srcdir/$pkgname-$pkgver/LICENCE $pkgdir/usr/share/licenses/$pkgname/LICENCE + + # FS#16893 + sed -i 's/\*/0.0.0.0/' $pkgdir/etc/ntpd.conf +} diff --git a/abs/core/openntpd/linux-adjtimex.patch b/abs/core/openntpd/linux-adjtimex.patch new file mode 100644 index 0000000..e7b72da --- /dev/null +++ b/abs/core/openntpd/linux-adjtimex.patch @@ -0,0 +1,168 @@ +Only in openntpd-3.9p1.old: configure +diff -ur --unidirectional-new-file openntpd-3.9p1.old/configure.ac openntpd-3.9p1/configure.ac +--- openntpd-3.9p1.old/configure.ac 2006-05-14 07:29:23.000000000 +0200 ++++ openntpd-3.9p1/configure.ac 2008-02-07 13:13:18.066366142 +0100 +@@ -583,6 +583,11 @@ + [ builtin_arc4random=$withval ] + ) + ++AC_ARG_WITH(adjtimex, ++ [ --with-adjtimex Use adjtimex to adjust kernel skew], ++ [ AC_DEFINE(USE_ADJTIMEX, [], [Use adjust skew with adjtimex (experimental)]) ] ++ ) ++ + AC_ARG_WITH(mantype, + [ --with-mantype=man|cat|doc Set man page type], + [ +diff -ur --unidirectional-new-file openntpd-3.9p1.old/defines.h openntpd-3.9p1/defines.h +--- openntpd-3.9p1.old/defines.h 2006-05-14 07:29:21.000000000 +0200 ++++ openntpd-3.9p1/defines.h 2008-02-07 13:14:34.488711868 +0100 +@@ -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) +Only in openntpd-3.9p1.old: ntpd.0 +Only in openntpd-3.9p1.old: ntpd.conf.0 +diff -ur --unidirectional-new-file openntpd-3.9p1.old/openbsd-compat/Makefile.in openntpd-3.9p1/openbsd-compat/Makefile.in +--- openntpd-3.9p1.old/openbsd-compat/Makefile.in 2006-05-14 07:29:19.000000000 +0200 ++++ openntpd-3.9p1/openbsd-compat/Makefile.in 2008-02-07 13:31:39.499728930 +0100 +@@ -9,7 +9,7 @@ + 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 -ur --unidirectional-new-file openntpd-3.9p1.old/openbsd-compat/openbsd-compat.h openntpd-3.9p1/openbsd-compat/openbsd-compat.h +--- openntpd-3.9p1.old/openbsd-compat/openbsd-compat.h 2006-05-14 07:29:19.000000000 +0200 ++++ openntpd-3.9p1/openbsd-compat/openbsd-compat.h 2008-02-07 13:17:00.272366764 +0100 +@@ -46,6 +46,11 @@ + __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 +diff -ur --unidirectional-new-file openntpd-3.9p1.old/openbsd-compat/port-linux.c openntpd-3.9p1/openbsd-compat/port-linux.c +--- openntpd-3.9p1.old/openbsd-compat/port-linux.c 1970-01-01 01:00:00.000000000 +0100 ++++ openntpd-3.9p1/openbsd-compat/port-linux.c 2008-02-07 13:24:43.800366563 +0100 +@@ -0,0 +1,105 @@ ++ ++ ++/* ++ * 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/abs/core/openntpd/openntpd b/abs/core/openntpd/openntpd new file mode 100755 index 0000000..0e63073 --- /dev/null +++ b/abs/core/openntpd/openntpd @@ -0,0 +1,43 @@ +#!/bin/bash + +CONF=/etc/conf.d/openntpd +RUNDIR=/var/run/openntpd + +. /etc/rc.conf +. /etc/rc.d/functions + +[ -f $CONF ] && . $CONF + +PID=`pidof -o %PPID /usr/sbin/ntpd` +case "$1" in + start) + stat_busy "Starting OpenNTPD" + [ -d $RUNDIR ] || mkdir $RUNDIR + [ -z "$PID" ] && /usr/sbin/ntpd $PARAMS + if [ $? -gt 0 ]; then + stat_fail + else + PID=`pidof -o %PPID /usr/sbin/ntpd` + echo $PID >/var/run/openntpd.pid + add_daemon openntpd + stat_done + fi + ;; + stop) + stat_busy "Stopping OpenNTPD" + [ ! -z "$PID" ] && kill $PID &>/dev/null + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon openntpd + stat_done + fi + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 diff --git a/abs/core/openntpd/openntpd.conf b/abs/core/openntpd/openntpd.conf new file mode 100644 index 0000000..a2af277 --- /dev/null +++ b/abs/core/openntpd/openntpd.conf @@ -0,0 +1,4 @@ +# -s Set the time immediately at startup if the local clock is off by more than# 180 seconds. +PARAMS="-s" + + diff --git a/abs/core/openntpd/openntpd.install b/abs/core/openntpd/openntpd.install new file mode 100644 index 0000000..837e4a1 --- /dev/null +++ b/abs/core/openntpd/openntpd.install @@ -0,0 +1,25 @@ +post_install() { + if [ ! "`grep ^ntp /etc/group`" ]; then + echo "adding new group: ntp" + /usr/sbin/groupadd -g 87 ntp + fi + + if [ ! "`grep ^ntp /etc/passwd`" ]; then + echo "adding new user: ntp" + /usr/sbin/useradd -g ntp -u 87 -d /var/empty -s /bin/false -c 'Network Time Protocol' ntp + fi +} + +post_upgrade() { + post_install $1 +} + +pre_remove() { + /bin/true +} + +post_remove() { + /bin/true +} + +# vim: ts=2 sw=2 et ft=sh diff --git a/abs/core/openntpd/sync_fix_with_adjtime.patch b/abs/core/openntpd/sync_fix_with_adjtime.patch new file mode 100644 index 0000000..4b9956b --- /dev/null +++ b/abs/core/openntpd/sync_fix_with_adjtime.patch @@ -0,0 +1,24 @@ +Index: ntp.c +=================================================================== +RCS file: /storage/1/mirror/openbsd/src/usr.sbin/ntpd/ntp.c,v +retrieving revision 1.91 +diff -u -r1.91 ntp.c +--- ntp.c 1 Jul 2006 18:52:46 -0000 1.91 ++++ ntp.c 15 Jul 2006 07:50:05 -0000 +@@ -1,4 +1,4 @@ +-/* $OpenBSD: ntp.c,v 1.91 2006-07-01 18:52:46 otto Exp $ */ ++/* $OpenBSD: ntp.c,v 1.91 2006/07/01 18:52:46 otto Exp $ */ + + /* + * Copyright (c) 2003, 2004 Henning Brauer <[EMAIL PROTECTED]> +@@ -315,8 +315,10 @@ + for (s = TAILQ_FIRST(&conf->ntp_sensors); s != NULL; + s = next_s) { + next_s = TAILQ_NEXT(s, entry); +- if (s->next <= time(NULL)) ++ if (s->next <= time(NULL)) { + sensor_query(s); ++ priv_adjtime(); ++ } + } + } |