sandbox
Introduction
|
By default, when you enter a guest session, the desktop looks like it does when a regular user logs in for the first time. This tutorial shows how a system owner can customize the guest session feature to change the appearance and behavior.
Hooks facilitate customization
This section is intended for advanced users. Don't worry if you find it somewhat esoteric - just skip it and continue to the next section.
When you launch a guest session, a temporary user account, whose home directory is located in /tmp, is created behind the scenes. To customize the feature, we need to control the contents of that home directory, and as from Ubuntu 11.04 the source code includes a couple of 'hooks' for the purpose:
If the directory /etc/guest-session/skel exists and is not empty, its contents is copied to the home directory of the temporary user account. Otherwise the files in /etc/skel are copied.
If the file /etc/guest-session/prefs.sh exists, it's sourced by /usr/sbin/guest-account or a previous equivalent. /etc/guest-session.prefs.sh is intended for commands that modify the contents of the home directory.
While $USER refers to "guest-XXXXXX" and $HOME to the home directory of the temporary account, /usr/sbin/guest-account is executed as UID 0. Hence the last command in /etc/guest-session/prefs.sh should bechown -R $USER:$USER "$HOME"
so the guest user, and not root, becomes the owner of the files and directories you create via /etc/guest-session/prefs.sh.
Special purpose user
Using a special user account for setting the guest session preferences is the most convenient way to customize the feature. Please follow these steps:
Open a terminal window and create a special user:
sudo adduser --uid 999 guest-prefs
Create a symbolic link to the home directory of guest-prefs:
sudo mkdir /etc/guest-session sudo ln -s /home/guest-prefs /etc/guest-session/skel
Log in to guest-prefs and change things to what you want your guests encounter at startup.
Now, when you launch a guest session, it will have the same preferences as you set for guest-prefs.
Notes:
In this tutorial we use the name guest-prefs, but you can give the special purpose user some other name.
By default a new Ubuntu user is assigned user ID 1000 or greater. By choosing a user ID below 1000, guest-prefs won't be listed on the login screen or in the system menu.
This method, with a symbolic link, works as from version 12.04. On Ubuntu 11.04 and 11.10 you can instead of the symbolic link create the file /etc/guest-session/prefs.sh and make it contain these lines:
cp -rT /home/guest-prefs $HOME chown -R $USER:$USER $HOME
Startup dialog
As from version 14.04, when you launch a guest session, a dialog window shows up that alerts you about the temporary nature of the session.
It's considered desirable that the window gets focused, so it's started with a 4 seconds delay. Whether those 4 seconds are sufficient is affected for instance by how powerful the computer is and which programs are automatically launched at startup.
Modify dialog delay time
To set 8 seconds delay time, create or open the file /etc/guest-session/prefs.sh and insert this line:
echo "export DIALOG_SLEEP=8" >> $HOME/.profile
Disable startup dialog
If you prefer that the dialog does not show up at all, create or open the file /etc/guest-session/prefs.sh and insert this line:
touch $HOME/.skip-guest-warning-dialog
Save files on disk
For the case you want to offer your guests the possibility to store files persistently on disk (not permitted by default), you can create the folder /var/guest-data:
sudo mkdir -m 0777 /var/guest-data
That folder is mentioned in the startup dialog window if it exists and is world writable.