Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got an ext3 filesystem sitting in a file, and I'd like to mount it to a local directory without sudo or any elevated permissions. Why? I'm creating a small filesystem for automated testing purposes. The automated tests run on machines I do not control, so there are some barriers to adding mount to sudoers.

Here's how I created the filesystem:

$ dd if=/dev/zero of=./50MB_partition count=102400
$ mkfs.ext3 -F 50MB_partition

Had I had permission, I could now mount it like so:

$ mkdir small_partition
$ sudo mount 50MB_partition ./small_partition

It seems that, because I own the filesystem and the mount point, there is no security risk associated with allowing me to mount this. I understand what is limiting me from calling mount without sudo; no explanation needed there. What I want to know is, is there a workaround that allows me to use my filesystem for testing purposes?

share|improve this question
add comment

2 Answers

mount requires mount() [defined in sys/mount.h] which, in turn, requires CAP_SYS_ADMIN, so you can't use mount() without a fstab entry or sudo.

might want to look into fuse (filesystem in userspace) [ http://fuse.sourceforge.net/ ]

share|improve this answer
    
Fuse is a good direction to look. In particular see fuse-ext2.sourceforge.net. –  Zoredache Jul 26 '11 at 22:18
    
Might you suggest mounting with pvfs2fuse or some such? –  Chris Betti Aug 3 '11 at 18:18
add comment

There is an option to mount to do this, owner, which also implies other options to prevent security violations.

owner

Allow an ordinary (i.e., non-root) user to mount the filesystem if he is the owner of the device. This option implies the options nosuid and nodev (unless overridden by subsequent options, as in the option line owner,dev,suid).

The problem is that it requires the "device" to be owned by you. There is no device in this case. The device (/dev/loopx) is automatically setup by mount, which requires root privileges, and then the device isn't owned by you.

Not sure how to work around that, unless, you can get a root user to use losetup and then chown the loop device to you.

It's also possible that this needs to be mentioned in /etc/fstab for the owner option to be accepted. Not sure since it isn't documented in the man page I have and I haven't tried it.

share|improve this answer
    
I tried to find a workaround for the losetup root user requirement. Doesn't look like there's something out there for that. Looks like the /etc/fstab mention isn't needed, though. –  Chris Betti Aug 3 '11 at 18:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.