N2200 User Patch FTPDPORTS

Facts

 * Name: FTPDPORTS
 * Maintainer: Misha Verplak
 * ftpd changes: Fabrice Martin
 * Target: N2200 / N0204
 * Latest version: 1.1

Description
From Fabrice: I have experimented with the option "FTP explicit mode", which enables secure FTP using TLS, so that it is possible to open the nas on the internet.

However, TheCus has forgotten one important feature: to be able to specify a range of passive ports to be opened in the firewall/router. Otherwise, it is necessary to open every port from 1024 to 65535, which obviously is not recommended.

Using ROOTCMD, I've found that the server is Pureftpd, and its configuration lies in /app/bin/rc/. I've corrected rc.ftpd so that only ports 50000:50100 should be opened.

I've found a simple way to enable the fix. In fact, /etc/ is persistent. So I modified the startup script "rc" in /etc/cfg to replace /app/bin/rc/rc.ftpd with a new one.

From Misha: Modified slightly to handle situations where the file contents may vary. See "How it works" below.

Forum article: ftpd fix for passive ports for firewall/router

Installation
Copy the contents of the following file into ROOTCMD tweak.ftpd.passive.ports.rc.sh

How this works

 * 1) The script makes a backup of /etc/cfg/rc
 * 2) It then uses "sed" to add a line into "rc", before the call to rc.ftpd.

On the next reboot and following reboots:
 * 1) /etc/cfg/rc  is run by the system.
 * 2) The extra line in rc uses "sed" to add the port numbers after each $ssl entry on lines running the ftpd.
 * 3) rc calls the rc.ftpd script as normal.

Features

 * Sets ftp passive ports range to 50000:50100.
 * Used "sed" to alter the ftpd config file on startup, aiming to be compatible with other changes.

News

 * 2010-04-09: First version uploaded to NAS Central.
 * 2010-04-25: Simplified to a single script (also discovered the -i option for sed).

Versions

 * Version 1.1
 * Release date: 2010-04-25
 * Works on firmware: 3.00.08
 * Download (zip): N2200-FTPDPORTS-1.1.zip
 * Major changes: simplified to one script.

N2200 User Patches