Commit 060b12f1 authored by Natanael Copa's avatar Natanael Copa
Browse files

core/openntpd: new aport

parent ba1c7e30
pkgname=openntpd
pkgver=3.9_p1
_myver=3.9p1
pkgrel=2
pkgdesc="Lightweight NTP server ported from OpenBSD"
url=http://www.openntpd.org/
install=openntpd.install
subpackages="doc"
source="
ftp://ftp.openbsd.org/pub/OpenBSD/OpenNTPD/openntpd-$_myver.tar.gz
openntpd-3.9p1_reconnect_on_sendto_EINVAL.diff
openntpd-3.9p1-ifaddr.patch
openntpd.conf.d
openntpd.rc
openntpd.install
"
_prepare() {
cd "$srcdir/$pkgname-$_myver"
patch -p1 < ../openntpd-3.9p1-ifaddr.patch
patch -p1 < ../openntpd-3.9p1_reconnect_on_sendto_EINVAL.diff
sed -i '/NTPD_USER/s:_ntp:ntp:' ntpd.h || return 1
}
_compile() {
cd "$srcdir/$pkgname-$_myver"
./configure --prefix=/usr --mandir=/usr/share/man
make || return 1
}
_install() {
cd "$srcdir/$pkgname-$_myver"
make install DESTDIR="$pkgdir"
mkdir -p "$pkgdir/etc/init.d" "$pkgdir/etc/conf.d"
cp ../openntpd.rc "$pkgdir/etc/init.d/ntpd"
cp ../openntpd.conf.d "$pkgdir/etc/conf.d/ntpd"
}
build() {
_prepare && _compile && _install
}
md5sums="afc34175f38d08867c1403d9008600b3 openntpd-3.9p1.tar.gz
ae2f708b860975b64126bb316aeb6641 openntpd-3.9p1_reconnect_on_sendto_EINVAL.diff
a1640ec40ac228338e60bd4fda42f84d openntpd-3.9p1-ifaddr.patch
e3eee9eb2ea092dfdf9d887cd6df5795 openntpd.conf.d
5000453927b7ae9943d51194c1042355 openntpd.rc
f4718a73028d6f65770a6bc2877a21f3 openntpd.install"
--- openntpd-3.9p1.orig/server.c Thu Nov 6 10:11:16 2008
+++ openntpd-3.9p1/server.c Thu Nov 6 10:11:36 2008
@@ -23,9 +23,6 @@
#include <sys/socket.h>
#include <errno.h>
#include <netinet/in.h>
-#ifdef HAVE_IFADDRS_H
-# include <ifaddrs.h>
-#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
diff -Naur openntpd-3.9p1/client.c openntpd-3.9p1-fixed/client.c
--- openntpd-3.9p1/client.c 2006-05-14 07:29:21.000000000 +0200
+++ openntpd-3.9p1-fixed/client.c 2006-10-11 02:41:44.000000000 +0200
@@ -116,6 +116,7 @@
client_query(struct ntp_peer *p)
{
int tos = IPTOS_LOWDELAY;
+ int result;
if (p->addr == NULL && client_nextaddr(p) == -1) {
set_next(p, error_interval());
@@ -163,9 +164,17 @@
p->query->msg.xmttime.fractionl = arc4random();
p->query->xmttime = gettime();
- if (ntp_sendmsg(p->query->fd, NULL, &p->query->msg,
- NTP_MSGSIZE_NOAUTH, 0) == -1) {
+ if ((result = ntp_sendmsg(p->query->fd, NULL, &p->query->msg,
+ NTP_MSGSIZE_NOAUTH, 0)) < 0) {
set_next(p, INTERVAL_QUERY_PATHETIC);
+ if (result == -2) {
+ /*
+ * got EINVAL in sendto(), probably the local socket
+ * address got invalidated -> force re-connect()
+ */
+ close(p->query->fd);
+ p->query->fd = -1;
+ }
return (-1);
}
diff -Naur openntpd-3.9p1/ntp_msg.c openntpd-3.9p1-fixed/ntp_msg.c
--- openntpd-3.9p1/ntp_msg.c 2006-05-14 07:29:21.000000000 +0200
+++ openntpd-3.9p1-fixed/ntp_msg.c 2006-10-11 02:41:49.000000000 +0200
@@ -98,6 +98,8 @@
return (-1);
}
log_warn("sendto");
+ if (errno == EINVAL)
+ return (-2);
return (-1);
}
# /etc/conf.d/ntpd: config file for openntpd's ntpd
NTPD_HOME=/var/empty
# See ntpd(8) man page ... some popular options:
# -s Set the time immediately at startup
NTPD_OPTS=""
#!/bin/sh
case $1 in
pre-install)
# this user should be included in alpine-baselayout-1.2.
# included here for backward compability.
adduser -H -h /var/empty -s /bin/false -D ntp 2>/dev/null
;;
esac
exit 0
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/openntpd/files/openntpd.rc,v 1.7 2008/10/10 09:40:10 bangert Exp $
depend() {
need net
after ntp-client
use dns logger
}
checkconfig() {
if [ ! -f /etc/ntpd.conf ] ; then
eerror "Could not find /etc/ntpd.conf!"
return 1
fi
if [ -x /usr/bin/getent ] ; then
if [ "`getent passwd ntp | cut -d: -f 6`" != "${NTPD_HOME}" ] ; then
eerror "Home directory of ntp needs to be ${NTPD_HOME}"
eerror "Please run 'usermod -d ${NTPD_HOME} ntp'"
return 1
fi
fi
return 0
}
start() {
checkconfig || return $?
ebegin "Starting ntpd"
start-stop-daemon --start --exec /usr/sbin/ntpd --name ntpd -- ${NTPD_OPTS}
eend $? "Failed to start ntpd"
}
stop() {
ebegin "Stopping ntpd"
start-stop-daemon --stop --exec /usr/sbin/ntpd --name ntpd --user root
eend $? "Failed to stop openntpd"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment