RStudio Server Pro integrates tightly with its host linux operating system. As a result, changing UIDs for a user (even upstream in an identity store like LDAP or Active Directory) can cause problems for the server.
If you have the need to change a user's UID or if you are trying to debug a user's broken experience with RStudio Server as a result of the UID change, please follow the steps below.
NOTE: Most of these commands will require root (or sudo) privileges
Did the User's UID change?
First, it is important to determine whether you are experiencing problems as a result of a UID change. In order to show illustrate this behavior, we will use a fake user: jen . Her UID before the change is 1234, and after the change is 9999.
Use the following commands in a linux terminal to explore if UIDs have changed. We see that jen's have not changed yet:
# look at the user's identity
id jen
# uid=1234(jen) gid=500(rstudio-users) groups=500(rstudio-users)
# look at her full user definition
getent passwd jen
# jen:*:1234:500:jen@example.com:/home/jen:/bin/bash
# look at her home directory
namei -l /home/jen
# f: /home/jen
# drwxr-xr-x root root /
# drwxr-xr-x root root home
# drwxr-xr-x jen rstudio-users jen
After the migration of jen to UID 9999, you might see something like the following:
# look at the user's identity
id jen
# uid=9999(jen) gid=500(rstudio-users) groups=500(rstudio-users)
# look at her full user definition
getent passwd jen
# jen:*:9999:500:jen@example.com:/home/jen:/bin/bash
# look at her home directory
namei -l /home/jen
# f: /home/jen
# drwxr-xr-x root root /
# drwxr-xr-x root root home
# drwxr-xr-x 1234 rstudio-users jen
This will lead to RStudio Server not being able to start sessions, because jen's home directory is still owned by user 1234 (which no longer exists).
Fix Home Directory Permissions
If you find yourself in a situation where the home directory is owned by the wrong / old user (above), then you need to change the ownership of the directory back to our example user: jen (now UID 9999). The solution is to execute:
chown -R jen /home/jen
# look at her home directory afterwards
namei -l /home/jen
# f: /home/jen
# drwxr-xr-x root root /
# drwxr-xr-x root root home
# drwxr-xr-x jen rstudio-users jen
Fix RStudio Server Permissions
Although this goes much of the way towards the fix, RStudio Server also uses other places on the file system for storage under the user's ownership. These will need to be chown'd to the new UID as well. These locations are:
-
/var/lib/rstudio-server/shared-storage/sessions/<username>
-
/tmp/rstudio-rsession/<username>-ds/<sessionid>/<sessionid>
For /var/lib/rstudio-server/shared-storage/sessions/<username>
# look at ownership
ls -lha /var/lib/rstudio-server/shared-storage/sessions
# total 28K
# drwxrwxrwx 7 root root 4.0K Oct 15 20:56 .
# drwxrwxrwt 3 root root 4.0K Sep 6 22:05 ..
# drwx------ 2 1234 rstudio-users 4.0K Oct 15 20:13 jen
# fix ownership
chown -R jen /var/lib/rstudio-server/shared-storage/sessions/jen
For /tmp/rstudio-rsession/<username>-ds/<sessionid>/<sessionid> (for active sessions)
namei -l /tmp/rstudio-rsession/jen-ds/3c286bd3/3c286bd3
# f: /tmp/rstudio-rsession/jen-ds/3c286bd3/3c286bd3
# drwxr-xr-x root root /
# drwxrwxrwt root root tmp
# drwxrwxrwt root root rstudio-rsession
# drwxr-xr-x rstudio-server rstudio-server jen-ds
# drwxrwxrwt rstudio-server rstudio-server 3c286bd3
# srw-rw-rw- 1234 rstudio-users 3c286bd3
# to fix this, either chown each individual session
chown jen /tmp/rstudio-rsession/jen-ds/3c286bd3/3c286bd3
# or delete the parent directory (if you are not concerned about temp data)
rm -r /tmp/rstudio-rsession/jen-ds
Fix RStudio Job Launcher Permissions
Along the same lines, the RStudio Job Launcher has files that it maintains under the user's ownership as well. This time, at
/var/lib/rstudio-launcher/<Launcher Plugin Name>/output/<username>
Note that the "Launcher Plugin Name" is dependent on your configuration. In our setup, we are using the "Local" launcher plugin.
# look at ownership
ls -lha /var/lib/rstudio-launcher/Local/output/jen/
# total 44K
# drwx------ 2 1234 rstudio-users 4.0K Oct 16 19:40 .
# drwxrwxrwx 37 rstudio-server rstudio-server 4.0K Oct 14 14:02 ..
# -rw-r--r-- 1 1234 rstudio-users 0 Oct 16 19:32 '1XuAGi53HYhGCBur42OUcg==.stderr'
# -rw-r--r-- 1 1234 rstudio-users 78 Oct 16 19:32 '1XuAGi53HYhGCBur42OUcg==.stdout'
# fix the ownership
chown -R jen /var/lib/rstudio-launcher/Local/output/jen
Restart the Service
Once complete fixing permissions and file ownership at the aforementioned locations, the RStudio Job Launcher and RStudio Server Pro should be restarted and should be functional for jen.
systemctl restart rstudio-launcher
systemctl restart rstudio-server
Please let us know if you run into any trouble during this process, as RStudio Server Pro and the RStudio Job Launcher are both covered by our professional support team.
One More Tip: use find
Although it may take some time (depending on the directory), the following command can be used on various directories to find files still owned by the old UID (1234, in our example case):
find /var/lib/rstudio-launcher -user 1234
# /var/lib/rstudio-launcher/Local/output/jen
# /var/lib/rstudio-launcher/Local/output/jen/a7CtHlGSePFBxJ-athJlqA==.stderr
# /var/lib/rstudio-launcher/Local/output/jen/GkZxvj0g0tlvASmFi4bMKQ==.stderr
find /var/lib/rstudio-server -user 1234
# /var/lib/rstudio-server/shared-storage/sessions/jen
# /var/lib/rstudio-server/shared-storage/sessions/jen/3d9e8412
find /tmp/rstudio-rsession/ -user 1234
# /tmp/rstudio-rsession/jen-ds/3c286bd3/3c286bd3
Comments