Link to home
Start Free TrialLog in
Avatar of yosmc
yosmc

asked on

Is it possible to limit file size and restrict file types for a certain FTP account?

I would like to give one of our users FTP access to our server. Restricting him to just a certain directory is no problem, but I would also like to restrict the file size he may upload, the overall size of files in the directory as well as the type of files. Is that possible?

P.S. I'm on a virtual hosting account with CPanel installed. I do have shell access, but since it's only a virtual account, I might not have all the necessary access rights. Thanks anyway!
Avatar of Kelly Black
Kelly Black
Flag of United States of America image

Sure....man ulimit.

You can limit file size allowed in this manner in
/etc/services

Regards,

~K Black
Avatar of yosmc
yosmc

ASKER

Not sure if that'll work for me. I have a /etc folder on my account, but not an /etc/services - so if I created one I'm not sure if it would be effective.

Any way, what kind of file should I create, and put what inside?
If you want to pass parameters which limit file sizes
to the shell of the users you will need to set up the
/home/userid/.bashrc and .ftprc

Something like

ulimit -f filesize

should do it.

~K Black
Just google.com for ".bashrc" "ulimit -f" here's one of the
examples:

http://www.cs.uic.edu/~consult/how/startup_files/bashrc

Ftp can be similarly maintained.

Regards,

~K Black
Avatar of yosmc

ASKER

Thanks a lot for the advice, however - as I said - I only have a virtual account (=no server control), so I'm afraid I can't set up what you are describing here...
Sure you can. You can edit the .rc files in the users
home directory surely!!

~KB
Avatar of yosmc

ASKER

Ok, I created a file called .ftprc and put the line "ulimit -f 1" in it. I placed it in my root at /home/userid - but I can still upload all sizes of files.

Hope I don't seem incredibly stupid - obviously I'm doing something very wrong?
try

limit -f 1024

~KB

limit = ftp

ulimit = bash
Avatar of yosmc

ASKER

Ok, I created a file called .ftprc and put the line "ulimit -f 1" in it. I placed it in my root at /home/userid - but I can still upload all sizes of files.

Hope I don't seem incredibly stupid - obviously I'm doing something very wrong?
Avatar of yosmc

ASKER

(Sorry about the message above - it got re-posted when I pressed "refresh"...)

Tried it with "limit" instead of "ulimit" - unfortunately still no sign of success... :(
What ftp server are you using (proftp, pure-ftp etc.) ?
Avatar of yosmc

ASKER

How can I tell?
Well, you can see the processes that are running, you can ask support, or maybe you get a banner when you connect
Avatar of yosmc

ASKER

Thanks! :) It's PureFTPd 1.0.12.
The PureFTPd site is a http://www.pureftpd.org (big surprise :). With pureftpd it's possible to limit the number of files and the total size with virtual-quota (see http://www.pureftpd.org/README). I doubt that you can easily limit the size od one file (unless you allow just one file, in which case the total size would be the size of the file:) or the files by their type (no matter how you want to determine the file type)
Any news ?
Avatar of yosmc

ASKER

Big SORRY for taking so long to respond - a very busy time at my day-time job (I'm only a leisure-time webmaster) was followed by hardware problems on my home PC.

I looked at the info provided on the pureftpd site, but from my understanding it's something you can only do when you have the access/rights to configure & compile your server. With a virtual account, it seems like it's just not possible, because all I can do is set up new FTP accounts via CPanel, but this doesn't mean that I also have the rights to do the fine-tuning.
It seems like with this approach, I would need to have the rights to change files below my document root, which unfortunately I do not have.
ASKER CERTIFIED SOLUTION
Avatar of Mihai Barbos
Mihai Barbos
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yosmc

ASKER

Thanks mbardos. As my question was if it's possible, "no" is an acceptable answer as well, so I'm giving you the points. Equal thanks to kblack, if it was possible to split the points, I would do it, but unfortunately it's not possible either. :)