Prevent user to read files from vfat filesystems - but allow to write

0

0

Its possible do that? I want to mount a flash drive(vfat) in linux and the user be able to write to it but not to read.

I've tried:

mount /dev/sdb1 /media/mpoint -o fmask=0444

but no results. After that I'm still able to read the files in the flash drive.

Raydel Miranda

Posted 2014-04-30T14:33:24.063

Reputation: 139

I voted up - thinking about it, the question is actually pretty interesting. – Volker Siegel – 2014-07-24T11:20:54.540

I thought about a more complicated approach to solve it, and wrote another independent answer (deleted the old) - but I think it's much more effort than you planned for. But if you're interested, I could try to find a suitable file system. – Volker Siegel – 2014-07-25T17:18:49.097

What operating system exactly? – Ramhound – 2014-04-30T14:35:35.737

Sorry, I forgot specify about that, is linux. – Raydel Miranda – 2014-04-30T14:38:06.877

Why the down vote? I need some explanation if some of you think I'm doing something wrong or my question is bad. – Raydel Miranda – 2014-04-30T15:45:04.737

Answers

1

To solve that, you obviously need a better permission system than a FAT file system provides. That can be solved by using an overlay filesystem:

The FAT filesystem is mounted normally, and not accessible at all for the user.
The permissions are handled by a file system that stores it's files just as files on the FAT filesystem - but can implement additional features, like a permission system.
(I do not know which filesystem would match your needs - but I assume there is more than one that could be used, ignoring most of their features.)

That overlay- or union filesystem is what the user will access, and where you can set restricted permissions.
The permission system would be just the normal Unix/Linux style.
Using that, you can just set write-only permissions on all files and directories.
To navigate a directory, the user does not need to list the file- and directory names in it; But he needs to access the involved directories themselves - . and ...

You can allow just what he needs with a special kind of permission: Directories have the x permission like files - but are not executable in the first place. This unused directory execute permission is used to handle just what you need. If the r bit is not set, but the x is, the user can still read just the little bit he needs here.

Then, the user can not list them, but he can make use of directories he knows himself. He can **cd into** known directories.

To set the right permissions for new files, set a restrictive umask for the user.

Volker Siegel

Posted 2014-04-30T14:33:24.063

Reputation: 1 188

This looks very interesnting, suppose I want to use "ext3" as filesystem, can you post an example? Is this supported in the kernel or is just for one distribution (Ubuntu, for instance). – Raydel Miranda – 2014-07-28T12:50:37.117