Subject: Re: [bug#75270] [PATCH 1/3] services: greetd: Improve greeter configurations.

From: muradm <[email-masked]>
Date: Sat, 04 Jan 2025 16:36:30 +0300

Nicolas Graves <[email-masked]> writes:

> On 2025-01-03 20:08, muradm wrote:
>
>> Nicolas Graves <[email-masked]> writes:
>>
>>> On 2025-01-02 01:53, muradm wrote:
>>>
>>>> This improvement focuses on providing common user session
>>>> scripts
>>>> for use by multiple greeters. It also fixes incorrect use of
>>>> `XDG_RUNTIME_DIR` for `wlgreet`. `wlgreet` requires 
>>>> compositor
>>>> to
>>>> run. We provide common sway based greeter script, which can 
>>>> be
>>>> shared by other graphical greeters.
>>>
>>> [...]
>>>
>>>> +(define (make-greetd-sway-greeter-command sway sway-config)
>>>> +  (let ((sway-bin (file-append sway "/bin/sway")))
>>>> +    (program-file
>>>> +     "greeter-sway-command"
>>>> +     #~(begin
>>>> +         (let* ((username (getenv "USER"))
>>>> +                (useruid (passwd:uid (getpwuid username)))
>>>> +                (useruid (number->string useruid))
>>>> +                ;; /run/user/<greeter-user-uid> won't exist
>>>> yet
>>>> +                ;; this will contain WAYLAND_DISPLAY socket
>>>> file
>>>> +                ;; and log-file below
>>>> +                (user-xdg-runtime-dir "/tmp/greeter-xdg-rt")
>>>> +                (log-file (string-append (number->string
>>>> (getpid)) ".log"))
>>>> +                (log-file (string-append 
>>>> user-xdg-runtime-dir
>>>> "/"
>>>> log-file)))
>>>
>>> Could you explain why this is necessary?  If I'm not mistaken,
>>> we didn't
>>> used a special runtime dir in RDE, and it worked OK.
>>>
>>
>> When you start sway, it has to put WAYLAND_DISPLAY somewhere. 
>> By
>> default it is put to `/run/user/<uid>`. However greeter is 
>> special
>> limited user which is used to run without logging in. Because 
>> of
>> that, `/run/user/<uid>` is not created by PAM mount. For 
>> special
>> purpose we can use any XDG_RUNTIME_DIR. Sway does not support
>> specifying location of WAYLAND_DISPLAY as far as I remember (I 
>> was
>> opening an issue about it long ago, still was not resolved).
>
> IIUC, it's because of PAM mount execution order that this 
> happens?  So
> there's also no need for that for people that don't use PAM 
> mount.
> Maybe completing the comment as "/run/user/<greeter-user-uid> 
> won't
> exist yet due to PAM mount execution order" comment would make 
> that
> clearer?

No, that is not about order, but the fact that when greeter is 
running it is not a "login action" to carry out PAM stuff. PAM 
mount normally runs after user successfully passing authentication 
with username and password. Greeter runs 
agreet/wlgreet/gtkgreet/whatever before that.

> Is the logfile here the one logging everything Sway?  Could you 
> make the
> logfile configurable or is that not possible due to unguaranteed 
> dir
> existence due to PAM mount?  We are making an extra effort to 
> locate
> logfiles in the same dir in RDE. (I could also try and make a 
> symlink a
> posteriori to the right dir).

That log file write stdout and stderr of greeter process, not the 
user. At the time user passes successfull authentication, greeter 
process exists, this log file completes its job. The user session 
is started by greetd in different environment unrelated to 
greeter's environment.