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