summaryrefslogtreecommitdiff
path: root/network/sntpc
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2022-01-26 15:33:58 -0500
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2022-01-30 08:36:00 +0700
commitd17bca972e018b295b8f887af0c3967ba99d4cf5 (patch)
treeebbe2f9db0d1046ede7433762faed3ba3b892f1d /network/sntpc
parentb5e76f14590bd2128436521f7c44a1100e6fb02a (diff)
downloadslackbuilds-d17bca972e018b295b8f887af0c3967ba99d4cf5.tar.gz
network/sntpc: Added (simple NTP client).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network/sntpc')
-rw-r--r--network/sntpc/README4
-rw-r--r--network/sntpc/compilefix.diff45
-rw-r--r--network/sntpc/git2tarxz.sh44
-rw-r--r--network/sntpc/slack-desc19
-rw-r--r--network/sntpc/sntpc.198
-rw-r--r--network/sntpc/sntpc.SlackBuild76
-rw-r--r--network/sntpc/sntpc.info10
-rw-r--r--network/sntpc/sntpc.rst87
8 files changed, 383 insertions, 0 deletions
diff --git a/network/sntpc/README b/network/sntpc/README
new file mode 100644
index 0000000000..97fd73a838
--- /dev/null
+++ b/network/sntpc/README
@@ -0,0 +1,4 @@
+sntpc (simple Network Time Protocol client)
+
+This client queries an NTP server for the current time, and sets the
+local clock to the time reported by the server.
diff --git a/network/sntpc/compilefix.diff b/network/sntpc/compilefix.diff
new file mode 100644
index 0000000000..e56b2a70a7
--- /dev/null
+++ b/network/sntpc/compilefix.diff
@@ -0,0 +1,45 @@
+diff -Naur sntpc-20181113_1ca1d00/sntpc.c sntpc-20181113_1ca1d00.patched/sntpc.c
+--- sntpc-20181113_1ca1d00/sntpc.c 2022-01-26 14:17:03.000000000 -0500
++++ sntpc-20181113_1ca1d00.patched/sntpc.c 2022-01-26 14:29:36.384241954 -0500
+@@ -7,9 +7,12 @@
+ #include <strings.h>
+ #include <sys/select.h>
+ #include <sys/socket.h>
++#include <time.h>
+ #include <sys/time.h>
+ #include <unistd.h>
+
++extern uint32_t arc4random(void);
++
+ #define SECONDS_1900_1970 (25567 * 86400U)
+
+ #pragma pack(1)
+@@ -56,10 +59,6 @@
+ errx(1, "Structure size mismatch (got %lu, expected 68)", sizeof(struct ntp_packet_t));
+ }
+
+- if (pledge("stdio inet dns settime", NULL) < 0) {
+- err(1, "pledge");
+- }
+-
+ int ch;
+ while ((ch = getopt(argc, argv, "bhnp:s:t:v")) != -1) {
+ switch (ch) {
+@@ -184,7 +183,7 @@
+
+ time_t local_now = time(NULL);
+ if (verbose) {
+- printf("sntpc: local clock %lld (%.24s)\n", local_now, ctime(&local_now));
++ printf("sntpc: local clock %ld (%.24s)\n", local_now, ctime(&local_now));
+ }
+ if (local_now > seconds_since_1970 && !backwards) {
+ errx(1, "not stepping clock backwards (use -b to allow this)");
+@@ -205,7 +204,7 @@
+ err(1, "settimeofday");
+ }
+ if (verbose) {
+- printf("sntpc: local clock set to %lld (%.24s)\n", new_clock.tv_sec, ctime(&new_clock.tv_sec));
++ printf("sntpc: local clock set to %ld (%.24s)\n", new_clock.tv_sec, ctime(&new_clock.tv_sec));
+ }
+ } else {
+ printf("sntpc: not setting clock because of -n\n");
diff --git a/network/sntpc/git2tarxz.sh b/network/sntpc/git2tarxz.sh
new file mode 100644
index 0000000000..08bbd6a489
--- /dev/null
+++ b/network/sntpc/git2tarxz.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# Create source tarball from git repo, with generated version
+# number.
+
+# Note that this script doesn't need to be run as root. It does
+# need to be able to write to the current directory it's run from.
+
+# Takes one optional argument, which is the commit or tag to create
+# a tarball of. With no arg, HEAD is used.
+
+PRGNAM=sntpc
+CLONE_URL=https://github.com/ghewgill/sntpc
+
+set -e
+
+GITDIR=$( mktemp -dt $PRGNAM.git.XXXXXX )
+rm -rf $GITDIR
+git clone $CLONE_URL $GITDIR
+
+CWD="$( pwd )"
+cd $GITDIR
+
+if [ "$1" != "" ]; then
+ git reset --hard "$1" || exit 1
+fi
+
+GIT_SHA=$( git rev-parse --short HEAD )
+
+DATE=$( git log --date=format:%Y%m%d --format=%cd | head -1 )
+
+VERSION=${DATE}_${GIT_SHA}
+
+rm -rf .git
+find . -name .gitignore -print0 | xargs -0 rm -f
+
+cd "$CWD"
+rm -rf $PRGNAM-$VERSION $PRGNAM-$VERSION.tar.xz
+mv $GITDIR $PRGNAM-$VERSION
+tar cvfJ $PRGNAM-$VERSION.tar.xz $PRGNAM-$VERSION
+
+echo
+echo "Created tarball: $PRGNAM-$VERSION.tar.xz"
+echo "VERSION=$VERSION"
diff --git a/network/sntpc/slack-desc b/network/sntpc/slack-desc
new file mode 100644
index 0000000000..20b8d8bd67
--- /dev/null
+++ b/network/sntpc/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 ':' except on otherwise blank lines.
+
+ |-----handy-ruler------------------------------------------------------|
+sntpc: sntpc (simple Network Time Protocol client)
+sntpc:
+sntpc: This client queries an NTP server for the current time, and sets the
+sntpc: local clock to the time reported by the server.
+sntpc:
+sntpc:
+sntpc:
+sntpc:
+sntpc:
+sntpc:
+sntpc:
diff --git a/network/sntpc/sntpc.1 b/network/sntpc/sntpc.1
new file mode 100644
index 0000000000..1bdf3d638f
--- /dev/null
+++ b/network/sntpc/sntpc.1
@@ -0,0 +1,98 @@
+.\" Man page generated from reStructuredText.
+.
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.TH "SNTPC" 1 "2022-01-26" "20181113_1ca1d00" "SlackBuilds.org"
+.SH NAME
+sntpc \- Network Time Protocol client
+.\" RST source for sntpc(1) man page. Convert with:
+.
+.\" rst2man.py sntpc.rst > sntpc.1
+.
+.\" rst2man.py comes from the SBo development/docutils package.
+.
+.SH SYNOPSIS
+.sp
+sntpc [\fB\-bhnv\fP] [\fB\-p\fP \fIport\fP] [\fB\-s\fP \fIserver\fP] [\fB\-t\fP \fIthreshold\fP]
+.SH DESCRIPTION
+.sp
+\fBsntpc\fP queries an NTP server for the current time, and sets the
+local clock to the time reported by the server. It\(aqs a standalone
+binary, with no config file and no dependency on the \fIntp\fP package.
+.sp
+\fBsntpc\fP does not run as a daemon like \fBntpd\fP does. To keep
+the time in sync, you can run \fBsntpc\fP from root\(aqs \fBcrontab\fP(1)
+every 30 minutes (or however often it\(aqs necessary).
+.sp
+\fBsntpc\fP requires root access to actually set the local clock,
+although it can be run with \fB\-n\fP by non\-privileged users (e.g. with
+\fB\-v\fP to simply check the local time against the server\(aqs time).
+.SH OPTIONS
+.INDENT 0.0
+.TP
+.B \-b
+Allow time shift backwards (default: forward only).
+.TP
+.B \-h
+Show built\-in help message.
+.TP
+.B \-n
+No set time (dry run).
+.TP
+.B \-p
+Set server port number (default: 123).
+.TP
+.B \-s
+Set server name or IPv4 address (default: pool.ntp.org).
+.TP
+.B \-t
+Set maximum time offset threshold (default: 300 seconds). This can
+be set to a ludicrously high value such as 40000000000 (over 1,000 years)
+to effectively disable the threshold.
+.TP
+.B \-v
+Verbose (default: silent)
+.UNINDENT
+.SH COPYRIGHT
+.sp
+See the file /usr/doc/sntpc\-20181113_1ca1d00/LICENSE.txt for license information.
+.SH AUTHORS
+.sp
+sntpc was written by Greg Hewgill.
+.sp
+This man page written for the SlackBuilds.org project
+by B. Watson, and is licensed under the WTFPL.
+.SH SEE ALSO
+.sp
+\fBntpd\fP(1)
+.sp
+\fI\%https://www.ntp.org\fP
+.sp
+The sntpc homepage: \fI\%https://github.com/ghewgill/sntpc\fP
+.\" Generated by docutils manpage writer.
+.
diff --git a/network/sntpc/sntpc.SlackBuild b/network/sntpc/sntpc.SlackBuild
new file mode 100644
index 0000000000..70659d2018
--- /dev/null
+++ b/network/sntpc/sntpc.SlackBuild
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+# Slackware build script for sntpc
+
+# Written by B. Watson (yalhcru@gmail.com)
+
+# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
+
+cd $(dirname $0) ; CWD=$(pwd)
+
+PRGNAM=sntpc
+VERSION=${VERSION:-20181113_1ca1d00}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+PKGTYPE=${PKGTYPE:-tgz}
+
+if [ -z "$ARCH" ]; then
+ case "$( uname -m )" in
+ i?86) ARCH=i586 ;;
+ arm*) ARCH=arm ;;
+ *) ARCH=$( uname -m ) ;;
+ esac
+fi
+
+if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
+ echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
+ exit 0
+fi
+
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+if [ "$ARCH" = "i586" ]; then
+ SLKCFLAGS="-O2 -march=i586 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+else
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+fi
+
+set -e
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf $PRGNAM-$VERSION
+tar xvf $CWD/$PRGNAM-$VERSION.tar.xz
+cd $PRGNAM-$VERSION
+chown -R root:root .
+chmod 644 *
+
+# Linux doesn't have BSD's pledge() syscall... also fix compile warnings.
+patch -p1 < $CWD/compilefix.diff
+
+make CFLAGS="$SLKCFLAGS -Wall -Wl,-s" LDFLAGS="-lbsd"
+
+mkdir -p $PKG/usr/sbin
+cp -a $PRGNAM $PKG/usr/sbin
+
+PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
+mkdir -p $PKGDOC
+cp -a *.md *.txt $PKGDOC
+cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
diff --git a/network/sntpc/sntpc.info b/network/sntpc/sntpc.info
new file mode 100644
index 0000000000..9f8aba8b92
--- /dev/null
+++ b/network/sntpc/sntpc.info
@@ -0,0 +1,10 @@
+PRGNAM="sntpc"
+VERSION="20181113_1ca1d00"
+HOMEPAGE="https://github.com/ghewgill/sntpc"
+DOWNLOAD="https://slackware.uk/~urchlay/src/sntpc-20181113_1ca1d00.tar.xz"
+MD5SUM="21640d86c27e27838966f0b620399cca"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES="libbsd"
+MAINTAINER="B. Watson"
+EMAIL="yalhcru@gmail.com"
diff --git a/network/sntpc/sntpc.rst b/network/sntpc/sntpc.rst
new file mode 100644
index 0000000000..b040bb7da6
--- /dev/null
+++ b/network/sntpc/sntpc.rst
@@ -0,0 +1,87 @@
+.. RST source for sntpc(1) man page. Convert with:
+.. rst2man.py sntpc.rst > sntpc.1
+.. rst2man.py comes from the SBo development/docutils package.
+
+.. |version| replace:: 20181113_1ca1d00
+.. |date| date::
+
+=====
+sntpc
+=====
+
+----------------------------
+Network Time Protocol client
+----------------------------
+
+:Manual section: 1
+:Manual group: SlackBuilds.org
+:Date: |date|
+:Version: |version|
+
+SYNOPSIS
+========
+
+sntpc [**-bhnv**] [**-p** *port*] [**-s** *server*] [**-t** *threshold*]
+
+DESCRIPTION
+===========
+
+**sntpc** queries an NTP server for the current time, and sets the
+local clock to the time reported by the server. It's a standalone
+binary, with no config file and no dependency on the *ntp* package.
+
+**sntpc** does not run as a daemon like **ntpd** does. To keep
+the time in sync, you can run **sntpc** from root's **crontab**\(1)
+every 30 minutes (or however often it's necessary).
+
+**sntpc** requires root access to actually set the local clock,
+although it can be run with **-n** by non-privileged users (e.g. with
+**-v** to simply check the local time against the server's time).
+
+OPTIONS
+=======
+
+-b
+ Allow time shift backwards (default: forward only).
+
+-h
+ Show built-in help message.
+
+-n
+ No set time (dry run).
+
+-p
+ Set server port number (default: 123).
+
+-s
+ Set server name or IPv4 address (default: pool.ntp.org).
+
+-t
+ Set maximum time offset threshold (default: 300 seconds). This can
+ be set to a ludicrously high value such as 40000000000 (over 1,000 years)
+ to effectively disable the threshold.
+
+-v
+ Verbose (default: silent)
+
+COPYRIGHT
+=========
+
+See the file /usr/doc/sntpc-|version|/LICENSE.txt for license information.
+
+AUTHORS
+=======
+
+sntpc was written by Greg Hewgill.
+
+This man page written for the SlackBuilds.org project
+by B. Watson, and is licensed under the WTFPL.
+
+SEE ALSO
+========
+
+**ntpd**\(1)
+
+https://www.ntp.org
+
+The sntpc homepage: https://github.com/ghewgill/sntpc