CVS commit: src/usr.sbin/ypserv/ypinit

2018-09-25 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Sep 25 09:53:40 UTC 2018

Modified Files:
src/usr.sbin/ypserv/ypinit: ypinit.8

Log Message:
New sentence, new line. Use An/Mt.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/ypserv/ypinit/ypinit.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ypserv/ypinit/ypinit.8
diff -u src/usr.sbin/ypserv/ypinit/ypinit.8:1.18 src/usr.sbin/ypserv/ypinit/ypinit.8:1.19
--- src/usr.sbin/ypserv/ypinit/ypinit.8:1.18	Sun Sep 23 02:15:25 2018
+++ src/usr.sbin/ypserv/ypinit/ypinit.8	Tue Sep 25 09:53:40 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ypinit.8,v 1.18 2018/09/23 02:15:25 kre Exp $
+.\"	$NetBSD: ypinit.8,v 1.19 2018/09/25 09:53:40 wiz Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -72,7 +72,8 @@ to contain a list of ypservers for
 to connect to.
 .It Fl l Ar server1,...,serverN
 Set the list of client servers from the command line rather than
-prompting for them interactively.  The format is a comma separated list
+prompting for them interactively.
+The format is a comma separated list
 of server names with no spaces.
 .It Fl m
 Create a master
@@ -124,7 +125,8 @@ servers to bind to.
 .Xr yppush 8 ,
 .Xr ypserv 8
 .Sh AUTHORS
-Originally written by Mats O Jansson
-.Aq m...@stacken.kth.se .
-Modified by Jason R. Thorpe
-.Aq thor...@netbsd.org .
+.An -nosplit
+Originally written by
+.An Mats O Jansson Aq Mt m...@stacken.kth.se .
+Modified by
+.An Jason R. Thorpe Aq Mt thor...@netbsd.org .



CVS commit: src/usr.sbin/ypserv/ypinit

2018-09-22 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Sep 23 02:15:25 UTC 2018

Modified Files:
src/usr.sbin/ypserv/ypinit: ypinit.8 ypinit.sh

Log Message:
Switch from getopt to getopts - and as part of that, update the usage,
and the man page, to reflect modern usage rather than some ancient style
that getopt[s] does not support (options, and their args when they exist)
always come before non-option agrs.

While here, update uses of test(1) to avoid obsolescent forms (and
even when still defined, prefer sh structures over test when possible).


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/ypserv/ypinit/ypinit.8
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/ypserv/ypinit/ypinit.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ypserv/ypinit/ypinit.8
diff -u src/usr.sbin/ypserv/ypinit/ypinit.8:1.17 src/usr.sbin/ypserv/ypinit/ypinit.8:1.18
--- src/usr.sbin/ypserv/ypinit/ypinit.8:1.17	Mon Jul  3 21:35:33 2017
+++ src/usr.sbin/ypserv/ypinit/ypinit.8	Sun Sep 23 02:15:25 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ypinit.8,v 1.17 2017/07/03 21:35:33 wiz Exp $
+.\"	$NetBSD: ypinit.8,v 1.18 2018/09/23 02:15:25 kre Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -36,17 +36,17 @@
 .Sh SYNOPSIS
 .Nm
 .Fl c
-.Op Ar domainname
 .Op Fl l Ar server1,...,serverN
+.Op Ar domainname
 .Nm
 .Fl m
-.Op Ar domainname
 .Op Fl l Ar server1,...,serverN
+.Op Ar domainname
 .Nm
 .Fl s
 .Ar master_server
-.Op Ar domainname
 .Op Fl l Ar server1,...,serverN
+.Op Ar domainname
 .Sh DESCRIPTION
 .Nm
 initializes the files and directories that are required for a

Index: src/usr.sbin/ypserv/ypinit/ypinit.sh
diff -u src/usr.sbin/ypserv/ypinit/ypinit.sh:1.13 src/usr.sbin/ypserv/ypinit/ypinit.sh:1.14
--- src/usr.sbin/ypserv/ypinit/ypinit.sh:1.13	Fri Jul 20 13:11:01 2018
+++ src/usr.sbin/ypserv/ypinit/ypinit.sh	Sun Sep 23 02:15:25 2018
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#	$NetBSD: ypinit.sh,v 1.13 2018/07/20 13:11:01 kre Exp $
+#	$NetBSD: ypinit.sh,v 1.14 2018/09/23 02:15:25 kre Exp $
 #
 # ypinit.sh - setup a master or slave YP server
 #
@@ -30,51 +30,44 @@ if [ $( ${ID} -u ) != 0 ]; then
 	exit 1
 fi
 
-args=$(getopt cl:ms: $*)		# XXX should switch to getopts
-if [ $? -eq 0 ]; then
-	set -- $args
-	for i; do
-		case $i in
-		"-c")
-			servertype=client
-			shift
-			;;
-		"-m")
-			servertype=master
-			shift
-			;;
-		"-s")
-			servertype=slave
-			master=${2}
-			shift
-			shift
-			;;
-		"-l")
-			noninteractive=yes
-			serverlist=${2}
-			shift
-			shift
-			;;
-		"--")
-			shift
-			break
-			;;
-		esac
-	done
+while getopts cl:ms: i
+do
+	case $i in
+	c)
+		servertype=client
+		;;
+	l)
+		noninteractive=yes
+		serverlist=${OPTARG}
+		;;
+	m)
+		servertype=master
+		;;
+	s)
+		servertype=slave
+		master=${OPTARG}
+		;;
+	\?)
+		echo >&2	# "Illegal option" message issued by getopts
+		servertype=	# force usage message just below
+		break
+		;;
+	esac
+done
+shift $((OPTIND - 1))
 
-	if [ $# -eq 1 ]; then
-		domain=${1}
-		shift;
-	else
-		domain=$( ${BIN_DOMAINNAME} )
-	fi
+if [ $# -eq 1 ]; then
+	domain=${1}
+	shift;
+else
+	domain=$( ${BIN_DOMAINNAME} )
 fi
 
 if [ -z ${servertype} ]; then
 	cat 1>&2 << __usage
-usage: 	${progname} -c [domainname] [-l server1,...,serverN]
-	${progname} -m [domainname] [-l server1,...,serverN]
-	${progname} -s master_server [domainname] [-l server1,...,serverN]
+usage: 	${progname} -c [-l server1,...,serverN] [domainname]
+	${progname} -m [-l server1,...,serverN] [domainname]
+	${progname} -s master_server [-l server1,...,serverN] [domainname]
 
 The \`-c' flag sets up a YP client, the \`-m' flag builds a master YP
 server, and the \`-s' flag builds a slave YP server.  When building a
@@ -104,14 +97,14 @@ __no_hostname
 
 	exit 1
 fi
-if [ "${servertype}" = "slave" -a "${host}" = "${master}" ]; then
+if [ "${servertype}" = slave ] && [ "${host}" = "${master}" ]; then
 	echo 1>&2 \
 	"$progname: cannot setup a YP slave server off the local host."
 	exit 1
 fi
 
 # Check if the YP directory exists.
-if [ ! -d ${yp_dir} -o -f ${yp_dir} ]; then
+if ! [ -d "${yp_dir}" ]; then
 	cat 1>&2 << __no_dir
 $progname: The directory ${yp_dir} does not exist.
 	Restore it from the distribution.
@@ -128,7 +121,7 @@ fi
 echo ""
 
 binding_dir=${yp_dir}/binding
-if [ ! -d ${binding_dir} ]; then
+if ! [ -d ${binding_dir} ]; then
 	cat 1>&2 << __no_dir
 $progname: The directory ${binding_dir} does not exist.
 	Restore it from the distribution.
@@ -152,13 +145,13 @@ When finished, press RETURN on a blank l
 
 __list_of_servers
 
-		if [ "${servertype}" != "client" ]; then
-			echo ${host} >> ${tmpfile}
+		if [ "${servertype}" != client ]; then
+			echo "${host}" >> ${tmpfile}
 			echo "	next host: ${host}";
 		fi
 		echo -n "	next host: ";
 
-		while read nextserver ; test -n "${nextserver}"
+		while read nextserver && test -n "${nextserver}"
 		do
 

CVS commit: src/usr.sbin/ypserv/ypinit

2018-07-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Jul 20 13:11:01 UTC 2018

Modified Files:
src/usr.sbin/ypserv/ypinit: ypinit.sh

Log Message:
PR bin/53458

Bring this script a little up to date - make it work with modern /bin/sh
(avoid HOSTNAME as a random variable) clean up trailing spaces on lines,
use $( ) instead of `` ...


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/ypserv/ypinit/ypinit.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ypserv/ypinit/ypinit.sh
diff -u src/usr.sbin/ypserv/ypinit/ypinit.sh:1.12 src/usr.sbin/ypserv/ypinit/ypinit.sh:1.13
--- src/usr.sbin/ypserv/ypinit/ypinit.sh:1.12	Tue Oct  5 11:35:35 2004
+++ src/usr.sbin/ypserv/ypinit/ypinit.sh	Fri Jul 20 13:11:01 2018
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#	$NetBSD: ypinit.sh,v 1.12 2004/10/05 11:35:35 tron Exp $
+#	$NetBSD: ypinit.sh,v 1.13 2018/07/20 13:11:01 kre Exp $
 #
 # ypinit.sh - setup a master or slave YP server
 #
@@ -10,27 +10,27 @@
 #
 
 PATH=/bin:/usr/sbin:/usr/bin:${PATH}
-DOMAINNAME=/bin/domainname
-HOSTNAME=/bin/hostname
+BIN_DOMAINNAME=/bin/domainname
+BIN_HOSTNAME=/bin/hostname
 ID=/usr/bin/id
 INSTALL=/usr/bin/install
 MAKEDBM=/usr/sbin/makedbm
 YPWHICH=/usr/bin/ypwhich
 YPXFR=/usr/sbin/ypxfr
 
-progname=`basename $0`
+progname=$( basename $0 )
 yp_dir=/var/yp
-tmpfile=`mktemp /tmp/ypservers.XX` || exit 1
+tmpfile=$(mktemp /tmp/ypservers.XX) || exit 1
 trap "rm -f ${tmpfile} ; exit 0" EXIT INT QUIT
 
 umask 077# protect created directories
 
-if [ `${ID} -u` != 0 ]; then
+if [ $( ${ID} -u ) != 0 ]; then
 	echo 1>&2 "$progname: you must be root to run this"
 	exit 1
 fi
 
-args=`getopt cl:ms: $*`
+args=$(getopt cl:ms: $*)		# XXX should switch to getopts
 if [ $? -eq 0 ]; then
 	set -- $args
 	for i; do
@@ -66,12 +66,12 @@ if [ $? -eq 0 ]; then
 		domain=${1}
 		shift;
 	else
-		domain=`${DOMAINNAME}`
+		domain=$( ${BIN_DOMAINNAME} )
 	fi
 fi
 
 if [ -z ${servertype} ]; then
-	cat 1>&2 << __usage 
+	cat 1>&2 << __usage
 usage: 	${progname} -c [domainname] [-l server1,...,serverN]
 	${progname} -m [domainname] [-l server1,...,serverN]
 	${progname} -s master_server [domainname] [-l server1,...,serverN]
@@ -95,7 +95,7 @@ __no_domain
 fi
 
 # Check if hostname is set, don't accept an empty hostname
-host=`${HOSTNAME}`
+host=$( ${BIN_HOSTNAME} )
 if [ -z "${host}" ]; then
 	cat 1>&2 << __no_hostname
 $progname: The local host's hostname has not been set.
@@ -258,7 +258,7 @@ master)
 		cp ${yp_dir}/Makefile.main ${yp_dir}/Makefile
 	fi
 
-	subdir=`grep "^SUBDIR=" ${yp_dir}/Makefile`
+	subdir=$(grep "^SUBDIR=" ${yp_dir}/Makefile)
 
 	if [ -z "${subdir}" ]; then
 		echo 1>&2 \
@@ -267,14 +267,14 @@ master)
 	fi
 
 	newsubdir="SUBDIR="
-	for dir in `echo ${subdir} | cut -c8-255`; do
+	for dir in $(echo ${subdir} | cut -c8-255); do
 		if [ "${dir}" != "${domain}" ]; then
 			newsubdir="${newsubdir} ${dir}"
 		fi
 	done
 	newsubdir="${newsubdir} ${domain}"
 
-	if [ -f ${yp_dir}/Makefile.tmp ]; then 
+	if [ -f ${yp_dir}/Makefile.tmp ]; then
 		rm ${yp_dir}/Makefile.tmp
 	fi
 
@@ -305,9 +305,9 @@ master)
 slave)
 	echo ""
 
-	maps=`${YPWHICH} -d ${domain} -h ${master} -f -m 2>/dev/null | \
+	maps=$( ${YPWHICH} -d ${domain} -h ${master} -f -m 2>/dev/null |
 	awk '{ if (substr($2, 1, length("'$master'")) == "'$master'") \
-		print $1; }'`
+		print $1; }' )
 
 	if [ -z "${maps}" ]; then
 		cat 1>&2 << __no_maps



CVS commit: src/usr.sbin/ypserv/ypinit

2013-07-19 Thread Hauke Fath
Module Name:src
Committed By:   hauke
Date:   Fri Jul 19 11:44:51 UTC 2013

Modified Files:
src/usr.sbin/ypserv/ypinit: Makefile.yp

Log Message:
Commit the patches in Wolfgang Stukenbrock's PR bin/41896.

(1) Do not serve UIDs below MINUID in master.passwd.* maps,
just like in passwd.* maps.

(2) Since stdethers(8) and stdhosts(8) strip comments, we do
not have to do it here, much less inconsistently.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/ypserv/ypinit/Makefile.yp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ypserv/ypinit/Makefile.yp
diff -u src/usr.sbin/ypserv/ypinit/Makefile.yp:1.21 src/usr.sbin/ypserv/ypinit/Makefile.yp:1.22
--- src/usr.sbin/ypserv/ypinit/Makefile.yp:1.21	Sat Oct  7 16:54:38 2006
+++ src/usr.sbin/ypserv/ypinit/Makefile.yp	Fri Jul 19 11:44:51 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.yp,v 1.21 2006/10/07 16:54:38 elad Exp $
+#	$NetBSD: Makefile.yp,v 1.22 2013/07/19 11:44:51 hauke Exp $
 #
 # This is the YP Makefile, used to create and push YP maps.
 #
@@ -112,12 +112,14 @@ passwd.time: ${DIR}/master.passwd
 			${MAKEDBM} - passwd.byuid; \
 		fi; \
 		${CAT} ${.ALLSRC} | \
-		${AWK} 'BEGIN { FS=:; OFS=\t; } /^[a-zA-Z0-9_]/ \
-		{ print $$1, $$0 }' - | ${SORT} | \
+		${AWK} -v minuid=${MINUID} \
+		'BEGIN { FS=:; OFS=\t; } /^[a-zA-Z0-9_]/ \
+		{ if (minuid = $$3) print $$1, $$0 }' - | ${SORT} | \
 		${MAKEDBM_S} - master.passwd.byname; \
 		${CAT} ${.ALLSRC} | \
-		${AWK} 'BEGIN { FS=:; OFS=\t; } /^[a-zA-Z0-9_]/ \
-		{ print $$3, $$0 }' - | ${SORT} | \
+		${AWK} -v minuid=${MINUID} \
+		'BEGIN { FS=:; OFS=\t; } /^[a-zA-Z0-9_]/ \
+		{ if (minuid = $$3) print $$3, $$0 }' - | ${SORT} | \
 		${MAKEDBM_S} - master.passwd.byuid; \
 		${TOUCH} ${.TARGET}; \
 		${ECHO} updated passwd; \
@@ -198,7 +200,7 @@ ${MAP}.time: ${AMDDIR}/${MAP} __makedbme
 
 ethers.time: ${DIR}/ethers
 	-@if [ -f ${.ALLSRC} ]; then \
-		${STDETHERS} ${.ALLSRC} | ${SED} -e s/#.*$$// | \
+		${STDETHERS} ${.ALLSRC} | \
 		${AWK} 'BEGIN { FS=\t; OFS=\t; } { print $$1, $$0 }' | \
 		${SORT} | ${MAKEDBM} - ethers.byaddr; \
 		${STDETHERS} ${.ALLSRC} | \
@@ -257,7 +259,7 @@ group.time: ${DIR}/group
 #
 hosts.time: ${DIR}/hosts
 	-@if [ -f ${.ALLSRC} ]; then \
-		${STDHOSTS} ${.ALLSRC} | ${SED} -e s/#.*$$// | \
+		${STDHOSTS} ${.ALLSRC} | \
 		${AWK} '{for (i = 2; i = NF; i++) print $$i, $$0 }' | \
 		${SORT} | ${MAKEDBM} - hosts.byname; \
 		${STDHOSTS} ${.ALLSRC} | \
@@ -279,7 +281,7 @@ hosts.time: ${DIR}/hosts
 
 ipnodes.time: ${DIR}/hosts
 	-@if [ -f ${.ALLSRC} ]; then \
-		${STDHOSTS} -n ${.ALLSRC} | ${SED} -e s/#.*$$// | \
+		${STDHOSTS} -n ${.ALLSRC} | \
 		${AWK} '{for (i = 2; i = NF; i++) print $$i, $$0 }' | \
 		${SORT} | ${MAKEDBM} - ipnodes.byname; \
 		${STDHOSTS} -n ${.ALLSRC} | \