Can't share docs between 2 users with common directory

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
roccop

Can't share docs between 2 users with common directory

Post by roccop »

Hello,
I'm using Linux Mint14 -64.
I have two users: rocco (main) and ospite (guest)
I shared /home/rocco/Pubblici (in english ->/home/rocco/Public)
rocco and ospite are using this directory and I want they can edit, write, read and delete everything inside.
After my modifications the 2 users can't edit not propetary files.
How can I solve my problem?

My idea is: ospite (in english guest) can use my PC just only for internet and can read, write and download file only in one directory shared with rocco.
(ospite must not have permissions to look other directories of my PC)

Some output:

Code: Select all

cat /etc/passwd
rocco:x:1000:1000:Rocco,,,:/home/rocco:/bin/bash
ospite:x:1001:1001:Ospite,,,,:/home/ospite:/bin/bash

Code: Select all

ls -l /home/rocco
drwxrwxrwx 2 rocco rocco-ospite 4096 gen 25 21:57 Pubblici

Code: Select all

ls -l /home/rocco/Pubblici/
-rw-r--r-- 1 ospite ospite 12 gen 22 21:26 file_ospite
-rw-r--r-- 1 rocco  rocco  21 gen 22 21:17 file_rocco

Code: Select all

cat /etc/group
rocco:x:1000:rocco
ospite:x:1001:ospite
rocco-ospite:x:1002:ospite,rocco
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
bjornmu
Level 3
Level 3
Posts: 189
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: Can't share docs between 2 users with common directory

Post by bjornmu »

This is a bit tricky. First you need to ensure all new files in this directory get a group id of rocco-ospite, you can do this with:

Code: Select all

chmod g+s Pubblici
Note this will not change existing files.

But for both users to be able to edit files created by the other, you have to change the "umask". Since you have only those two users you can edit the global default setting in the file /etc/login.defs . Find the line with UMASK and change 022 to 002. You need to be superuser to do this:

Code: Select all

sudo gedit /etc/login.defs
Or whatever editor you use. Be careful! This will not take effect until next time you log in. NB this will cause *all* files created by the users to be group writable which is not generally recommended, but as long as ospite is not member of rocco's default group, it will not be able to access your other files.
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Can't share docs between 2 users with common directory

Post by altair4 »

Creating a shared directory is easy enough using either the setgid method that bjornmu suggested or by using bindfs but that doesn't solve the other requirement:
(ospite must not have permissions to look other directories of my PC)
You can isolate your own home directory from ospite:

Code: Select all

chmod 0770 /home/rocco
But ospite will have read access to almost everything else on your system.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
Locked

Return to “Software & Applications”