1

How can I disallow a user from moving/renaming a subdirectory of this home directory?

Even if a user doesn't have any rights on a directory, it can rename/move it as long as the source and destination parent directory are writable.

I had a similar problem on macosx. Users inadvertently drag&drop the "Library" folder somewhere else breaking everything as there are applications depending on that path.

I don't it would be better to depend on another path, outside the home dir, or use ".files" but I have a legacy situation.

I tried to fix the problem my putting the dir somewhere else and then making a "bind" mount

mount -o bind sourcepath /home/user/somedir

It prevents the renaming of the dir:

mv: cannot move `somedir' to `somethingelse': Device or resource busy

Does anybody know an easier way?

1 Answer 1

2

Easiest is probably using chattr:

sudo mkdir /home/user/somedir
sudo chown root:root /home/user/somedir
sudo chattr +i /home/user/somedir
4
  • Does this require mounting with extended attributes? Does Ubuntu mount with xattrs by default? Nov 1, 2010 at 19:04
  • ok it solves the problem for me since I don't have to let the user create direct children in this directory
    – mkm
    Nov 1, 2010 at 19:05
  • Ubuntu mounts with xattr by default, but not user xattrs.
    – Kees Cook
    Nov 1, 2010 at 19:13
  • does this work with acl (access control lists) as well?
    – RolandiXor
    Nov 1, 2010 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .