2

Similar to https://stackoverflow.com/questions/15143614/file-ownership-changes-to-root-after-saving-from-a-program-in-ubuntu but I can't use the answer since I'm not running a command-line app as sudo. I'm running a desktop app on Mint 16 32-bit on a shared file (locally shared, i.e. just on a local drive with 777 perms and nobody:users ownership), which then is not able to be overwritten by another user when they go to use it because it becomes adminuser:adminuser and 644.

How can I share this file between users, and keep it from switching ownership/perms whenever the main admin user uses it?

3

Without the ability to use sudo your options become limited to essentially 2.

Method #1

You can either put the users into the same Unix group (/etc/group) so that they're able to access the same files & directories.

Example

$ more /etc/group
somegroup:x:1001:adminuser,nobody

You then need to set the parent directory that contains this file like so:

$ chgrp somegroup parentdir
$ chmod g+rwxs parentdir

This method will force any files or directories created underneath parentdir to have the group set to somegroup. This method works fairly well, by in large, but can be a bit fragile if parentdir's permissions or ownership gets messed up. Also this method doesn't work if files and/or directories are moved into the directory from some other location.

Method #2

The more robust way to do this would be to make use of access control lists (ACLs) on the file or directory of interest, using the command setfacl.

$ setfacl -Rdm g:somegroup:rx somedir
$ ll -d somedir/
drwxrwxr-x+ 2 saml saml 4096 Feb 17 20:46 somedir/

You can then confirm that the ACL has been applied using getfacl.

$ getfacl somedir/
# file: somedir/
# owner: saml
# group: saml
user::rwx
group::rwx
other::r-x
default:user::rwx
default:group::rwx
default:group:somegroup:r-x
default:mask::rwx
default:other::r-x

Setting the permissions above on the parent directory will enforce that a default ACL will get applied to any new files or sub-directories contained within somedir.

References

  • I haven't tried these yet but will soon; however I notice you mention in both methods "any new files". What's happening is that an existing file, with correct unix permissions (not ACLs though perhaps), gets its unix permissions and ownership changed when someone opens the file and then saves it. But +1 so far for the ideas. – Kev Jul 13 '14 at 12:39
  • Tried Method 1: result is that group stays the same (good!) but owner still changes (maybe OK) and permissions still change (not OK, because now it's read-only for the other group members and only writeable by the new owner.) – Kev Jul 13 '14 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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