137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering#!/usr/sbin/sh
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering#
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# CDDL HEADER START
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering#
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# The contents of this file are subject to the terms of the
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# Common Development and Distribution License (the "License").
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# You may not use this file except in compliance with the License.
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering#
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# or http://www.opensolaris.org/os/licensing.
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# See the License for the specific language governing permissions
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# and limitations under the License.
d6bc8348d5be8576a475ac8ced2b0146e60fb71fDaniel Buch#
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# When distributing Covered Code, include this CDDL HEADER in each
92eab5dea40f50d0e66b91ba1224e2101bc83494Michal Sekletar# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
92eab5dea40f50d0e66b91ba1224e2101bc83494Michal Sekletar# If applicable, add the following below this CDDL HEADER, with the
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# fields enclosed by brackets "[]" replaced with your own identifying
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# information: Portions Copyright [yyyy] [name of copyright owner]
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering#
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering# CDDL HEADER END
137243fd130149ce22071d22c7de95bf46c7079cLennart Poettering#
#
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
#
. /lib/svc/share/ipf_include.sh
create_ipf_rules()
{
FMRI=$1
ipf_file=`fmri_to_file ${FMRI} $IPF_SUFFIX`
nat_file=`fmri_to_file ${FMRI} $NAT_SUFFIX`
policy=`get_policy ${FMRI}`
#
# Ftp uses two ports, ftp and ftp-data, see /etc/services which
# is why it's necessary to have this custom method.
#
conn_port=`$SERVINFO -p -t -s ftp 2>/dev/null`
data_port=`$SERVINFO -p -t -s ftp-data 2>/dev/null`
echo "# $FMRI" >$ipf_file
generate_rules $FMRI $policy "tcp" "any" $conn_port $ipf_file
generate_rules $FMRI $policy "tcp" "any" $data_port $ipf_file
# Generate a custom NAT rule here to use the ftp-proxy
#
echo "# $FMRI" >$nat_file
echo "rdr * any -> 0/32 proxy port ftp ftp/tcp" >>$nat_file
}
case "$1" in
'ipfilter')
create_ipf_rules $2
;;
*)
echo "Usage: $0 ipfilter"
;;
esac
exit 0