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