1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-19 19:59:43 +00:00

* Fix out-of-bound string accesses.

* Fix %m GNUism in printf.
* Don't create the man page, it is already included.
* ptpd is not a user command, put it into sbin.
* Overhaul the startup file and move it to "ptpd".

Approved by:	gnn (maintainer)
This commit is contained in:
Christian Weisgerber 2008-11-13 22:17:28 +00:00
parent a2b69b9c69
commit 2042b740ed
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=222812
8 changed files with 86 additions and 164 deletions

View File

@ -7,7 +7,7 @@
PORTNAME= ptpd
DISTVERSION= 1.0.0
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net
MASTER_SITES= SF
MASTER_SITE_SUBDIR= ${PORTNAME}
@ -17,14 +17,14 @@ COMMENT= An implementation of the precision time protocol IEEE 1588
WRKSRC= ${WRKDIR}/ptpd-${DISTVERSION}/src
PLIST_FILES= bin/ptpd
PLIST_FILES= sbin/ptpd
USE_RC_SUBR= ptp
USE_RC_SUBR= ptpd
MAN8= ptpd.8
do-install::
${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${PREFIX}/bin
${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${PREFIX}/sbin
${INSTALL_MAN} ${WRKSRC}/${PORTNAME}.8 ${MANPREFIX}/man/man8
.include <bsd.port.mk>

View File

@ -1,13 +0,0 @@
Index: Makefile
===================================================================
--- Makefile (revision 45)
+++ Makefile (working copy)
@@ -1,7 +1,7 @@
# Makefile for ptpd
RM = rm -f
-CFLAGS = -Wall
+CFLAGS = -Wall -DBSD_INTERFACE_FUNCTIONS
#CPPFLAGS = -DPTPD_DBG -DPTPD_NO_DAEMON
PROG = ptpd

View File

@ -0,0 +1,11 @@
--- dep/constants_dep.h.orig
+++ dep/constants_dep.h
@@ -46,6 +46,8 @@
# define IFCONF_LENGTH 10
+# define BSD_INTERFACE_FUNCTIONS
+
# define adjtimex ntp_adjtime
# include <machine/endian.h>

View File

@ -0,0 +1,36 @@
--- dep/net.c.orig
+++ dep/net.c
@@ -8,26 +8,26 @@
/* set multicast group address based on subdomainName */
if (!memcmp(subdomainName, DEFAULT_PTP_DOMAIN_NAME, PTP_SUBDOMAIN_NAME_LENGTH))
- memcpy(subdomainAddress, DEFAULT_PTP_DOMAIN_ADDRESS, NET_ADDRESS_LENGTH);
+ strncpy(subdomainAddress, DEFAULT_PTP_DOMAIN_ADDRESS, NET_ADDRESS_LENGTH);
else if(!memcmp(subdomainName, ALTERNATE_PTP_DOMAIN1_NAME, PTP_SUBDOMAIN_NAME_LENGTH))
- memcpy(subdomainAddress, ALTERNATE_PTP_DOMAIN1_ADDRESS, NET_ADDRESS_LENGTH);
+ strncpy(subdomainAddress, ALTERNATE_PTP_DOMAIN1_ADDRESS, NET_ADDRESS_LENGTH);
else if(!memcmp(subdomainName, ALTERNATE_PTP_DOMAIN2_NAME, PTP_SUBDOMAIN_NAME_LENGTH))
- memcpy(subdomainAddress, ALTERNATE_PTP_DOMAIN2_ADDRESS, NET_ADDRESS_LENGTH);
+ strncpy(subdomainAddress, ALTERNATE_PTP_DOMAIN2_ADDRESS, NET_ADDRESS_LENGTH);
else if(!memcmp(subdomainName, ALTERNATE_PTP_DOMAIN3_NAME, PTP_SUBDOMAIN_NAME_LENGTH))
- memcpy(subdomainAddress, ALTERNATE_PTP_DOMAIN3_ADDRESS, NET_ADDRESS_LENGTH);
+ strncpy(subdomainAddress, ALTERNATE_PTP_DOMAIN3_ADDRESS, NET_ADDRESS_LENGTH);
else
{
h = crc_algorithm(subdomainName, PTP_SUBDOMAIN_NAME_LENGTH) % 3;
switch(h)
{
case 0:
- memcpy(subdomainAddress, ALTERNATE_PTP_DOMAIN1_ADDRESS, NET_ADDRESS_LENGTH);
+ strncpy(subdomainAddress, ALTERNATE_PTP_DOMAIN1_ADDRESS, NET_ADDRESS_LENGTH);
break;
case 1:
- memcpy(subdomainAddress, ALTERNATE_PTP_DOMAIN2_ADDRESS, NET_ADDRESS_LENGTH);
+ strncpy(subdomainAddress, ALTERNATE_PTP_DOMAIN2_ADDRESS, NET_ADDRESS_LENGTH);
break;
case 2:
- memcpy(subdomainAddress, ALTERNATE_PTP_DOMAIN3_ADDRESS, NET_ADDRESS_LENGTH);
+ strncpy(subdomainAddress, ALTERNATE_PTP_DOMAIN3_ADDRESS, NET_ADDRESS_LENGTH);
break;
default:
ERROR("handle out of range for '%s'!\n", subdomainName);

View File

@ -0,0 +1,11 @@
--- dep/ptpd_dep.h.orig
+++ dep/ptpd_dep.h
@@ -22,7 +22,7 @@
/* system messages */
#define ERROR(x, ...) fprintf(stderr, "(ptpd error) " x, ##__VA_ARGS__)
-#define PERROR(x, ...) fprintf(stderr, "(ptpd error) " x ": %m\n", ##__VA_ARGS__)
+#define PERROR(x, ...) fprintf(stderr, "(ptpd error) " x ": %s\n", ##__VA_ARGS__, strerror(errno))
#define NOTIFY(x, ...) fprintf(stderr, "(ptpd notice) " x, ##__VA_ARGS__)
/* debug messages */

View File

@ -1,122 +0,0 @@
--- /dev/null Tue Mar 4 13:24:31 2008
+++ ptpd.8 Mon Mar 3 16:58:16 2008
@@ -0,0 +1,119 @@
+.\" -*- nroff -*"
+.TH ptpd 8 "September 22, 2007" "version 1rc1" "Precision Time Protocol daemon"
+.SH NAME
+ptpd \- Precision Time Protocol daemon
+.SH SYNOPSIS
+.B ptpd
+
+[-?]
+[-c]
+[-f]
+[-d]
+[-D]
+[-x]
+[-t]
+[-a NUMBER,NUMBER]
+[-w NUMBER]
+[-b NAME]
+[-u ADDRESS]
+[-l NUMBER,NUMBER]
+[-o NUMBER]
+[-e NUMBER]
+[-y NUMBER]
+[-m NUMBER]
+[-g]
+[-p]
+[-s NUMBER]
+[-i NAME]
+[-v NUMBER]
+[-n NAME]
+[-k NUMBER,NUMBER]
+
+.SH DESCRIPTION
+Implements the Precision Time Protocol (PTP) as defined by the IEEE
+1588 standard. PTP was developed to provide very precise time
+coordination of LAN connected computers.
+.PP
+PTPd is a complete implementation of the IEEE 1588 specification for a
+standard (non-boundary) clock. PTPd has been tested with and is known
+to work properly with other IEEE 1588 implementations. The source code
+for PTPd is freely available under a BSD-style license. Thanks to
+contributions from users, PTPd is becoming an increasingly portable,
+interoperable, and stable IEEE 1588 implementation.
+.PP
+For more information, see http://ptpd.sourceforge.net/
+.SH OPTIONS
+.TP
+.B \-?
+display a short help text
+.TP
+.B \-c
+run in command line (non-daemon) mode
+.TP
+.B \-f FILE
+send output to FILE
+.TP
+.B \-d
+display stats
+.TP
+.B \-D
+display stats in .csv format
+.TP
+.B \-x
+do not reset the clock if off by more than one second
+.TP
+.B \-t
+do not adjust the system clock
+.TP
+.B \-a NUMBER,NUMBER
+specify clock servo P and I attenuations
+.TP
+.B \-w NUMBER
+specify one way delay filter stiffness
+.TP
+.B \-b NAME
+bind PTP to network interface NAME
+.TP
+.B \-u ADDRESS
+don't multicast, send messages unicast to ADDRESS
+.TP
+.B \-l NUMBER,NUMBER
+specify inbound, outbound latency in nsec
+.TP
+.B \-o NUMBER
+specify current UTC offset
+.TP
+.B \-e NUMBER
+specify epoch NUMBER
+.TP
+.B \-y NUMBER
+specify sync interval in 2^NUMBER sec
+.TP
+.B \-m NUMBER
+specify max number of foreign master records
+.TP
+.B \-g
+run as slave only
+.TP
+.B \-p
+make this a preferred clock
+.TP
+.B \-s NUMBER
+specify system clock stratum
+.TP
+.B \-i NAME
+specify system clock identifier
+.TP
+.B \-v NUMBER
+specify system clock allen variance
+.TP
+.B \-n NAME
+specify PTP subdomain name (not related to IP or DNS)
+.TP
+.B \-k NUMBER,NUMBER
+send a management message of key, record, then exit
+
+.SH AUTHOR
+Kendall Correll <kendall_c@users.sourceforge.net>. This manual page
+was written by Andrew Straw <strawman@astraw.com> for the Debian
+Project (but may be used by others).

View File

@ -1,25 +0,0 @@
#!/bin/sh
#
# $FreeBSD: /tmp/pcvs/ports/net/ptpd/files/Attic/ptp.in,v 1.1 2008-06-05 01:44:43 wxs Exp $
#
# PROVIDE: ptpd
# REQUIRE: NETWORKING DAEMON
#
# Add the following lines to /etc/rc.conf to enable ptpd
#
# ptpd_enable (bool): Set to "NO" by default
# Set it to "YES" to enable sshd
. %%RC_SUBR%%
name="ptpd"
rcvar=${name}_enable
if [ -n "${ptpd_flags}" ]; then
command="%%PREFIX%%/bin/${name} ${ptpd_flags}"
else
command="%%PREFIX%%/bin/${name}"
fi
load_rc_config $name
run_rc_command "$1"

24
net/ptpd/files/ptpd.in Normal file
View File

@ -0,0 +1,24 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: ptpd
# REQUIRE: NETWORKING DAEMON
# KEYWORD: nojail
#
# Add the following lines to /etc/rc.conf to enable ptpd
#
# ptpd_enable (bool): Set to "NO" by default
# Set it to "YES" to enable ptpd
. %%RC_SUBR%%
name="ptpd"
rcvar=`set_rcvar`
command="%%PREFIX%%/sbin/${name}"
ptpd_enable=${ptpd_enable:-"NO"}
load_rc_config $name
run_rc_command "$1"