Monday, September 14, 2015

Configuring vsftpd to support proxy FTP


I've had to deal with a legacy application that is hard coded to use proxy ftp sessions. These are initiated by using the "proxy" command in a stock ftp client.

It was giving us trouble with vsftpd refusing to transfer files when using "proxy get" to initiate a passive session between the vsftpd server and another server.

What is a proxy FTP? In a nutshell, a proxy session lets you open a connection to a second FTP server, so that you can transfer files between both servers from instead of between the primary server and your FTP client.

The ftp(1) man page documents what "proxy" does. It is important to read it and understand what happens when you use this:
     proxy ftp-command
                 Execute an ftp command on a secondary control connection.
                 This command allows simultaneous connection to two remote ftp
                 servers for transferring files between the two servers.  The
                 first proxy command should be an open, to establish the sec-
                 ondary control connection.  Enter the command "proxy ?" to
                 see other ftp commands executable on the secondary connec-
                 tion.  The following commands behave differently when pref-
                 aced by proxy: open will not define new macros during the
                 auto-login process, close will not erase existing macro defi-
                 nitions, get and mget transfer files from the host on the
                 primary control connection to the host on the secondary con-
                 trol connection, and put, mput, and append transfer files
                 from the host on the secondary control connection to the host
                 on the primary control connection.  Third party file trans-
                 fers depend upon support of the ftp protocol PASV command by
                 the server on the secondary control connection.

So how does this impact vsftpd when using it to handle the primary control connection?

The first thing that might happen is that if you issue a proxy get, it might  fail with the following message:
500 Illegal PORT command

This is fixed by adding the following parameter to vsftpd.conf:
port_promiscuous=YES
What this parameter does is authroize vsftpd to open a data connection with the proxy server, instead of limiting it between vsftpd and the FTP client.

Then, you might get:
500 OOPS: vsf_sysutil_bind

This happens because the vsftpd process is trying to bind to port 20 to the IP address of the server. By stracing the process, I found out that this does not work because the vsftpd process that handles communication with clients is unprivileged. This privilege separation is by design. The workaround I found is to add this to vsftpd.conf:
connect_from_port_20=NO

This makes vsftpd bind to another port (I didn't even check which one) but it works. By default it is set to "NO", but it is left to "YES" in the example configuration file and thus why it was there in the first place.

Good luck

Monday, July 20, 2015

Updating a Magellan Triton 500's GPS chip firmware

I've been recently trying to restart using a circa-2008 GPS I own, a Magellan Triton 500. Back when I purchased it, it was so frustrating to use that I gave up. It's time for a rematch.

There used to be a english forum with lots of information on these, but it closed some years ago. Whatever was in this forum is lost forever (and no, the web archive didn't save the posts, only the thread subjects).

There are still tidbits of info scattered here and there, however. Many in russian and german though, which requires running them through a translator, with mixed results. I might try to put a comprehensive page in the future in this blog in case they go down, too.

In the mean time, here is the best hack available for this unit.  I found an interesting post in a German board that explains how to flash an unofficial driver for the SiRFstar III GPS chip that updates its software from GSW 3.2.4 to 3.5.0 and it increases the unit's sensitivity considerably. The details are here:
http://www.magellanboard.de/viewtopic.php?f=35&t=4343

Here is how to do this.

1. Download this file here:
http://maps4me.net/tools/Triton500_UPD1.95_SIRF.zip
P.S. maps4me offers many maps for the triton for a one-time download fee, I suggest you check it out.

2. Extract the zip file.

3. Turn OFF your GPS (this is important, if it's already turned on when you plug it in, the GPS driver will fail to install)

4. Run MgnFwUpd.exe

5. NOW plug your GPS, turn it on, and run the update. It takes at least 30 minutes to complete.

6. Tada! The about -> version page should show GSW3.5.0 for SiRF.

I've tested this on Windows 8.1 and it still works even if the software was probably designed for XP.

For advanced users: If you don't want SiRF 3.5.0, there is a way to update from 3.2.4 to 3.2.5 using official Magellan code. I requires downloading the latest firmware update to 1.95 from Magellan, running their update, finding out the temporary directory where it extracts its data, then modifying MgnFWUpd.xml to uncomment the line mgnFWGpsChipUpdate version. I tried it but didn't find 3.2.5 to be very useful.