Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

For a user process, I want to mount a directory in other location but in user space without root privilieges. Something like mount --bind /origin /dest, but with a vfs wrapper. Like a usermode fine-tuned chroot.

The program would wrapper the syscalls to files to "substitute" the paths needed. It could be called with a command line like:

bindvfs /fake-home:/home ls /home

I am sure that this alredy exists! :)

share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

You can use PRoot almost the same way as in your example:

proot -b /fake-home:/home ls /home

Unlike BindFS/FUSE, PRoot is able to bind over files and directories you don't own.

share|improve this answer
    
Perfect, that is exactly what I was thinking on –  Keymon Aug 27 '12 at 16:49
    
Some other ptrace-based approaches -- unix.stackexchange.com/a/72697/4319 . –  imz -- Ivan Zakharyaschev Apr 17 '13 at 3:34
add comment

The parrot program can do what you ask for: intercept system calls and redirect certain paths (e.g., all paths starting with /anonftp are remapped to transparently access remote files over FTP). It also runs entirely in userspace.

However, despite an impressive array of common and uncommon network protocols, parrot does not have any module to do simple filesystem->filesystem rewriting like you ask for. That should be quite simple to add, if you know some C language programming.

Alternatively, bindfs (which runs on top of FUSE), works like a mount --bind in userspace. (But this goes in the reverse direction relative to re-directing /home to /fake-home as you mention in your question.)

share|improve this answer
    
I did not knwon that program, parrot. I will mail them. –  Keymon Sep 10 '10 at 6:54
add comment

VFS already allows for non-root mounting of filesystems. You can add the user or users option to the fstab entry and make sure vfs.usermount=1 is in /etc/sysctl.

None of this will give you chroot-like controls however. The bind option isn't going to change permissions or allow for an 'alternate' access, this is a second mtab entry for the same exact filesystem and contents. Modifications in the bind mount affect the original.

I'd make sure you clarify your end goal before moving further.

share|improve this answer
    
Well imagine this situation: I have a precompiled program, that I can not recompile. This program access to a fixed path, like '~/.program-data' and I need to launch several instances of the program as user, without doing chroot. Of course I could create a chrooted environment and use fakechroot, but it is too complex. –  Keymon Sep 10 '10 at 6:56
1  
So in that instance you are trying to provide a shared location (like /var/program-data) for users to all access as ~/.program-data when running said program? Or are you trying to provide separate copies of ~/.program-data to each instance of a program run by the same user? –  nzwulfin Sep 15 '10 at 15:35
    
Both situations are ok. If can be by process instance, better. –  Keymon Sep 30 '11 at 14:37
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.