5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
27 .
/lib
/svc
/share
/smf_include.sh
28 .
/lib
/svc
/share
/ipf_include.sh
30 YPDIR
=/usr
/lib
/netsvc
/yp
32 create_client_ipf_rules
()
35 file=`fmri_to_file $FMRI $IPF_SUFFIX`
36 file6
=`fmri_to_file $FMRI $IPF6_SUFFIX`
37 iana_name
=`svcprop -p $FW_CONTEXT_PG/name $FMRI`
40 if [ -z "$domain" ]; then
44 if [ ! -d /var
/yp
/binding
/$domain ]; then
48 echo "# $FMRI" >$file6
50 ypfile
="/var/yp/binding/$domain/ypservers"
51 if [ -f $ypfile ]; then
52 tports
=`$SERVINFO -R -p -t -s $iana_name 2>/dev/null`
53 uports
=`$SERVINFO -R -p -u -s $iana_name 2>/dev/null`
54 tports_6
=`$SERVINFO -R -p -t6 -s $iana_name 2>/dev/null`
55 uports_6
=`$SERVINFO -R -p -u6 -s $iana_name 2>/dev/null`
59 for ypsvr
in `grep -v '^[ ]*#' $ypfile`; do
61 # Get corresponding IPv4/IPv6 addresses
63 servers
=`getent ipnodes $ypsvr | awk '/^:/{ print $1 }'`
64 servers_6
=`getent ipnodes $ypsvr | awk '/:/{ print $1 }'`
66 if [ -n "$servers" ]; then
67 server_addrs
="$server_addrs $servers"
70 if [ -n "$servers_6" ]; then
71 server_addrs_6
="$server_addrs_6 $servers"
75 if [ -n "$server_addrs" ]; then
76 for s
in $server_addrs; do
77 if [ -n "$tports" ]; then
78 for tport
in $tports; do
79 echo "pass in log quick" \
81 "to any port = $tport" \
86 if [ -n "$uports" ]; then
87 for uport
in $uports; do
88 echo "pass in log quick" \
90 "to any port = $uport" \
97 if [ -n "$server_addrs_6" ]; then
98 for s
in $server_addrs_6; do
99 if [ -n "$tports_6" ]; then
100 for tport
in $tports_6; do
101 echo "pass in log quick" \
102 "proto tcp from $s" \
103 "to any port = $tport" \
108 if [ -n "$uports_6" ]; then
109 for uport
in $uports_6; do
110 echo "pass in log quick" \
111 "proto udp from $s" \
112 "to any port = $uport" \
120 # How do we handle the client broadcast case? Server replies
121 # to the outgoing port that sent the broadcast, but there's
122 # no way the client know a packet is the reply.
124 # Nis server should be specified and clients shouldn't be
125 # doing broadcasts but if it does, no choice but to allow
128 echo "pass in log quick proto udp from any to any" \
129 "port > 32768" >>$file
130 echo "pass in log quick proto udp from any to any" \
131 "port > 32768" >>$file6
138 if [ -n "$1" -a "$1" = "ipfilter" ]; then
139 create_client_ipf_rules
$2
144 'svc:/network/nis/client:default')
147 if [ -z "$domain" ]; then
148 echo "$0: domainname not set"
149 exit $SMF_EXIT_ERR_CONFIG
152 if [ ! -d /var
/yp
/binding
/$domain ]; then
153 echo "$0: /var/yp/binding/$domain is not a directory"
154 exit $SMF_EXIT_ERR_CONFIG
157 # Since two ypbinds will cause ypwhich to hang...
158 if pgrep
-z `/sbin/zonename` ypbind
>/dev
/null
; then
159 echo "$0: ypbind is already running."
160 exit $SMF_EXIT_ERR_CONFIG
163 if [ -f /var
/yp
/binding
/$domain/ypservers
]; then
164 $YPDIR/ypbind
> /dev
/null
2>&1
166 $YPDIR/ypbind
-broadcast > /dev
/null
2>&1
170 if [ $rc != 0 ]; then
171 echo "$0: ypbind failed with $rc"
176 'svc:/network/nis/server:default')
179 if [ -z "$domain" ]; then
180 echo "$0: domainname not set"
181 exit $SMF_EXIT_ERR_CONFIG
184 if [ ! -d /var
/yp
/$domain ]; then
185 echo "$0: domain directory missing"
186 exit $SMF_EXIT_ERR_CONFIG
189 if [ -f /etc
/resolv.conf
]; then
196 if [ $rc != 0 ]; then
197 echo "$0: ypserv failed with $rc"
202 'svc:/network/nis/passwd:default')
203 PWDIR
=`grep "^PWDIR" /var/yp/Makefile 2> /dev/null` \
204 && PWDIR
=`expr "$PWDIR" : '.*=[ ]*\([^ ]*\)'`
205 if [ "$PWDIR" ]; then
206 if [ "$PWDIR" = "/etc" ]; then
212 $YPDIR/rpc.yppasswdd
$PWDIR -m
215 if [ $rc != 0 ]; then
216 echo "$0: rpc.yppasswdd failed with $rc"
222 echo "$0: Unknown service \"$SMF_FMRI\"."
223 exit $SMF_EXIT_ERR_CONFIG