diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/openntpd/Makefile | 14 | ||||
-rw-r--r-- | net/openntpd/files/arc4random.c | 74 | ||||
-rw-r--r-- | net/openntpd/files/compat.h | 3 | ||||
-rw-r--r-- | net/openntpd/files/patch-Makefile | 6 |
4 files changed, 6 insertions, 91 deletions
diff --git a/net/openntpd/Makefile b/net/openntpd/Makefile index ea2ed99c36af..b21fd6f66fc6 100644 --- a/net/openntpd/Makefile +++ b/net/openntpd/Makefile @@ -18,20 +18,12 @@ GROUPS= _ntp USE_RC_SUBR= openntpd WRKSRC= ${WRKDIR}/ntpd -MAKE_JOBS_SAFE= yes MAN5= ntpd.conf.5 MAN8= ntpd.8 -.include <bsd.port.pre.mk> - -# requires adjtime(NULL, &olddelta) by unprivileged user -.if ${OSVERSION} < 700000 -IGNORE= is unsupported prior to FreeBSD 7.0 -.endif - post-extract: -.for i in compat.h adjfreq.c arc4random.c +.for i in compat.h adjfreq.c @${CP} ${FILESDIR}/$i ${WRKSRC} .endfor @@ -46,7 +38,7 @@ do-install: @${MKDIR} ${EXAMPLESDIR} ${INSTALL_DATA} ${FILESDIR}/ntpd.conf ${EXAMPLESDIR} @if [ ! -f ${PREFIX}/etc/ntpd.conf ]; then \ - ${CP} ${EXAMPLESDIR}/ntpd.conf ${PREFIX}/etc; \ + ${CP} ${EXAMPLESDIR}/ntpd.conf ${PREFIX}/etc; \ fi -.include <bsd.port.post.mk> +.include <bsd.port.mk> diff --git a/net/openntpd/files/arc4random.c b/net/openntpd/files/arc4random.c deleted file mode 100644 index f90d70e5bfde..000000000000 --- a/net/openntpd/files/arc4random.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 1999,2000,2004 Damien Miller <djm@mindrot.org> - * - * 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. - * - * $FreeBSD$ - */ - -#include <sys/param.h> - -#if __FreeBSD_version < 800041 - -#include <sys/types.h> -#include <limits.h> -#include <stdlib.h> - -#include "ntpd.h" - -/* - * Calculate a uniformly distributed random number less than upper_bound - * avoiding "modulo bias". - * - * Uniformity is achieved by generating new random numbers until the one - * returned is outside the range [0, 2**32 % upper_bound). This - * guarantees the selected random number will be inside - * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound) - * after reduction modulo upper_bound. - */ -u_int32_t -arc4random_uniform(u_int32_t upper_bound) -{ - u_int32_t r, min; - - if (upper_bound < 2) - return 0; - -#if (ULONG_MAX > 0xffffffffUL) - min = 0x100000000UL % upper_bound; -#else - /* Calculate (2**32 % upper_bound) avoiding 64-bit math */ - if (upper_bound > 0x80000000) - min = 1 + ~upper_bound; /* 2**32 - upper_bound */ - else { - /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */ - min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound; - } -#endif - - /* - * This could theoretically loop forever but each retry has - * p > 0.5 (worst case, usually far better) of selecting a - * number inside the range we need, so it should rarely need - * to re-roll. - */ - for (;;) { - r = arc4random(); - if (r >= min) - break; - } - - return r % upper_bound; -} - -#endif /* __FreeBSD_version */ diff --git a/net/openntpd/files/compat.h b/net/openntpd/files/compat.h index 47050687b460..eb15fb92d9fe 100644 --- a/net/openntpd/files/compat.h +++ b/net/openntpd/files/compat.h @@ -20,6 +20,3 @@ /* adjfreq.c */ int adjfreq(const int64_t *, int64_t *); - -/* arc4random.c */ -u_int32_t arc4random_uniform(u_int32_t); diff --git a/net/openntpd/files/patch-Makefile b/net/openntpd/files/patch-Makefile index bdf6f9a4aee1..488a8bdd7ff8 100644 --- a/net/openntpd/files/patch-Makefile +++ b/net/openntpd/files/patch-Makefile @@ -1,12 +1,12 @@ $FreeBSD$ ---- Makefile.orig 2009-11-23 20:27:18.000000000 +0100 -+++ Makefile 2009-11-23 20:29:05.000000000 +0100 +--- Makefile.orig 2009-06-25 16:14:54.000000000 +0200 ++++ Makefile 2013-08-01 17:33:37.000000000 +0200 @@ -2,7 +2,7 @@ PROG= ntpd SRCS= ntpd.c buffer.c log.c imsg.c ntp.c ntp_msg.c parse.y config.c \ - server.c client.c sensors.c util.c ntp_dns.c -+ server.c client.c util.c ntp_dns.c adjfreq.c arc4random.c ++ server.c client.c util.c ntp_dns.c adjfreq.c CFLAGS+= -Wall -I${.CURDIR} CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes CFLAGS+= -Wmissing-declarations |