Browse Source

qubes.GetAppmenus: handle home directory properly in case of sudo

Pawel Marczewski 4 years ago
parent
commit
418a5ec6e3
1 changed files with 7 additions and 1 deletions
  1. 7 1
      qubes-rpc/qubes.GetAppmenus

+ 7 - 1
qubes-rpc/qubes.GetAppmenus

@@ -17,7 +17,13 @@ for i in /etc/profile.d/*.sh ; do
 done
 
 if [ -z "$XDG_DATA_HOME" ]; then
-    XDG_DATA_HOME="$HOME/.local/share"
+    user="$(whoami)"
+    # In case we are running under sudo, use default-user.
+    if [ "$user" = "root" ]; then
+        user="$(qubesdb-read /default-user || echo user)"
+    fi
+    home="$(eval echo "~$user")"
+    XDG_DATA_HOME="$home/.local/share"
 fi
 if [ -z "$XDG_DATA_DIRS" ]; then
     XDG_DATA_DIRS="/usr/local/share/:/usr/share/"