Issue: When we start a workspace in Domino the default username is 'ubuntu'. I would like to change this username to something else or the logged in Domino username.
Considerations: While this does sound like a great idea and is absolutely possible there are several considerations to take in to account before executing such a change.
- This should not be used for auditing purposes. Since Domino workspaces allow for 'sudo'/'root' access in the workspace, it is trivial for the user to change the given username to anything they desire. As such "binding" the Domino username to the workspace OS username should not be considered as an authoritative record.
- When we are changing the username we must not change the UID. Changing the UID will result in a broken workspace since there are a large number of files which will have ownership to the original 'ubuntu' user UID.
- In a centralised authentication scenario where Domino usernames are from sso/ad/ldap this method can be used to facilitate easier access to other external infrastructure like databases for example which might be using the same authentication authority.
- Domino Data Lab does not consider this method as an official way to run your workspaces. We have tested this in 5.x family of the product but we can not guarantee it will continue working in future releases or based on any customisations you might have in your environment. As Domino workspaces are designed to run with the 'ubuntu' user, changing this can lead to unexpected results.
Solution: To make this work we will have to add some additional instructions to the environment of your choosing under the "Pre Setup script". We will be using an existing environment variable to extract the username of the running user from Domino and change the workspace username with it.
- Find the environment you wish to use. Open the edit definitions page and scroll down to "Advanced". Under "Advanced" section select "Pre Run Script" and insert the following:
# Creating script that will change the workspace username
# Sleep for 20s to allow for any startup tasks to complete
echo "sleep 20" > /tmp/userchange.sh
# Use $DOMINO_STARTING_USERNAME to change the ubuntu username
echo "usermod -l $DOMINO_STARTING_USERNAME ubuntu" >> /tmp/userchange.sh
# Change script to executable
chmod +x /tmp/userchange.sh
# Run the script as a background task so we do not wait for it to complete
In this script we are creating the script that will actually execute the change. As there are a number of setup tasks that might be still running we allow for a 20 seconds sleep before we run the change. It is also important to run the usernamechange.sh in the background as this will allow for the workspace to continue the start process without waiting for our script.
It will take approximately 20s after our workspace has started for the change to be executed. You can check this from a terminal in the workspace to confirm the result.
uid=12574(ddl-g) gid=12574(ubuntu) groups=12574(ubuntu)