Directory Group Permissions and VSFTP

I have just installed and setup vsftpd in standalone mode, with users but chroot’d by default with the exception of my own account.

I would like to share my external drive over the FTP server, which is a USB drive mounted in /media/external, with owner being my main account and group owner being users.

drwx------ 1 flatline users 12288 Sep 27 19:54 external

However it won’t allow any other user to navigate to this folder. They can’t navigate to it using ssh either, with a permission denied message. I tried creating a new group called sharing and then running the following command to change the group ownership. The edit time code did update though

chgrp sharing /media/external

but it seems to have no effect with the user group still staying as user. I’m running the command as root but have tried as the file owners account too. Chown doesn’t seem to work either.

I would also like to know how I can then create a link in another users home directory to allow then access to this external drive.

On 09/27/2011 09:26 PM, jkraw90 wrote:
> /media/external

try making the directory /media/external executable


DD
Caveat
openSUSE®, the “German Automobiles” of operating systems

And how would I go about doing that? And more importantly what does it actually do

drwx------ 1 flatline users 12288 Sep 27 19:54 external

As you have only the access bits for owner set, only the owner can do things there, regardless of the group.
You should have

drwxrwx--- 1 flatline users 12288 Sep 27 19:54 external

to allow all in group users access.
you can do this with

chmod g+rwx /media/external

Which is what I thought too but running any permission change, (e.g. chown, chmod, chgrp) doesn’t produce an error but doesn’t have an effect on the permission other than to change the edited timestamp.

I have tried making the changes under both the owner account, and root. Same result.

What kind of filesystem is on it? FAT? NTFS? Linux filesystem?

Yes, we ar of course allways supposing you use native Linux file systems, unless you tell us otherwise.

And please prove with computer evidence what you say. Thus when you say a chmod does not do anything, show us the whole session with the commands* ls -l,* chmod g+rwx and *ls -l *again.

And show with

mount[/mount]
what is mounted where as what.

Hi jkraw90,

As /media/external is the mount-point for your external disk which is I’m guessing formatted as fat or ntfs you will need to set the ownership and permissions when you mount the disk.

If you were mounting the disk manually you would control this via the command line (mounting the device with the options gid=xxx,umask=007) or via an entry in /etc/fstab where the options would be placed in the fourth field

I’m going to assume however that you’re allowing the disk to be mounted automatically via the system. This uses udev so you will need to ensure udev mounts the device using the options ENV{mount_options}="$env{mount_options},dmask=007,fmask=117,gid=xxx"

You’ll be able to find the group id for your new group using:

cat /etc/group | grep -i sharing | cut -f 3 -d :

from a console prompt - for for the group “users” rather than “sharing” this would usually be 100

I’ll try and test a couple of local rules tomorrow and post some samples for you:

In the meantime you might like to read this: Create your own udev rules to control removable devices - Ubuntu Forums

A point to note is that USB disks in performance terms aren’t great -In my experience, if you’re using the ftp server in a “LAN” environment and pulling large files you may get timeouts which usually cause the mount point to get dropped. I’ve certainly found trying to transfer any more than 1 high quality video file at a time via vsftpd on a Gigabit network difficult. Limiting to a single transfer is OK but not much use when you have lots of users…

Regards

Hi jkraw90,

A little more research shows this is more complicated!

it appears auto-mounting is now achieved via udisks and the default permissions are hard-coded so the only way to change them is to edit the source code and recompile - ugh!

However you can manually remount the disk with the correct options

My usb stick is mounted it’s uuid as it has no label so appears at /media/7CCF-F043

to remount with the required perms I run the following:

udisks --unmount /dev/disk/by-uuid/7CCF-F043
udisks --mount-options “dmask=007,fmask=117” --mount /dev/disk/by-uuid/7CCF-F043

I suspect your disk is being mounted by the label so you could try:

udisks --unmount /dev/disk/by-label/external
udisks --mount-options “dmask=007,fmask=117” --mount /dev/disk/by-label/external

If that works you could create a script to do this for you

vi ~/bin/remountusb.sh
i
#!/bin/bash
udisks --unmount /dev/disk/by-label/external
udisks --mount-options “dmask=007,fmask=117” --mount /dev/disk/by-label/external
:wq
chmod u+x ~/bin/remountusb.sh

running remountusb.sh from the command line would then be easier

Hope that helps & very sorry it seams complicated - sometimes new features are oversimplified, I’m sure someone has put in a feature request to allow “udisks” permissions to be configurable. If not perhaps you’d like to ask?

Cool!
A topic I’ve only recently been doing a little research on!
(Beware my current knowledge on this topic is limited)

You might find the following udev wiki page useful which I’ve referenced many times
http://wiki.archlinux.org/index.php/Udev

In it, you’ll not only find an entire section that applies only to USB devices, you might also find interesting that apparently the properties and attributes of the auto-mounted device is based on discovery of the type of device and seems to be defined in a “wrapper” and generally speaking that wrapper can be customized.

HTH,
Tony

audiocomp’s solution looks promising in that it does change the permissions, problem is that it sets drive owner and group to the current, which has to be root cause any other account gets a Authorization Required message.

I tried adding gid=1000,uid=1000 into the command making it;


udisks --mount-options "dmask=007,fmask=117,uid=1000,gid=1000" --mount /dev/disk/by-uuid/7CCF-F043

but that just gets an error that gid and uid are not supported mount options, which I always thought they were.

tsu2’s solutions looks promising by creating a custom wrapper, and I have had some mixed results playing around with it. Gonna take some more research on how it works before I can make it work properly though.

Eventually I gave up trying to sort this and dealing with udisks stupid hard-coded design and simply removed udisks which can be done with


zypper rm udisks

I can then mount the drive with whatever permissions I want in fstab. There doesn’t seem to be any adverse effects to removing udisks, other than having to resort to the old system for mounting usb, but I don’t count that as adverse. If I come across any though I’ll be sure to post back.

On 2011-10-06 23:56, jkraw90 wrote:

> I can then mount the drive with whatever permissions I want in fstab.
> There doesn’t seem to be any adverse effects to removing udisks, other
> than having to resort to the old system for mounting usb, but I don’t
> count that as adverse. If I come across any though I’ll be sure to post
> back.

I find automatic mounting of usb drives useful, but I also use manual
mounting via fstab. At least in gnome, when an external drive is defined in
fstab, gnome does not mount it automatically, the fstab entries are
respected. So I get the best of those worlds.

I think that does not happens with kde, but haven’t verified it myself.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

That’s interesting cause I have a friend running 11.4 who says he always just uses fstab, and has never had to use udisks in any form however when I tried just adding a line in fstab to override udisks it didn’t seem to make a difference to the mount, and the mount ended up with the same permissions udisks was always assigning it.

The line I was using, and currently am using, in fstab is;


/dev/sdb1    /media/external    ntfs-3g    uid=1000,gid=1000,umask=007,fmask=007,dmask=007    0 0

Hm, strange.

Like Carlos, my idea is that an fstab entry overrules any “automatic” mounting. It did so allready with HAL and AFAIK this is still the case and Carlos (and several others) confirms this. Also the same is true in KDE as it is IMHO desktop independent.

And about your fstab entry: many problems on many threads about permissions using ntfs (being a non-Linux file system that must mimic permissions in one way or the other) were solved by using the single option defaults instead of the long range you have. Just a suggestion.

On 2011-10-07 11:26, hcvv wrote:
>
> Hm, strange.
>
> Like Carlos, my idea is that an -fstab- entry overrules any “automatic”
> mounting. It did so allready with HAL and AFAIK this is still the case
> and Carlos (and several others) confirms this. Also the same is true in
> KDE as it is IMHO desktop independent.

I read at least of one person for which it doesn’t work in KDE. I have not
investigated it.

> And about your -fstab- entry: many problems on many threads about
> permissions using ntfs (being a non-Linux file system that must mimic
> permissions in one way or the other) were solved by using the single
> option -defaults- instead of the long range you have. Just a suggestion.

It is also solved by using the proper options :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

It is also solved by using the proper options :slight_smile:

Of course. According to the man page defaults means

Use default options: rw, suid, dev, exec, auto, nouser, and async.
.

On 2011-10-07 14:36, hcvv wrote:
>
>> It is also solved by using the proper options :slight_smile:
> Of course. According to the -man- page -defaults- means
>> Use default options: rw, suid, dev, exec, auto, nouser, and async…

I just change the options that YaST uses with fmask=0117,dmask=0007, and it
works.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)