LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 03-11-2006, 05:35 AM   #1
mchitrakar
Member
 
Registered: Mar 2004
Posts: 93
Blog Entries: 1

Rep: Reputation: 15
security prob for ftp userquota?


I want to change the home directory of ftp from /var/ftp/ to /ftp. but I will not be able to reformat or change the partition. Currently, the partitions I have are
/(30GB), /home ,/var(1GB),and swap. However, I am worried that users may over use the /ftp on / partiion. so I am putting the usrquota for /. however, is it possible to put usrquota and restrict ftp user only? will that restrict others functionalities in / partition. My main worry is for the security. will the home dir of ftp "/ftp" will have bad security conseqences ? currently, I am using vsftpd-1.1.3-8 and my linux installation is-red hat linux 9.
 
Old 03-12-2006, 09:08 AM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
I like to use container files instead of using disk quota. It presents less overhead to the operating system and if the container file gets filled it won't interfere with the operating system. Here is what I mean. In this case I will use loop devices. It might be better to use device mapper but I am just learning about that.

- Create a file that is as large as the maximum disk usage allowed for ftp.

- Connect the container file to a loop device.

- Format the loop device for your favorite file system.

- Mount the loop device at the point that you want to locate your ftp.

Note that this is about 3/4 of the steps needed to create an encrypted ftp (or any) file system. Here again device mapper would be better than using cryptoloop so I won't do the encryption part.

I am guessing from your post that you feel that you have more space on the root partition than on the var partition so we will make the container file on the root partition. Since we can't discuss this I'm going to say that if possible you would prefer to keep your ftp in /var/ftp just so that you don't have to change any scripts but you want to use the space on the root partition to do this. So let's make the /ftp area the place that we create our container file.
Code:
$ dd if=/dev/zero of=/ftp/container.file bs=1024 count=4096
That command will create a 4 megabyte file. You can adjust the numbers to fit your requirements. Note that people have different styles regarding how the size numbers are used. Some people might say bs=4000000 count=1 to make a more or less 4 megabyte size file. It makes more sense to me to use a byte size that is the typical size of a file system block but in reality it makes not difference at all.

Anyway now we have a 4 MB file in /ftp called container.file. (/ftp/container.file) Now we connect that file to a loop device.
Code:
$ losetup /dev/loop0 /ftp/container.file
Once we connect the container file to a loop device we can treat the container file just like a disk partition when we access the file through the loop device. Now we create a file system inside the container file through the loop device.
Code:
$ /sbin/mkreiserfs /dev/loop0
Initially you will want to mount the container file at a temporary mount point in order to transfer the contents of /var/ftp into the container file. Once that is done you can mount the container file using the old ftp directory as a mount point.

First make a little helper to let you quickly know that the container file is not mounted at /var/ftp.
Code:
$ touch /var/ftp/container.file.is.not.mounted
This way if you list the /var/ftp area and if you see that file you will know that the container file is not mounted. Now we mount the ftp container file.
Code:
$ mount /dev/loop0 /var/ftp
Now your ftp users can have the /var/ftp area as it always was, which may or may not be important to any scripts. I'm thinking of system admin scripts that you may or may not have running.

Now you can put a line in /etc/fstab to automatically mount this container file at /var/ftp when the system starts.
Code:
/ftp/container.file   /var/ftp   auto   loop,noexec,nosuid,users   0 0
I think that is basically the correct fstab line. I don't use a line in fstab because my loop file systems are encrypted and I don't automatically mount them when the system starts. You may have to play with the fstab line a bit. I don't know. Here is a line to manually mount the container file to /var/ftp.
Code:
$ mount -o loop /ftp/container.file /var/ftp
You can see that since the container file already has a file system we don't need to use the losetup utility. The -o loop option in the mount command will automatically choose the lowest numbered available loop device and make the connection to the container file for us. Of course you would want to add mount options like noexec, nosuid, noguid, and possibly others.

This approach is also possible for each individual user's home directory. If you have interactive users you can tailor each user's permitted disk space allowance without using disk quota by way of mounting a container file at each user's home directory. If a user fills up his/her container file it won't affect anybody else.

Last edited by stress_junkie; 03-12-2006 at 09:50 AM.
 
Old 03-16-2006, 11:04 AM   #3
mchitrakar
Member
 
Registered: Mar 2004
Posts: 93

Original Poster
Blog Entries: 1

Rep: Reputation: 15
thanks but ftp users also read lost+found

thanks for the help.definitely, my system will not now slow down since i wont be using quota as u have suggested that I need not. However,the /var/ftp behaved like a new partition (thats good, OK) but theere is added folder (normal ..I guesss) lost+found. Now, ftp users can even see that folder. Is there anyway somewhere to make normal users (ftp users) not see this folder??
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php/ftp overwriting files.. prob. collen Programming 1 03-14-2005 04:56 AM
ftp up/download permission prob Stex Linux - Networking 6 10-03-2003 01:23 PM
ftp security spate Linux - Software 1 01-19-2003 06:04 PM
FTP Security?? Milkman00 Linux - Software 3 08-10-2002 11:10 PM
FTP security ! chuck77 Linux - General 4 03-05-2002 12:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration