To be honest until recently I never gave much taught on FTPs way of working. Sure I’ve used it for a long time, and tried to minimize it’s use for an even longer period; but sometimes you just get things as granted.
Due to some events that took place last week I realized how leaky the FTP libraries actually are.
Now, some will disagree with me and I as well reflected much on this idea before posting it, I firmly believe that libraries are abstractions. Leaky abstractions, as we will shall see in a few moments.
As I was saying, last week we had to migrate our application to the “cloud” (whatever that means) and among the many things our application does there are a few batch processes that retrieve content for our application from different sources. Among those sources a couple of FTP servers can be counted.
Through the testing phase, we found out that several of these services broke, more precisely those which interacted with external FTP servers. It took us some time to realize that the issue was caused by the firewall sitting in front of our application which didn’t allow our application to use the privileged port 20.
As you could find out in a couple of seconds overcoming this problem is in most cases as simple as setting the FTP connection in passive mode. One line in three scripts and we where done:
Or were we?
Some may have known this, or would have read the whole page in the PHP manual, but setting the connection to passive mode has practically no effect if it is issued before the user is logged in. So the correct solution was:
If you would still like to say that the FTP library is a mere protocol implementation, just think that it offers non blocking procedures and handling of FTP SSL connections. The later being part of a different RFC than the FTP protocol.
And it does not stop here, even when people abstract further away the FTP library they still stick with the same leaked implementation detail. Sure, the command pattern would be a good candidate for a solution, but what argument could one give to make them add a bit more complexity in their abstraction for a disputable benefit.
No one, and that is why the current state of development consists of leaks all the way down.