xref: /illumos-gate/usr/src/cmd/smbsrv/smbd/svc-smbd (revision 7ddce99911fbb5e44b38ac65e991a22e42267ee9)
1eb1a3463STruong Nguyen#!/sbin/sh
2eb1a3463STruong Nguyen#
3eb1a3463STruong Nguyen# CDDL HEADER START
4eb1a3463STruong Nguyen#
5eb1a3463STruong Nguyen# The contents of this file are subject to the terms of the
6eb1a3463STruong Nguyen# Common Development and Distribution License (the "License").
7eb1a3463STruong Nguyen# You may not use this file except in compliance with the License.
8eb1a3463STruong Nguyen#
9eb1a3463STruong Nguyen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10eb1a3463STruong Nguyen# or http://www.opensolaris.org/os/licensing.
11eb1a3463STruong Nguyen# See the License for the specific language governing permissions
12eb1a3463STruong Nguyen# and limitations under the License.
13eb1a3463STruong Nguyen#
14eb1a3463STruong Nguyen# When distributing Covered Code, include this CDDL HEADER in each
15eb1a3463STruong Nguyen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16eb1a3463STruong Nguyen# If applicable, add the following below this CDDL HEADER, with the
17eb1a3463STruong Nguyen# fields enclosed by brackets "[]" replaced with your own identifying
18eb1a3463STruong Nguyen# information: Portions Copyright [yyyy] [name of copyright owner]
19eb1a3463STruong Nguyen#
20eb1a3463STruong Nguyen# CDDL HEADER END
21eb1a3463STruong Nguyen#
22eb1a3463STruong Nguyen# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23eb1a3463STruong Nguyen# Use is subject to license terms.
24eb1a3463STruong Nguyen#
25*7ddce999SHans Rosenfeld# Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
26*7ddce999SHans Rosenfeld#
27eb1a3463STruong Nguyen
28eb1a3463STruong Nguyen# Scripts that generate IPfilter rules for SMB server
29eb1a3463STruong Nguyen
30eb1a3463STruong Nguyen. /lib/svc/share/smf_include.sh
31eb1a3463STruong Nguyen. /lib/svc/share/ipf_include.sh
32eb1a3463STruong Nguyen
33eb1a3463STruong Nguyencreate_ipf_rules()
34eb1a3463STruong Nguyen{
35eb1a3463STruong Nguyen	FMRI=$1
36eb1a3463STruong Nguyen	file=`fmri_to_file $FMRI $IPF_SUFFIX`
37*7ddce999SHans Rosenfeld	file6=`fmri_to_file $FMRI $IPF6_SUFFIX`
38eb1a3463STruong Nguyen	policy=`get_policy ${FMRI}`
39eb1a3463STruong Nguyen	iana_names="microsoft-ds netbios-ns netbios-dgm netbios-ssn"
40eb1a3463STruong Nguyen
41eb1a3463STruong Nguyen	#
42eb1a3463STruong Nguyen	# Enforce policy on each port
43eb1a3463STruong Nguyen	#
44eb1a3463STruong Nguyen	echo "# $FMRI" >$file
45*7ddce999SHans Rosenfeld	echo "# $FMRI" >$file6
46eb1a3463STruong Nguyen	for name in $iana_names; do
47eb1a3463STruong Nguyen		port=`$SERVINFO -p -s $name 2>/dev/null`
48eb1a3463STruong Nguyen		if [ -z "$port" ]; then
49eb1a3463STruong Nguyen			continue;
50eb1a3463STruong Nguyen		fi
51*7ddce999SHans Rosenfeld		generate_rules $FMRI $policy "tcp" $port $file
52*7ddce999SHans Rosenfeld		generate_rules $FMRI $policy "tcp" $port $file6 _6
53*7ddce999SHans Rosenfeld		generate_rules $FMRI $policy "udp" $port $file
54*7ddce999SHans Rosenfeld		generate_rules $FMRI $policy "udp" $port $file6 _6
55eb1a3463STruong Nguyen	done
56eb1a3463STruong Nguyen}
57eb1a3463STruong Nguyen
58eb1a3463STruong Nguyenif [ "$1" = "ipfilter" ]; then
59eb1a3463STruong Nguyen	create_ipf_rules $2
60eb1a3463STruong Nguyenfi
61eb1a3463STruong Nguyenexit 0
62