diff options
Diffstat (limited to 'patches/source/ntp')
-rw-r--r-- | patches/source/ntp/doinst.sh | 28 | ||||
-rwxr-xr-x | patches/source/ntp/ntp.SlackBuild | 158 | ||||
-rw-r--r-- | patches/source/ntp/ntp.conf | 72 | ||||
-rw-r--r-- | patches/source/ntp/ntp.keys | 2 | ||||
-rw-r--r-- | patches/source/ntp/ntp.nano.diff | 17 | ||||
-rw-r--r-- | patches/source/ntp/rc.ntpd | 71 | ||||
-rw-r--r-- | patches/source/ntp/slack-desc | 19 |
7 files changed, 367 insertions, 0 deletions
diff --git a/patches/source/ntp/doinst.sh b/patches/source/ntp/doinst.sh new file mode 100644 index 00000000..bc542990 --- /dev/null +++ b/patches/source/ntp/doinst.sh @@ -0,0 +1,28 @@ +config() { + NEW="$1" + OLD="`dirname $NEW`/`basename $NEW .new`" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} +preserve_perms() { + NEW="$1" + OLD="$(dirname ${NEW})/$(basename ${NEW} .new)" + if [ -e ${OLD} ]; then + cp -a ${OLD} ${NEW}.incoming + cat ${NEW} > ${NEW}.incoming + mv ${NEW}.incoming ${NEW} + fi + config ${NEW} +} + +config etc/ntp.conf.new +config etc/ntp/ntp.keys.new +if [ -r etc/rc.d/rc.ntpd -a -r etc/rc.d/rc.ntpd.new ]; then + chmod --reference=etc/rc.d/rc.ntpd etc/rc.d/rc.ntpd.new +fi +mv etc/rc.d/rc.ntpd.new etc/rc.d/rc.ntpd diff --git a/patches/source/ntp/ntp.SlackBuild b/patches/source/ntp/ntp.SlackBuild new file mode 100755 index 00000000..fef8d125 --- /dev/null +++ b/patches/source/ntp/ntp.SlackBuild @@ -0,0 +1,158 @@ +#!/bin/sh + +# Copyright 2008, 2009, 2010, 2011, 2012, 2014 Patrick J. Volkerding, Sebeka, MN, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PKGNAM=ntp +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +BUILD=${BUILD:-1_slack13.1} + +# Automatically determine the architecture we're building on: +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) export ARCH=i486 ;; + arm*) export ARCH=arm ;; + # Unless $ARCH is already set, use uname -m for all other archs: + *) export ARCH=$( uname -m ) ;; + esac +fi + +NUMJOBS=${NUMJOBS:-" -j7 "} + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" +elif [ "$ARCH" = "s390" ]; then + SLKCFLAGS="-O2" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" +else + SLKCFLAGS="-O2" +fi + +CWD=$(pwd) +TMP=${TMP:-/tmp} +PKG=$TMP/package-ntp + +rm -rf $PKG +mkdir -p $TMP $PKG +cd $TMP +rm -rf ntp-${VERSION}* +tar xvf $CWD/ntp-${VERSION}*.tar.?z* || exit 1 +cd ntp-${VERSION}* || exit 1 + +zcat $CWD/ntp.nano.diff.gz | patch -p1 --verbose || exit 1 + +chown -R root:root . +find . \ + \( -perm 2777 -o -perm 2755 -o -perm 2775 \) \ + -exec chmod u+rwx,g-sw,g+rx,o-w,o+rx {} \; -o \ + \( -perm 777 -o -perm 775 -o -perm 774 -o -perm 711 -o -perm 555 -o -perm 511 \) \ + -exec chmod u+rwx,g-sw,g+rx,o-w,o+rx {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ + -exec chmod 644 {} \; + +CFLAGS="$SLKCFLAGS" \ +./configure \ + --prefix=/usr \ + --localstatedir=/var \ + --sysconfdir=/etc \ + --bindir=/usr/sbin \ + --sbindir=/usr/sbin \ + --mandir=/usr/man \ + --docdir=/usr/doc/ntp-$VERSION \ + --htmldir=/usr/doc/ntp-$VERSION \ + --enable-ipv6 \ + --with-crypto \ + --program-prefix= \ + --program-suffix= \ + --build=$ARCH-slackware-linux + +make $NUMJOBS || make || exit 1 +make -i install DESTDIR=$PKG || exit 1 + +# Since the Makefile's install pays no heed to the --bindir settings, +# we'll move things to where they've always been ourselves: +mv $PKG/usr/bin/* $PKG/usr/sbin +rmdir $PKG/usr/bin + +# This might only be an empty directory: +rmdir $PKG/usr/lib/pkgconfig + +# This should be empty. Try to remove it, and error out if it's not actually empty: +rmdir $PKG/usr/libexec || exit 1 + +mkdir -p $PKG/etc/ntp +cat $CWD/ntp.conf > $PKG/etc/ntp.conf.new +cat $CWD/ntp.keys > $PKG/etc/ntp/ntp.keys.new +chmod 600 $PKG/etc/ntp/ntp.keys.new +touch $PKG/etc/ntp/step-tickers + +mkdir -p $PKG/etc/rc.d +cat $CWD/rc.ntpd > $PKG/etc/rc.d/rc.ntpd.new + +mv $PKG/usr/doc/ntp-$VERSION/*.html $PKG/usr/doc/ntp-$VERSION/html || exit 1 +cp -a \ + COPYRIGHT NEWS README* TODO WHERE-TO-START \ + *.y2kfixes clockstuff conf scripts \ + $PKG/usr/doc/ntp-$VERSION +mkdir $PKG/usr/doc/ntp-$VERSION/util +cp -a util/README $PKG/usr/doc/ntp-$VERSION/util +mkdir $PKG/usr/doc/ntp-$VERSION/ntpdate +cp -a ntpdate/README $PKG/usr/doc/ntp-$VERSION/ntpdate +( cd $PKG/usr/doc/ntp-$VERSION + find . -name ".deps*" -exec rm -rf "{}" \; 2> /dev/null +) + +# If there's a ChangeLog, installing at least part of the recent history +# is useful, but don't let it get totally out of control: +if [ -r ChangeLog ]; then + DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION) + cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog + touch -r ChangeLog $DOCSDIR/ChangeLog +fi + +# Strip binaries: +( cd $PKG + find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null + find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null +) + +# Compress and link manpages, if any: +if [ -d $PKG/usr/man ]; then + ( cd $PKG/usr/man + for manpagedir in $(find . -type d -name "man*") ; do + ( cd $manpagedir + for eachpage in $( find . -type l -maxdepth 1) ; do + ln -s $( readlink $eachpage ).gz $eachpage.gz + rm $eachpage + done + gzip -9 *.? + ) + done + ) +fi + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $TMP/ntp-$VERSION-$ARCH-$BUILD.txz + diff --git a/patches/source/ntp/ntp.conf b/patches/source/ntp/ntp.conf new file mode 100644 index 00000000..1844fb91 --- /dev/null +++ b/patches/source/ntp/ntp.conf @@ -0,0 +1,72 @@ +# Sample /etc/ntp.conf: Configuration file for ntpd. +# +# Undisciplined Local Clock. This is a fake driver intended for backup +# and when no outside source of synchronized time is available. The +# default stratum is usually 3, but in this case we elect to use stratum +# 0. Since the server line does not have the prefer keyword, this driver +# is never used for synchronization, unless no other other +# synchronization source is available. In case the local host is +# controlled by some external source, such as an external oscillator or +# another protocol, the prefer keyword would cause the local host to +# disregard all other synchronization sources, unless the kernel +# modifications are in use and declare an unsynchronized condition. +# +server 127.127.1.0 # local clock +fudge 127.127.1.0 stratum 10 + +# +# NTP server (list one or more) to synchronize with: +#server 0.pool.ntp.org iburst +#server 1.pool.ntp.org iburst +#server 2.pool.ntp.org iburst +#server 3.pool.ntp.org iburst + +# +# Drift file. Put this in a directory which the daemon can write to. +# No symbolic links allowed, either, since the daemon updates the file +# by creating a temporary in the same directory and then rename()'ing +# it to the file. +# +driftfile /etc/ntp/drift + +# +# Uncomment to use a multicast NTP server on the local subnet: +#multicastclient 224.0.1.1 # listen on default 224.0.1.1 +# Set an optional compensation for broadcast packet delay: +#broadcastdelay 0.008 + +# +# Keys file. If you want to diddle your server at run time, make a +# keys file (mode 600 for sure) and define the key number to be +# used for making requests. +# PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote +# systems might be able to reset your clock at will. +# +#keys /etc/ntp/keys +#trustedkey 65535 +#requestkey 65535 +#controlkey 65535 + +# +# Don't serve time or stats to anyone else by default (more secure) +restrict default limited kod nomodify notrap nopeer noquery +restrict -6 default limited kod nomodify notrap nopeer noquery + +# +# Use these lines instead if you do want to serve time and stats to +# other machines on the network: +#restrict default limited kod nomodify notrap nopeer +#restrict -6 default limited kod nomodify notrap nopeer + +# +# Disable the ntpdc -c monlist command, which is insecure and can be used +# to cause a denial of service attack (CVE-2013-5211). Future versions of +# NTP will remove this command. +# (this feature was disabled by default with ntpd 4.2.7p230) +disable monitor + +# +# Trust ourselves. :-) +restrict 127.0.0.1 +restrict ::1 + diff --git a/patches/source/ntp/ntp.keys b/patches/source/ntp/ntp.keys new file mode 100644 index 00000000..1c3fbd2c --- /dev/null +++ b/patches/source/ntp/ntp.keys @@ -0,0 +1,2 @@ +65535 M akey +1 M pass diff --git a/patches/source/ntp/ntp.nano.diff b/patches/source/ntp/ntp.nano.diff new file mode 100644 index 00000000..0ff361ce --- /dev/null +++ b/patches/source/ntp/ntp.nano.diff @@ -0,0 +1,17 @@ +--- ./include/ntp_syscall.h.orig 2009-12-09 01:36:37.000000000 -0600 ++++ ./include/ntp_syscall.h 2010-04-21 23:38:30.000000000 -0500 +@@ -14,6 +14,14 @@ + # include <sys/timex.h> + #endif + ++#if defined(ADJ_NANO) && !defined(MOD_NANO) ++#define MOD_NANO ADJ_NANO ++#endif ++ ++#if defined(ADJ_TAI) && !defined(MOD_TAI) ++#define MOD_TAI ADJ_TAI ++#endif ++ + #ifndef NTP_SYSCALLS_LIBC + #ifdef NTP_SYSCALLS_STD + # define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t)) diff --git a/patches/source/ntp/rc.ntpd b/patches/source/ntp/rc.ntpd new file mode 100644 index 00000000..c1d1411c --- /dev/null +++ b/patches/source/ntp/rc.ntpd @@ -0,0 +1,71 @@ +#!/bin/sh +# Start/stop/restart ntpd. + +# Start ntpd: +ntpd_start() { + CMDLINE="/usr/sbin/ntpd -g" + echo -n "Starting NTP daemon: $CMDLINE" + $CMDLINE -p /var/run/ntpd.pid + echo + # The kernel is now mocking around with the the hardware clock if + # ntpd is running, so if the hardware clock (wall clock) is set to + # 'localtime' execute hwclock --localtime --systohc to disable the + # 11 minute mode kernel function: + if [ -x /sbin/hwclock ]; then + # Check for a broken motherboard RTC clock (where ioports for rtc are + # unknown) to prevent hwclock causing a hang: + if ! grep -q -w rtc /proc/ioports ; then + CLOCK_OPT="--directisa" + fi + if ! grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then + echo "Saving system time to the hardware clock (localtime)." + /sbin/hwclock $CLOCK_OPT --localtime --systohc + fi + fi +} + +# Stop ntpd: +ntpd_stop() { + echo -n "Stopping NTP daemon..." + if [ -r /var/run/ntpd.pid ]; then + kill -HUP $(cat /var/run/ntpd.pid) + rm -f /var/run/ntpd.pid + else + killall -HUP -q ntpd + fi + echo +} + +# Restart ntpd: +ntpd_restart() { + ntpd_stop + sleep 1 + ntpd_start +} + +# Check if ntpd is running +ntpd_status() { + if [ -e /var/run/ntpd.pid ]; then + echo "ntpd is running." + else + echo "ntpd is stopped." + exit 1 + fi +} + +case "$1" in +'start') + ntpd_start + ;; +'stop') + ntpd_stop + ;; +'restart') + ntpd_restart + ;; +'status') + ntpd_status + ;; +*) + echo "usage $0 start|stop|restart|status" +esac diff --git a/patches/source/ntp/slack-desc b/patches/source/ntp/slack-desc new file mode 100644 index 00000000..6319e888 --- /dev/null +++ b/patches/source/ntp/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':'. + + |-----handy-ruler------------------------------------------------------| +ntp: ntp (Network Time Protocol daemon) +ntp: +ntp: The Network Time Protocol (NTP) is used to synchronize the time of a +ntp: computer client or server to another server or reference time source, +ntp: such as a radio or satellite receiver or modem. It provides client +ntp: accuracies typically within a millisecond on LANs and up to a few tens +ntp: of milliseconds on WANs relative to a primary server synchronized to +ntp: Coordinated Universal Time (UTC) via a Global Positioning Service +ntp: (GPS) receiver, for example. +ntp: +ntp: |