Re: [RFC] w using logind instead of utmp

"Craig Small" <[email protected]> ("csmall") Tue, 13 Jun 2023 16:56:53 +1000
Newsgroups gmane.linux.procps.devel
Message-ID <CALy8Cw4wD5+quUyL3q2En1LRTUqa7LT7pEhs2K9-MZ112a80UQ@mail.gmail.com>
--000000000000c6e8f805fdfd5753
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, 9 Jun 2023 at 23:27, Thorsten Kukuk <[email protected]>
wrote:

>
> with w there is one binary left which only uses utmp, here is a patch to
> add logind support, too.
>
OK, thanks for looking into this.


> systemd-logind v245 (or current git) will be necessary for this, as only
> this version has all the APIs to access the data.
>
The autoconf only checks for sd_session_get_leader() but I see that you
have ringfenced a few systemd functions with that define. That would imply
to me that either
1) You can't use those functions without the information from the
sd_session_get_leader(); or
2) They are introduced at the same time (e.g. in v254

What I'm concerned here is the compile time works but those functions are
not present. What happens then? It looks like its doing the right thing
here but confirming it would be great.

Also, I think what you're doing here is iterating through what
sd_get_sessions returns which is an array of sessions. For all the
subsequent functions, session=3D=3DNULL means that sd_get_sessions didn't
have any sessions so we're not running on a systemd system?

Not sure about all the conditional function calls/definitions, it might be
better always to pass the session even when it's NULL (e.g. not compiled
with systemd). On the one hand, it means we aren't meaninglessly passing
that
pointer, on the other it makes all the function definitions messier.

I'll compile it in soon and let you know.

 - Craig


> Would it be Ok this way? Or what to change?
>
>  Thorsten
> --
> Thorsten Kukuk, Distinguished Engineer, Senior Architect, Future
> Technologies
> SUSE Software Solutions Germany GmbH, Frankenstra=C3=9Fe 146, 90461 Nuern=
berg,
> Germany
> Managing Director: Ivo Totev, Andrew Myers, Andrew McDonald, Martje
> Boudien Moerman
> (HRB 36809, AG N=C3=BCrnberg)
>

--000000000000c6e8f805fdfd5753
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">On Fri, 9 Jun 2023 at 23:27, Thorsten Kuk=
uk &lt;<a href=3D"mailto:[email protected]">dmarc-noreply@freelis=
ts.org</a>&gt; wrote:<br></div><div class=3D"gmail_quote"><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><br>
with w there is one binary left which only uses utmp, here is a patch to<br=
>
add logind support, too.<br></blockquote><div>OK, thanks for looking into t=
his.</div><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left=
:1ex">
systemd-logind v245 (or current git) will be necessary for this, as only<br=
>
this version has all the APIs to access the data.<br></blockquote><div>The =
autoconf only checks for sd_session_get_leader() but I see that you have ri=
ngfenced a few systemd functions with that define. That would imply to me t=
hat either</div><div>1) You can&#39;t use those functions without the infor=
mation from the sd_session_get_leader(); or</div><div>2) They are introduce=
d at the same time (e.g. in v254</div><div><br></div><div>What I&#39;m conc=
erned here is the compile time works but those functions are not present. W=
hat happens then? It looks like its doing the right thing here but confirmi=
ng it would be great.</div><div><br></div><div>Also, I think what you&#39;r=
e doing here is iterating through what sd_get_sessions returns which is an =
array of sessions. For all the subsequent functions, session=3D=3DNULL mean=
s that sd_get_sessions didn&#39;t</div><div>have any sessions so we&#39;re =
not running on a systemd system?</div><div><br></div><div>Not sure about al=
l the conditional function calls/definitions, it might be better always to =
pass the session even when it&#39;s NULL (e.g. not compiled with systemd). =
On the one hand, it means we aren&#39;t meaninglessly passing that</div><di=
v>pointer, on the other it makes all the function definitions messier.</div=
><div><br></div><div>I&#39;ll compile it in soon and let you know.</div><di=
v><br></div><div>=C2=A0- Craig</div><div><br></div><blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,2=
04,204);padding-left:1ex">
<br>
Would it be Ok this way? Or what to change?<br>
<br>
=C2=A0Thorsten<br>
-- <br>
Thorsten Kukuk, Distinguished Engineer, Senior Architect, Future Technologi=
es<br>
SUSE Software Solutions Germany GmbH, Frankenstra=C3=9Fe 146, 90461 Nuernbe=
rg, Germany<br>
Managing Director: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien=
 Moerman<br>
(HRB 36809, AG N=C3=BCrnberg)<br>
</blockquote></div></div>

--000000000000c6e8f805fdfd5753--