Results 1 to 15 of 15
  1. #1
    Join Date
    Sep 2007
    Posts
    815

    Pure-ftpd, a way to modify ftp configuration to limit file size?

    Is there a way to limit the files of certain file types (like zip or rar) that are being uploaded through FTP?
    All things work together for the good of those who love God - Romans 8:28

  2. #2
    Hello Sharma,

    Yes you can limit file upload size via FTP check the configuration file /etc/vsftpd.conf


    Thank you

  3. #3
    I don't believe this can be done with the pure-ftpd config. Proftpd has a setting for "MaxStoreFileSize" which affects all files regardless of type.
    cPanel Hosting
    Site5.com - Best support in the hosting business!

  4. #4
    Join Date
    Feb 2008
    Location
    Houston, Texas, USA
    Posts
    2,955
    Quote Originally Posted by sharmaine1111 View Post
    Is there a way to limit the files of certain file types (like zip or rar) that are being uploaded through FTP?
    There's no direct support for this feature in pure-ftpd but it's possible to prevent certain files from being uploaded. pure-ftpd has a post-upload program that runs after each file is successfully uploaded and can run an external program. Here's the excerpt from the pure-ftpd manual:
    NAME
    pure-uploadscript - Automatically run an external program after a successful upload

    SYNTAX
    pure-uploadscript [-p </path/to/pidfile>] [-B] [-g <gid>] [-h] -r <program to run> [-u <uid>]
    So the <program to run> in our case can be a simple Bash script I'm going to call ban.sh

    #!/bin/bash

    uploaded_file=${1};
    banned_extensions="zip tar rar";

    for ext in ${banned_extensions};
    do
    count=$(echo ${uploaded_file}|grep -i ${ext}$|wc -l);
    if [ "${count}" -gt "0" ];
    then
    rm -f ${uploaded_file}; # File with banned extension detected. Delete it.
    break;
    fi;
    done
    So you start the program in the background like this:

    pure-uploadscript -p /var/run/pure-ftpd.pid -B -r /root/ban.sh
    Best
    UNIXy - Fully Managed Servers and Clusters - Established in 2006
    [ cPanel Varnish Nginx Plugin ] - Enhance LiteSpeed and Apache Performance
    www.unixy.net - Los Angeles | Houston | Atlanta | Rotterdam
    Love to help pro bono (time permitting). joe > unixy.net

  5. #5
    Join Date
    Sep 2007
    Posts
    815
    Thank you!

    I don't really do bash programming but is it also possible to limit file size of the uploaded files? Say FTP will not allow files => 2 GB to be uploaded?
    All things work together for the good of those who love God - Romans 8:28

  6. #6
    Join Date
    Sep 2007
    Posts
    815
    I would really hope that someone can help me in this matter...
    All things work together for the good of those who love God - Romans 8:28

  7. #7
    Join Date
    Feb 2008
    Location
    Houston, Texas, USA
    Posts
    2,955
    Quote Originally Posted by sharmaine1111 View Post
    I would really hope that someone can help me in this matter...
    You could implement the <2GB policy with the same script above just fine. It's one extra line.

    Regards
    UNIXy - Fully Managed Servers and Clusters - Established in 2006
    [ cPanel Varnish Nginx Plugin ] - Enhance LiteSpeed and Apache Performance
    www.unixy.net - Los Angeles | Houston | Atlanta | Rotterdam
    Love to help pro bono (time permitting). joe > unixy.net

  8. #8
    Join Date
    Sep 2007
    Posts
    815
    Hmmm.. I do not know bash script. Where do i add that piece of line? Meaning files more than 2GB will not be uploaded? I used to have a host before that does this. Thank you for your help
    All things work together for the good of those who love God - Romans 8:28

  9. #9
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    You can set the number of files and quota size as follows in the file /etc/pure-ftpd.conf. The following will limit the number of files the user can upload to 10000 and size to 2GB.
    Code:
    Quota                       10000:2000
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  10. #10
    Join Date
    Sep 2007
    Posts
    815
    Quote Originally Posted by david510 View Post
    You can set the number of files and quota size as follows in the file /etc/pure-ftpd.conf. The following will limit the number of files the user can upload to 10000 and size to 2GB.
    Code:
    Quota                       10000:2000
    Thank you. What if I dont want to limit the number of files a user can upload? I want to limit only the size that a user can upload

    Thanks
    All things work together for the good of those who love God - Romans 8:28

  11. #11
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    You can give it a huge value
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  12. #12
    Quote Originally Posted by linux-engineer View Post
    Hello Sharma,

    Yes you can limit file upload size via FTP check the configuration file /etc/vsftpd.conf


    Thank you
    vsftpd.conf is the configuration file for "very secure ftp server" which is totally different then pure-ftpd...

    anyways

    in your .conf file for pure-ftpd you can change these variables
    Code:
    # set max file size for downloads and uploads
    MaxRetrieveFileSize 10 Mb
    MaxStoreFileSize 4 Mb
    Last edited by icyshout; 07-21-2009 at 01:43 PM.

  13. #13
    Join Date
    Sep 2007
    Posts
    815
    icyshout, thank you

    # set max file size for downloads and uploads
    MaxRetrieveFileSize 10 Mb
    MaxStoreFileSize 4 Mb
    Can that handle "Gb" instead of "Mb"? Or do I need to convert it to Mb?

    Also is it per file or per IP? Say I set it to 10mb, so i can download each files with 10mb or less in file size?
    Last edited by sharmaine1111; 08-08-2009 at 11:03 PM.
    All things work together for the good of those who love God - Romans 8:28

  14. #14
    Quote Originally Posted by david510 View Post
    You can set the number of files and quota size as follows in the file /etc/pure-ftpd.conf. The following will limit the number of files the user can upload to 10000 and size to 2GB.
    Code:
    Quota                       10000:2000
    Ok so let's say I want to restrict the size of each file a person would upload, meaning they can upload 200,000 files which is fine, but each file cannot be larger than 50mb. Once they begin uploading via file manager or ftp it would error out after reaching the 50mb limit per file if they tried to per say upload a movie and share that from my server (600mb+ etc)?

  15. #15
    I just seen the response above, so in reality I can just change this in pureftp conf to this?

    # set max file size for downloads and uploads
    MaxRetrieveFileSize 99999 Mb
    MaxStoreFileSize 50 Mb

Similar Threads

  1. Pure-FTPD login not working -- /var/run/ftpd.sock?
    By jaseeey in forum Hosting Security and Technology
    Replies: 1
    Last Post: 11-09-2008, 08:33 AM
  2. File Size Limit
    By sbjafri in forum Dedicated Server
    Replies: 9
    Last Post: 08-11-2008, 03:12 PM
  3. Pure-ftpd crashing during file uploads
    By zymic in forum Hosting Security and Technology
    Replies: 2
    Last Post: 01-14-2008, 10:42 AM
  4. pure-ftpd temporary file
    By HD Fanatic in forum Hosting Security and Technology
    Replies: 2
    Last Post: 02-06-2007, 05:24 PM
  5. file size limit
    By xcpd in forum Hosting Security and Technology
    Replies: 6
    Last Post: 01-15-2006, 01:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •