#!/sbin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # 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" $conn_port $ipf_file generate_rules $FMRI $policy "tcp" $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