I am trying to run gsettings for another user in Ubuntu 18.04.2 LTS. Specifically, I am attempting to prevent the user's screen from locking. This will be run as part of a bash script. The commands I am using are:
su someuser
dbus-launch gsettings set org.gnome.desktop.screensaver lock-enabled false
Because this is run via ssh, I am opening with dbus-launch to start dbus then attempting a simple call to gsettings. However, I get the error:
dbus[22652]: Unable to set up transient service directory: XDG_RUNTIME_DIR "/run/user/1000" is owned by uid 1000, not our uid 1001
(process:22650): dconf-CRITICAL **: 11:11:27.830: unable to create directory '/run/user/1000/dconf': Permission denied. dconf will not work properly.
(process:22650): dconf-CRITICAL **: 11:11:27.830: unable to create directory '/run/user/1000/dconf': Permission denied. dconf will not work properly.
(process:22650): dconf-CRITICAL **: 11:11:27.836: unable to create directory '/run/user/1000/dconf': Permission denied. dconf will not work properly.
To confirm that the UIDs are being mismatched I checked the /run/user directory:
ls -lah /run/user
Which outputs:
total 0
drwxr-xr-x 4 root root 80 Apr 16 14:25 .
drwxr-xr-x 31 root root 900 Apr 16 14:25 ..
drwx------ 4 adminuser adminuser 100 Apr 16 14:25 1000
drwx------ 11 someuser someuser 260 Apr 16 12:26 1001
I also tried using sudo:
sudo -u "someuser" dbus-launch gsettings set org.gnome.desktop.screensaver lock-enabled false
Which gives the errors:
(process:22264): dconf-CRITICAL **: 14:33:41.124: unable to create directory '/home/adminuser/.cache/dconf': Permission denied. dconf will not work properly.
(process:22264): dconf-CRITICAL **: 14:33:41.124: unable to create directory '/home/adminuser/.cache/dconf': Permission denied. dconf will not work properly.
(process:22264): dconf-CRITICAL **: 14:33:41.135: unable to create directory '/home/adminuser/.cache/dconf': Permission denied. dconf will not work properly.
(process:22264): dconf-WARNING **: 14:33:41.152: failed to commit changes to dconf: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dfile_2derror_2dquark.Code2: Cannot open dconf database: Failed to open file “/home/adminuser/.config/dconf/user”: Permission denied
Which leads to the question, why is gsettings trying to run for adminuser instead of someuser and how can it be directed to run for someuser by adminuser over SSH?
sudo -Hu someuser dbus-launch ...
– steeldriver Apr 16 '19 at 18:44