summaryrefslogtreecommitdiff
path: root/etc/rc.d/yppasswdd
blob: 07b5263452bfbc7d0a070fa81104dd9fb97b922b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
#
# $OpenBSD: yppasswdd,v 1.3 2011/07/08 02:15:34 robert Exp $

daemon="/usr/sbin/rpc.yppasswdd"

. /etc/rc.d/rc.subr

rc_reload=NO

rc_pre() {
	[ X"`domainname`" != X"" -a -d /var/yp/`domainname` ] || \
		return 1
	_host1=`ypwhich -m passwd 2> /dev/null`
	_host2=`hostname`
	if [ `grep '^lookup' /etc/resolv.conf | grep yp | wc -c` -ne 0 ]; then
		_host1=`ypmatch $_host1 hosts | cut -d' ' -f2`
		_host2=`ypmatch $_host2 hosts | cut -d' ' -f2 | head -1`
	else
		_host1=`echo $_host1 | nslookup | grep '^Name: ' | \
			sed -e 's/^Name:    //'`
		_host2=`echo $_host2 | nslookup | grep '^Name: ' | \
			sed -e 's/^Name:    //'`
	fi
	[ "$_host2" != "$_host1" ] && return 1
	return 0
}

rc_cmd $1