intgr / ego

Alter Ego: run Linux desktop applications under a different local user
MIT License
132 stars 1 forks source link

`ego` user home directory not created by AUR package #131

Closed Bad3r closed 1 year ago

Bad3r commented 1 year ago
intgr commented 1 year ago

Hi! I tried the code package from Arch Linux (open source build of VS Code) and logseq-desktop-bin package from AUR and they seemed to start up fine on my setup.

Please be more specific than "unable to run". What happens when you try to run them? Do some other applications work? What output do you see on console when you attempt to run these? What desktop environment are you running? Using Wayland or not? Are you using any custom flags with ego?

Also please run ego -vvv with some application and post the console output.

Bad3r commented 1 year ago

Please be more specific than "unable to run". What happens when you try to run them? Do some other applications work? What output do you see on console when you attempt to run these? What desktop environment are you running? Using Wayland or not? Are you using any custom flags with ego? Also please run ego -vvv with some application and post the console output.

Yes sorry. They immediately crash with a javascript related error when initializing electron. I am using i3wm on Xorg.

❯ ego -vvv logseq                                   
[ego::logging] Log level TRACE
[users::base] Running getpwnam_r for user "ego"
[users::base] Loading user with uid 921
Setting up Alter Ego for user ego (921)
Runtime data dir '/run/user/1000' configured
Wayland: WAYLAND_DISPLAY not set, skipping
Running: xhost +si:localuser:ego
Publishing PulseAudio cookie /home/user/.config/pulse/cookie to /run/user/1000/ego/pulse-cookie
PulseAudio dir '/run/user/1000/pulse' configured
Running command: machinectl shell '--uid=ego' '-EDISPLAY=:0' '-EPULSE_SERVER=unix:/run/user/1000/pulse/native' '-EPULSE_COOKIE=/run/user/1000/ego/pulse-cookie' -- .host /bin/sh -c 'dbus-update-activation-environment --systemd DISPLAY PULSE_SERVER PULSE_COOKIE; systemctl --user start xdg-desktop-portal-gtk; exec logseq'
Executing: machinectl shell '--uid=ego' '-EDISPLAY=:0' '-EPULSE_SERVER=unix:/run/user/1000/pulse/native' '-EPULSE_COOKIE=/run/user/1000/ego/pulse-cookie' -- .host /bin/sh -c 'dbus-update-activation-environment --systemd DISPLAY PULSE_SERVER PULSE_COOKIE; systemctl --user start xdg-desktop-portal-gtk; exec logseq'
Connected to the local host. Press ^] three times within 1s to exit session.
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Failed to get 'userData' path
    at /opt/logseq-desktop-git/resources/app/electron.js:12689:211
    at Object.<anonymous> (/opt/logseq-desktop-git/resources/app/electron.js:16772:3)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1296:10)
    at Module.load (node:internal/modules/cjs/loader:1096:32)
    at Module._load (node:internal/modules/cjs/loader:937:12)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at node:electron/js2c/browser_init:2:115880
    at node:electron/js2c/browser_init:2:116083
    at node:electron/js2c/browser_init:2:116087
Connection to the local host terminated.

I tested with firefox (non electron app example) and it fails due to a permission issue related to dbus.

❯ ego -vvv firefox
[ego::logging] Log level TRACE
[users::base] Running getpwnam_r for user "ego"
[users::base] Loading user with uid 921
Setting up Alter Ego for user ego (921)
Runtime data dir '/run/user/1000' configured
Wayland: WAYLAND_DISPLAY not set, skipping
Running: xhost +si:localuser:ego
Publishing PulseAudio cookie /home/user/.config/pulse/cookie to /run/user/1000/ego/pulse-cookie
PulseAudio dir '/run/user/1000/pulse' configured
Running command: machinectl shell '--uid=ego' '-EDISPLAY=:0' '-EPULSE_SERVER=unix:/run/user/1000/pulse/native' '-EPULSE_COOKIE=/run/user/1000/ego/pulse-cookie' -- .host /bin/sh -c 'dbus-update-activation-environment --systemd DISPLAY PULSE_SERVER PULSE_COOKIE; systemctl --user start xdg-desktop-portal-gtk; exec firefox'
Executing: machinectl shell '--uid=ego' '-EDISPLAY=:0' '-EPULSE_SERVER=unix:/run/user/1000/pulse/native' '-EPULSE_COOKIE=/run/user/1000/ego/pulse-cookie' -- .host /bin/sh -c 'dbus-update-activation-environment --systemd DISPLAY PULSE_SERVER PULSE_COOKIE; systemctl --user start xdg-desktop-portal-gtk; exec firefox'
Connected to the local host. Press ^] three times within 1s to exit session.
[Parent 2102299, Main Thread] WARNING: Failed to mkdir /home/ego/.config/ibus/bus: Permission denied: 'glib warning', file /build/firefox-developer-edition/src/firefox-115.0/toolkit/xre/nsSigHandlers.cpp:167

(firefoxdeveloperedition:2102299): IBUS-WARNING **: 01:00:12.941: Failed to mkdir /home/ego/.config/ibus/bus: Permission denied
Connection to the local host terminated.
intgr commented 1 year ago

Sorry for not getting back to you earlier.

Please check the filesystem permissions of /home/ego and subdirectories. I think they have incorrect ownership. If so, running sudo chown ego: -R /home/ego should fix it.

Bad3r commented 1 year ago

Sorry for not getting back to you earlier.

Please check the filesystem permissions of /home/ego and subdirectories. I think they have incorrect ownership. If so, running sudo chown ego: -R /home/ego should fix it.

No worries. Strangely the home directory for the user ego was never created. Looking how I can force creating the home directory. Not sure if I missed something.

intgr commented 1 year ago

The command that ego recommends to create the user explicitly uses --create-home. I guess you created the user some other way?

% ego -u blabla
error: Unknown user 'blabla'
hint: Specify different user with --user= or create a new user with the command:
    sudo useradd 'blabla' --uid 154 --create-home

I suppose I could add a check for the user's home directory and log a warning in that case, maybe it helps someone else in the future.

Bad3r commented 1 year ago

The command that ego recommends to create the user explicitly uses --create-home. I guess you created the user some other way?

% ego -u blabla
error: Unknown user 'blabla'
hint: Specify different user with --user= or create a new user with the command:
    sudo useradd 'blabla' --uid 154 --create-home

I suppose I could add a check for the user's home directory and log a warning in that case, maybe it helps someone else in the future.

I didn't create any extra users. the user ego exist in /etc/shadow

ego:x:921:921:Alter Ego:/home/ego:/bin/bash

Somehow the home directory for the user ego was not initialized. I installed via the AUR will double check if something is missing from the pkgbuild.

intgr commented 1 year ago

OH! Then the issue is with AUR packaging instead of this repository. I had forgotten that the AUR package autocreates the user.

Thanks, that's something that should be fixed.

intgr commented 1 year ago

From sysusers.d man page https://man.archlinux.org/man/sysusers.d.5#Home_Directory

systemd-sysusers only sets the home directory record in the user database. To actually create the directory, consider adding a corresponding tmpfiles.d(5) fragment.

Bad3r commented 1 year ago

to confirm; creating the missing home directory fixed the issue for me. Thank you for your help!