How to share home directory for different users of GUI desktop application?

208 views Asked by At

I am developing notebook GUI application for field support people (i.e. there is only one user logged into system at any one time). There is only one user application program running started in User Defined Session (i.e. there is only one desktop format file in /usr/share/xsession/ starting GUI application on Ubuntu Greeting). When the user powers up, it is asked to login and when login is successful, application starts. When he/she quits, Ubuntu Greeting is displayed again.

Users have separate accounts(ex: user1, user2, user3...) and all users belong to the same primary group (ex.: tnet) and all have the same home directory named after group (ex: "/home/tnet"). I also created user corresponding to group name (but he is not allowed to login). All users share umask 002 giving them access to files created by other user.

All works fine for the first user (ex. user1), but GUI application fails to run after 1st user exit and another one attempts to login (ex. user2). It fails while executing one of the 1st statements in my python program:

  root=Tk()
...
_tkinter.TclError: couldn't connect to display "localhost:10.0"

The reason is hidden file in $HOME/.Xauthority still own by user1 with permission 600 and program fails to open this file for user2. There are other hidden files/directories having similar mode (i.e. not allowing to be opened by other user):

-rw-------  1 user1 tnet    414 Jun  9 12:09 .bash_history
drwx------ 10 user1 tnet   4096 Jun  9 12:11 .cache
drwx------  3 user1 tnet   4096 Jun  2 15:06 .compiz
drwx------ 14 user1 tnet   4096 Jun  3 11:27 .config
drwx------  3 user1 tnet   4096 Jun  2 15:13 .dbus

drwx------  3 user1 tnet   4096 Jun  3 11:26 .gconf
-rw-------  1 user1 tnet    946 Jun  3 11:26 .ICEauthority
drwx------  3 user1 tnet   4096 Jun  2 15:06 .local
-rw-------  1 tunet tnet    101 Jun  8 13:40 .Xauthority
-rw-------  2 user1 tnet      0 Jun  9 12:11 .Xauthority-c
-rw-------  2 user1 tnet      0 Jun  9 12:11 .Xauthority-l
-rw-------  1 user1 tnet    593 Jun  3 15:00 .xsession-errors
-rw-------  1 user1 tnet   1156 Jun  3 14:54 .xsession-errors.old

If I manually change mode to 660 for .Xauthority my GUI program works fine for User2.

My question is how to avoid this problem and possible other problems with other hidden files/directories having 600 mode, which I have little clue what they are for? Once again only one user at the time is allowed to login into the system.

PS. It is more than just mode of $HOME/.Xauthority: when I was writing this question, to capture what was happening, I logged remotely ssh -Y user2@ (in this case changing mode prior to login worked). But when I login locally as user2 it does not work at all - all I see is Ubuntu splash screen :-( More precisely in the file .xsession-errors:

init:/home/tunet/.config/upstart: Unable to load configuration: Permission denied
init: dbus pre-start process (2658) terminated with status 1

Thus my problem is not limited to file mode of .Xauthority. Perhaps I have to change approach altogether.

1

There are 1 answers

0
Tadek On BEST ANSWER

Well, the answer is: do not use same home directory for all users! It is bad idea in the first place. Instead place the file .xsession in the directory all users have access to. (ex.: /usr/local/common/)

So to have same application running for all users of the system (instead of the ubuntu desktop) I used answer to the question How to share home directory for different users of GUI desktop application? provided by @Takkak, modified Exec directive in the file custom.desktop to point to /usr/local/common/.xsession, created .xsession file which in turn runs gui application. All users must have primary group defined (ex. tnet). The group ownership of /usr/local/common/ and its contents must also be tnet. If you don't want any other desktops selectable in the Ubuntu Greeting, remove *.desktop from /usr/share/xsession/ except custom.desktop.