vsftp: anomymous can upload but not download

This bug seems to be here from a long time. Even if a patch exists, the bug is still here in the most recent version.
Here is the resolution (I assume gcc is installed):


  1. Stop your vsftpd daemon: service vsftpd stop
  2. Download the lastest source package (vsftpd-2.0.5 so far) from http://vsftpd.beasts.org.
  3. gunzip and untar

    # gunzip vsftpd-2.0.5.tar.gz
    # tar xf vsftpd-2.0.5.tar
    # cd vsftpd-2.0.5

  4. A couple of files must be changed

    1. postlogin.c, line 1831

      Replace


      ...
      if (p_sess->is_anonymous && tunable_chown_uploads)
      {
      vsf_sysutil_fchmod(new_file_fd, 0600);
      if (tunable_one_process_model)
      {
      ...

      by

      ...
      if (p_sess->is_anonymous && tunable_chown_uploads)
      {
      vsf_sysutil_fchmod(new_file_fd, (0666 & ~tunable_anon_umask));
      if (tunable_one_process_model)
      {
      ...


    2. tunable.c, line 129,130


      Replace


      /* -rw-rw-rw- */
      unsigned int tunable_file_open_mode = 0666;

      by

      /* -rw------- */
      unsigned int tunable_file_open_mode = 0600;


    3. builddefs.c, line 9


      Replace


      #undef VSF_BUILD_TCPWRAPPERS

      by

      #define VSF_BUILD_TCPWRAPPERS


    4. vsf_findlibs.sh


      This script doesn't work on 64 bits systems.
      I added


      [ `uname -m` == "x86_64" ] && LIB=lib64 || LIB=lib

      at the begining, and I replaced all
      locate_library /lib/ by
      locate_library /$LIB/
      and echo "/lib/libpam.so.0"; (line 17)
      by echo "/$LIB/libpam.so.0";

  5. Compile: make
  6. Replace /usr/sbin/vsftpd by the new version
  7. Restart your vsftpd daemon: service vsftpd start


Tested on RedHat Enterprise Linux 4 (32 and 64 bits)

Comments

Popular Posts