tech@,

This allows the use of a /etc/ftp-proxy.conf file, containing
argument lines which will be fed to ftp-proxy one by one.
This solves the case of having to start multiple ftp-proxy
instances at startup.

I've retained the original behavior in order not to break things
should this go in, it can go away later I guess (or should it
go right now ?).

Thoughts ?

        - pyr

Index: etc/rc
===================================================================
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.341
diff -u -p -r1.341 rc
--- etc/rc      6 Sep 2010 17:10:19 -0000       1.341
+++ etc/rc      23 Sep 2010 11:15:13 -0000
@@ -99,6 +99,22 @@ wsconsctl_conf()
        done
 }
 
+ftpproxy_conf()
+{
+       test -s /etc/ftp-proxy.conf || return
+
+       # delete comments and blank lines
+       local save_IFS="$IFS"
+       IFS="
+"
+       set -- `stripcom /etc/ftp-proxy.conf`
+       IFS="$save_IFS"
+       while [ $# -ge 1 ]; do
+               ftp-proxy $1
+               shift
+       done
+}
+
 random_seed()
 {
        if [ -f /var/db/host.random -a "X$random_seed_done" = "X" ]; then
@@ -751,7 +767,10 @@ if [ X"${ftpd_flags}" != X"NO" ]; then
        echo -n ' ftpd';                /usr/libexec/ftpd ${ftpd_flags}
 fi
 
-if [ X"${ftpproxy_flags}" != X"NO" ]; then
+if [ X"${ftpproxy}" = X"YES" ]; then
+       ftpproxy_conf
+       echo -n ' ftp-proxy';
+elif [ X"${ftpproxy_flags}" != X"NO" ]; then
        echo -n ' ftp-proxy';           /usr/sbin/ftp-proxy ${ftpproxy_flags}
 fi
 
Index: etc/rc.conf
===================================================================
RCS file: /cvs/src/etc/rc.conf,v
retrieving revision 1.139
diff -u -p -r1.139 rc.conf
--- etc/rc.conf 29 Jul 2010 13:55:48 -0000      1.139
+++ etc/rc.conf 23 Sep 2010 11:15:13 -0000
@@ -38,7 +38,8 @@ lpd_flags=NO          # for normal use: "" (or "
 sensorsd_flags=NO      # for normal use: ""
 hotplugd_flags=NO      # for normal use: ""
 watchdogd_flags=NO     # for normal use: ""
-ftpproxy_flags=NO      # for normal use: ""
+ftpproxy=NO            # for normal use: "" (needs /etc/ftp-proxy.conf)
+ftpproxy_flags=NO      # for normal use: "" (runs a single ftp-proxy)
 hostapd_flags=NO       # for normal use: ""
 ifstated_flags=NO      # for normal use: ""
 relayd_flags=NO                # for normal use: ""
Index: usr.sbin/ftp-proxy/ftp-proxy.8
===================================================================
RCS file: /cvs/src/usr.sbin/ftp-proxy/ftp-proxy.8,v
retrieving revision 1.14
diff -u -p -r1.14 ftp-proxy.8
--- usr.sbin/ftp-proxy/ftp-proxy.8      21 Nov 2009 13:59:31 -0000      1.14
+++ usr.sbin/ftp-proxy/ftp-proxy.8      23 Sep 2010 11:15:13 -0000
@@ -172,6 +172,7 @@ anchor "ftp-proxy/*"
 pass in quick proto tcp to port ftp rdr-to 127.0.0.1 port 8021
 .Ed
 .Sh SEE ALSO
+.Xr ftp-proxy.conf 5 ,
 .Xr ftp 1 ,
 .Xr pf 4 ,
 .Xr pf.conf 5
Index: usr.sbin/ftp-proxy/ftp-proxy.conf.5
===================================================================
RCS file: usr.sbin/ftp-proxy/ftp-proxy.conf.5
diff -N usr.sbin/ftp-proxy/ftp-proxy.conf.5
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ usr.sbin/ftp-proxy/ftp-proxy.conf.5 23 Sep 2010 11:15:13 -0000
@@ -0,0 +1,53 @@
+.\"     $OpenBSD$
+.\"
+.\" Copyright (c) 2010 Pierre-Yves Ritschard <[email protected]>
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate$
+.Dt FTP-PROXY.CONF 5
+.Os
+.Sh NAME
+.Nm ftp-proxy.conf
+.Nd configuration of multiple ftp-proxy instances at startup
+.Sh DESCRIPTION
+.Nm
+contains a list of
+.Xr ftp-proxy 8
+arguments is read at system startup by
+.Xr rc 8
+during the boot sequence.
+.Pp
+The file is made up of
+.Xr ftp-proxy 8
+argument lines.
+Each line corresponds to a separate ftp-proxy instances which will
+be started.
+Comments are designated by a hash mark.
+Blank lines are ignored.
+.Sh FILES
+.Bl -tag -width /etc/ftp-proxy.conf -compact
+.It Pa /etc/ftp-proxy.conf
+.El
+.Sh EXAMPLES
+To start a generic instance for outbound ftp which will bind on
+10.0.0.1 and listens on the 8021 tcp port as well as a specific
+instance forwarding inbound ftp to the 10.0.0.2 internal host
+listening on the 8022 tcp port, one would use the following lines:
+.Bd -literal -offset indent
+-a 10.0.0.1
+-R 10.0.0.2 -p 8022
+.Ed
+.Sh SEE ALSO
+.Xr rc 8 ,
+.Xr ftp-proxy 8
Index: usr.sbin/ftp-proxy/Makefile
===================================================================
RCS file: /cvs/src/usr.sbin/ftp-proxy/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- usr.sbin/ftp-proxy/Makefile 26 Nov 2006 11:31:13 -0000      1.3
+++ usr.sbin/ftp-proxy/Makefile 23 Sep 2010 11:15:13 -0000
@@ -2,7 +2,7 @@
 
 PROG=  ftp-proxy
 SRCS=  ftp-proxy.c filter.c
-MAN=   ftp-proxy.8
+MAN=   ftp-proxy.8 ftp-proxy.conf.5
 
 CFLAGS+= -I${.CURDIR}
 CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \

Reply via email to