~alpine/devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[alpine-devel] [PATCH] main/chrony Version bump 1.29.1

Nathan Angelacos <nangel@alpinelinux.org>
Details
Message ID
<1392670307-31294-1-git-send-email-nangel@alpinelinux.org>
Sender timestamp
1392670307
DKIM signature
missing
Download raw message
Patch: +239 -11
* Fixes monlist-like amplification vector
* Include timepps.h to grab PPS from gpsd
---
 main/chrony/APKBUILD  |  34 +++++---
 main/chrony/timepps.h | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 239 insertions(+), 11 deletions(-)
 create mode 100644 main/chrony/timepps.h

diff --git a/main/chrony/APKBUILD b/main/chrony/APKBUILD
index 5a7ff12..8702ea0 100644
--- a/main/chrony/APKBUILD
+++ b/main/chrony/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=chrony
pkgver=1.29
pkgrel=1
pkgver=1.29.1
pkgrel=0
_ver=${pkgver/_/-}
pkgdesc="NTP client and server programs"
url="http://chrony.tuxfamily.org/"
@@ -17,11 +17,18 @@ source="http://download.tuxfamily.org/chrony/$pkgname-$_ver.tar.gz
	chronyd.initd
	chrony.logrotate
	chrony.conf
	timepps.h
	"

_builddir="$srcdir"/$pkgname-$_ver
prepare() {
	local i
	# We copy timepps.h to the local build directory instead of
	# creating a pps-tools-dev package for ppstime.h
	# (See https://github.com/ago/pps-tools)
	mkdir -p "$_builddir"/pps-tools/sys
	cp timepps.h "$_builddir"/pps-tools/sys/
	
	cd "$_builddir"

	for i in $source; do
@@ -31,13 +38,15 @@ prepare() {
	done
	sed -i "s:/etc/chrony:/etc/chrony/chrony:g" \
		chrony*.[158] faq.txt || die "sed failed"
	
}


build() {
	cd "$_builddir"

        cd "$_builddir"
        CPPFLAGS="$CPPFLAGS -I./pps-tools/" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man \
@@ -61,24 +70,27 @@ package() {
	touch "$pkgdir"/etc/chrony/chrony.drift
	install -m644 "$srcdir"/chrony.conf "$pkgdir"/etc/chrony/chrony.conf
}
md5sums="6e1a8ee2ce6632bedc2f8b5cdccfa69f  chrony-1.29.tar.gz
md5sums="9d49eadac5eb49daec8cc3d92a869b0c  chrony-1.29.1.tar.gz
c479553205e2dfe1409c7924b0d0f81b  0001-uclibc-res-do-not-call-res_init.patch
1f72a2805160dfa653866e0963256f7f  0002-ntp_sources-decrease-maximum-re-resolving-delay.patch
d62521b4c8837e15262c47ac88359307  chronyd.confd
f0c73948224cc1706cf9c94e4d2d7b69  chronyd.initd
468eaf2b5465d60b3ee021ce3f948ab1  chrony.logrotate
46f42c52953d398ca44d6baa449618d7  chrony.conf"
sha256sums="c685f072ba0663ab026a7f56870ab2c246bd97ca4629dd2e1899617bd16ad39b  chrony-1.29.tar.gz
46f42c52953d398ca44d6baa449618d7  chrony.conf
28f6835098a216f4a620f9218d15b5b8  timepps.h"
sha256sums="658c9bb4d8c8d8ec7d0908429aa266e5f8413ba86bd4acbfd2f9669f6065af27  chrony-1.29.1.tar.gz
4aec957ff59adbba1058e5376c73fe74e1e6fb511d9ca6cb5b6e74fca8c75a9f  0001-uclibc-res-do-not-call-res_init.patch
20be1362eac7f19d5ff3c69d0821d165ef7c29202b563c5e638c0f3092b192d8  0002-ntp_sources-decrease-maximum-re-resolving-delay.patch
29040502f86c419dbfbc7e2627cc658a8df82b37da21b3d1fce2eed9136d8f99  chronyd.confd
f3a2a5ff9800bfc6a49897c6c8f64d264a75fc2e65cd98e059beaf9e5446fd1b  chronyd.initd
d25ce3f5ce4a28184931c68a97340a5b332cbaf071434d172f262122240ad652  chrony.logrotate
43e1bf9c3b0eb95c6330afdc9063f24353086f057d258c00ea711975a86c1194  chrony.conf"
sha512sums="bea384e098a7ea3862e49b31ee85959ae1d23af3a095dd34dbfc6e52329dc9404ff2ca9d0e01eb12ea79d2f5ab484a67f025c152a374bc6bd0e3a803a3bec93e  chrony-1.29.tar.gz
43e1bf9c3b0eb95c6330afdc9063f24353086f057d258c00ea711975a86c1194  chrony.conf
ab4f459ee9d1037d7fa962a66ea652b08935539a4f443dc216e82b5717d8bb22  timepps.h"
sha512sums="0573eea9745089f0b5f257faaf9e601b98fd7d773063c41f3354592830bf5d047f4960e1a9e739ab706e5308ff908c29aead913ab7dbcf8b66543d18b85410bd  chrony-1.29.1.tar.gz
5b1d0766eceee000d97dfb20c34f95319ac295729c16e571d7fe382e7d737c7335a1a98b67d89792056f969d4bb9eb7296c343ee4bb16c6a0805606f505d16c5  0001-uclibc-res-do-not-call-res_init.patch
765687fe59ba0f0f254e2d443defdb451fe6371d13dc62692d86d935d938dc10eb54c24ea70589227cd519153f94ae5171fcf6a0a08a2e7baf7b76be8abd4ac2  0002-ntp_sources-decrease-maximum-re-resolving-delay.patch
6919c7bddce2a8f81c0f2759c7c58506e97f89102bfeb7b5c19c6da5ed4cbd9070faddd4f3fb411bb4c653fffbdcc93a7f7dc810f38b199f038b1d4072f57640  chronyd.confd
fdf97b2e6790b29ba1979326e553808712ba25b500e6c82346651b27711ba4b2e22f1bba9b26b6740127bd9ccaa25a7b7d27514a00489be5823a8bbf4cef13a8  chronyd.initd
8c2f9b396bde7f0124fdc4bb25fb31d154ae4ec73717401e5dd36a3730cd55ff91e60c70bcafb917883e437993ee245ad56e7a12c3711b482c6df592896a42dc  chrony.logrotate
23157310e9352736efb000fef9f37cb57bfdc3b0ee95bfd5022b8e00dbfb16bfede1692fd91a128a9bedebfcf938b1668fa0695a112bd0c24525487ee2a53c65  chrony.conf"
23157310e9352736efb000fef9f37cb57bfdc3b0ee95bfd5022b8e00dbfb16bfede1692fd91a128a9bedebfcf938b1668fa0695a112bd0c24525487ee2a53c65  chrony.conf
eb11fc19243d1789016d88eb7645bfe67c46304547781489bf36eb1dd4c252d523681ff835a6488fa0ef62b6b9e2f781c672279f4439f5d5640a3f214a113048  timepps.h"
diff --git a/main/chrony/timepps.h b/main/chrony/timepps.h
new file mode 100644
index 0000000..8c3bd83
--- /dev/null
+++ b/main/chrony/timepps.h
@@ -0,0 +1,216 @@
/*
 * timepps.h -- PPS API main header
 *
 * Copyright (C) 2005-2007   Rodolfo Giometti <giometti@linux.it>
 * Copyright (C) 2009-2011   Alexander Gordeev <alex@gordick.net>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 * Source: https://github.com/ago/pps-tools/ - Retreived Dec 2013
 */

#ifndef _SYS_TIMEPPS_H_
#define _SYS_TIMEPPS_H_

#include <errno.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/pps.h>

#define LINUXPPS	1		/* signal we are using LinuxPPS */

/*
 * New data structures
 */

struct ntp_fp {
	unsigned int integral;
	unsigned int fractional;
};

union pps_timeu {
	struct timespec tspec;
	struct ntp_fp ntpfp;
	unsigned long longpad[3];
};

struct pps_info {
	unsigned long assert_sequence;	/* seq. num. of assert event */
	unsigned long clear_sequence;	/* seq. num. of clear event */
	union pps_timeu assert_tu;	/* time of assert event */
	union pps_timeu clear_tu;	/* time of clear event */
	int current_mode;		/* current mode bits */
};

struct pps_params {
	int api_version;		/* API version # */
	int mode;			/* mode bits */
	union pps_timeu assert_off_tu;	/* offset compensation for assert */
	union pps_timeu clear_off_tu;	/* offset compensation for clear */
};

typedef int pps_handle_t;		/* represents a PPS source */
typedef unsigned long pps_seq_t;	/* sequence number */
typedef struct ntp_fp ntp_fp_t;		/* NTP-compatible time stamp */
typedef union pps_timeu pps_timeu_t;	/* generic data type for time stamps */
typedef struct pps_info pps_info_t;
typedef struct pps_params pps_params_t;

#define assert_timestamp        assert_tu.tspec
#define clear_timestamp         clear_tu.tspec

#define assert_timestamp_ntpfp  assert_tu.ntpfp
#define clear_timestamp_ntpfp   clear_tu.ntpfp

#define assert_offset		assert_off_tu.tspec
#define clear_offset		clear_off_tu.tspec

#define assert_offset_ntpfp     assert_off_tu.ntpfp
#define clear_offset_ntpfp      clear_off_tu.ntpfp

/*
 * The PPS API
 */

static __inline int time_pps_create(int source, pps_handle_t *handle)
{
	int ret;
	struct pps_kparams dummy;

	if (!handle) {
		errno = EINVAL;
		return -1;
	}

	/* First we check if current device is a valid PPS one by
	 * doing a dummy PPS_GETPARAMS...
	 */
	ret = ioctl(source, PPS_GETPARAMS, &dummy);
	if (ret) {
		errno = EOPNOTSUPP;
		return -1;
	}

	/* ... then since in LinuxPPS there are no differences between a
	 * "PPS source" and a "PPS handle", we simply return the same value.
	 */
	*handle = source;

	return 0;
}

static __inline int time_pps_destroy(pps_handle_t handle)
{
	return close(handle);
}

static __inline int time_pps_getparams(pps_handle_t handle,
					pps_params_t *ppsparams)
{
	int ret;
	struct pps_kparams __ppsparams;

	ret = ioctl(handle, PPS_GETPARAMS, &__ppsparams);

	ppsparams->api_version = __ppsparams.api_version;
	ppsparams->mode = __ppsparams.mode;
	ppsparams->assert_off_tu.tspec.tv_sec = __ppsparams.assert_off_tu.sec;
	ppsparams->assert_off_tu.tspec.tv_nsec = __ppsparams.assert_off_tu.nsec;
	ppsparams->clear_off_tu.tspec.tv_sec = __ppsparams.clear_off_tu.sec;
	ppsparams->clear_off_tu.tspec.tv_nsec = __ppsparams.clear_off_tu.nsec;

	return ret;
}

static __inline int time_pps_setparams(pps_handle_t handle,
					const pps_params_t *ppsparams)
{
	struct pps_kparams __ppsparams;

	__ppsparams.api_version = ppsparams->api_version;
	__ppsparams.mode = ppsparams->mode;
	__ppsparams.assert_off_tu.sec = ppsparams->assert_off_tu.tspec.tv_sec;
	__ppsparams.assert_off_tu.nsec = ppsparams->assert_off_tu.tspec.tv_nsec;
	__ppsparams.clear_off_tu.sec = ppsparams->clear_off_tu.tspec.tv_sec;
	__ppsparams.clear_off_tu.nsec = ppsparams->clear_off_tu.tspec.tv_nsec;

	return ioctl(handle, PPS_SETPARAMS, &__ppsparams);
}

/* Get capabilities for handle */
static __inline int time_pps_getcap(pps_handle_t handle, int *mode)
{
	return ioctl(handle, PPS_GETCAP, mode);
}

static __inline int time_pps_fetch(pps_handle_t handle, const int tsformat,
					pps_info_t *ppsinfobuf,
					const struct timespec *timeout)
{
	struct pps_fdata __fdata;
	int ret;

	/* Sanity checks */
	if (tsformat != PPS_TSFMT_TSPEC) {
		errno = EINVAL;
		return -1;
	}

	if (timeout) {
		__fdata.timeout.sec = timeout->tv_sec;
		__fdata.timeout.nsec = timeout->tv_nsec;
		__fdata.timeout.flags = ~PPS_TIME_INVALID;
	} else
		__fdata.timeout.flags = PPS_TIME_INVALID;

	ret = ioctl(handle, PPS_FETCH, &__fdata);

	ppsinfobuf->assert_sequence = __fdata.info.assert_sequence;
	ppsinfobuf->clear_sequence = __fdata.info.clear_sequence;
	ppsinfobuf->assert_tu.tspec.tv_sec = __fdata.info.assert_tu.sec;
	ppsinfobuf->assert_tu.tspec.tv_nsec = __fdata.info.assert_tu.nsec;
	ppsinfobuf->clear_tu.tspec.tv_sec = __fdata.info.clear_tu.sec;
	ppsinfobuf->clear_tu.tspec.tv_nsec = __fdata.info.clear_tu.nsec;
	ppsinfobuf->current_mode = __fdata.info.current_mode;

	return ret;
}

#ifdef PPS_KC_BIND

static __inline int time_pps_kcbind(pps_handle_t handle,
					const int kernel_consumer,
					const int edge, const int tsformat)
{
	struct pps_bind_args __bind_args;

	__bind_args.tsformat = tsformat;
	__bind_args.edge = edge;
	__bind_args.consumer = kernel_consumer;

	return ioctl(handle, PPS_KC_BIND, &__bind_args);
}

#else /* !PPS_KC_BIND */

static __inline int time_pps_kcbind(pps_handle_t handle,
					const int kernel_consumer,
					const int edge, const int tsformat)
{
	/* LinuxPPS doesn't implement kernel consumer feature */
	errno = EOPNOTSUPP;
	return -1;
}

#endif /* PPS_KC_BIND */

#endif /* _SYS_TIMEPPS_H_ */
-- 
1.8.4.3



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Reply to thread Export thread (mbox)