Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 709734 - gui-wm/sway[elogind]: sd_uid_get_sessions returns zero
Summary: gui-wm/sway[elogind]: sd_uid_get_sessions returns zero
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal with 1 vote (vote)
Assignee: Aaron Bauman (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-15 15:39 UTC by Elincm
Modified: 2020-02-17 11:04 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Sway errors (sway.log,1.96 KB, text/plain)
2020-02-15 15:42 UTC, Elincm
Details
emerge --info (emerge--info.txt,6.28 KB, text/plain)
2020-02-15 15:44 UTC, Elincm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Elincm 2020-02-15 15:39:05 UTC
When trying to run gui-wm/sway it outputs error log with gui-libs/wlroots errors issued when calling libelogind function.
Main error is "User has no sessions". I am trying to ditch X and make setuid obsolete (I have -suid everywhere) for security reasons.

Reproducible: Always

Steps to Reproduce:
1. On OpenRC system, compile everything with -suid
2. Install sway with elogind support
3. Run sway
Actual Results:  
Output is in sway.log. I run gdb and the problem is as follows: get_greeter_session in wlroots calls libelogind function sd_uid_get_sessions which calls parse_env_file* functions that try to read file "/run/systemd/users/1000" but it doesn't exist so we have ENOENT and everything fails.

Expected Results:  
I guess the file should be created after logging as user but before running sway, and then sway should happily run.

Running sway:
User is in input and video groups. I run sway in .profile (sourced by bash_profile) after creating XDG_RUNTIME_DIR (in this case 1000-runtime-dir) the usual way, by

WLR_DRM_DEVICES=/dev/dri/card0 sway --debug --verbose 2> sway.log

Hardware:
I use Intel GPU (00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)), but i have also NVIDIA card, without any drivers in use (so it doesn't show up in /dev/dri/).

I tried multiple combinations of versions of sway and wlroots, ~amd64 elogind, nothing works, same error. Elogind is on runlevel boot, dbus default.
Comment 1 Elincm 2020-02-15 15:42:56 UTC
Created attachment 613946 [details]
Sway errors
Comment 2 Elincm 2020-02-15 15:44:20 UTC
Created attachment 613948 [details]
emerge --info
Comment 3 Andreas Sturmlechner gentoo-dev 2020-02-16 12:52:29 UTC
Shouldn't you also add `dbus-launch --exit-with-session` to your command?

I am unconvinced elogind is the first address to search for the issue.
Comment 4 Elincm 2020-02-16 14:31:12 UTC
dbus-launch --exit-with-session sway
Doesn't help. Same error. I didn't know where to address that issue.

Should this print 0?

/* file.c */
#include <unistd.h>
#include <sys/types.h>
#include <elogind/sd-login.h>
#include <studio.h>

int main(void)
{
        char **user_sessions = NULL;
        int user_session_count = sd_uid_get_sessions(getuid(), 1, &user_sessions);
        
        printf("%d\n", user_session_count);

        return 0;
}

gcc -L/lib64/elogind -Wl,-rpath=/lib64/elogind -lelogind-shared-241.4 file.c -o file
Comment 5 Elincm 2020-02-16 19:51:28 UTC
I will paste here "chain" of functions executed maybe it will be helpful. ("in <file>" means "implementation is in <file>")

main (sway)
| in sway/main.c
V
server_privileged_prepare (sway)
| in sway/server.c
V
wlr_backend_autocreate (wlroots)
| in backend/backend.c
V
wlr_session_create (wlroots)
| in backend/sessions/sessions.c
V
session_logind.create (wlroots)
| in backend/session/logind.c
V
logind_session_create (wlroots)
| in backend/session/logind.c
V
get_display_session (wlroots)
| in backend/session/logind.c
V
get_greeter_session (wlroots)
| in backend/session/logind.c
V
sd_uid_get_sessions (elogind)
Comment 6 Elincm 2020-02-17 11:03:00 UTC
Somehow in my package.use was -elogind on sys-auth/pambase. I added elogind in USE in make.conf. Resolved.