Re: [RFC] w using logind instead of utmp

"Craig Small" <[email protected]> ("csmall") Wed, 21 Jun 2023 20:19:49 +1000
Newsgroups gmane.linux.procps.devel
Message-ID <CALy8Cw6Z9XXk0iUhwxCM9HfpuzF_nxbOy1pwCEhfqEav6+Z0EA@mail.gmail.com>
--0000000000003f576a05fea11ce0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,
  That all seems fine. I can either commit this change or if you have an
updated version that version, let me know if there is anything else to add.

 - Craig


On Tue, 13 Jun 2023 at 17:16, Thorsten Kukuk <[email protected]>
wrote:

>
> Hi,
>
> On Tue, Jun 13, Craig Small wrote:
>
> > On Fri, 9 Jun 2023 at 23:27, Thorsten Kukuk <[email protected]=
g
> >
> > 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 t=
o
> 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
>
> sd_session_get_leader() was the last added function, all other functions
> are older. So if sd_session_get_leader() is present, all other functions
> should be present, too. I doubt that anybody builds a systemd version
> and manually removes single, older functions.
>
> > 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 her=
e
> but
> > confirming it would be great.
>
> This are libsystemd functions. They use the same symbol versioning as
> glibc is using. So if you compile with a newer libsystemd and run it
> with an older libsystemd, you will get the same function not found errors=
.
>
> If you use a newer libsystemd with an older systemd-logind: also no
> problem, it will continue to work. systemd-logind provides the data
> since the beginning, only the libsystemd API was missing.
>
> > 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?
>
> No, it means nobody is logged in.
> sd_booted() determines, if systemd is running or not.
>
> > 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 compile=
d
> with
> > systemd). On the one hand, it means we aren't meaninglessly passing tha=
t
> > pointer, on the other it makes all the function definitions messier.
>
> That what I was thinking about, too, but was unsure. And you would get
> "unused arguments" warnings/errors.
>
>   Thorsten
>
> > 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
> Nuernberg,
> >     Germany
> >     Managing Director: Ivo Totev, Andrew Myers, Andrew McDonald, Martje
> Boudien
> >     Moerman
> >     (HRB 36809, AG N=C3=BCrnberg)
> >
>
> --
> 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)
>
>

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

<div dir=3D"ltr"><div>Hi,</div><div>=C2=A0 That all seems fine. I can eithe=
r commit this change or if you have an updated version that version, let me=
 know if there is anything else to add.</div><div>=C2=A0</div><div>=C2=A0- =
Craig</div><div><br></div></div><br><div class=3D"gmail_quote"><div dir=3D"=
ltr" class=3D"gmail_attr">On Tue, 13 Jun 2023 at 17:16, Thorsten Kukuk &lt;=
<a href=3D"mailto:[email protected]">[email protected]<=
/a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><=
br>
Hi,<br>
<br>
On Tue, Jun 13, Craig Small wrote:<br>
<br>
&gt; On Fri, 9 Jun 2023 at 23:27, Thorsten Kukuk &lt;<a href=3D"mailto:dmar=
[email protected]" target=3D"_blank">[email protected]</a>&=
gt;<br>
&gt; wrote:<br>
&gt; <br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0with w there is one binary left which only uses utm=
p, here is a patch to<br>
&gt;=C2=A0 =C2=A0 =C2=A0add logind support, too.<br>
&gt; <br>
&gt; OK, thanks for looking into this.<br>
&gt;=C2=A0 <br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0systemd-logind v245 (or current git) will be necess=
ary for this, as only<br>
&gt;=C2=A0 =C2=A0 =C2=A0this version has all the APIs to access the data.<b=
r>
&gt; <br>
&gt; The autoconf only checks for sd_session_get_leader() but I see that yo=
u have<br>
&gt; ringfenced a few systemd functions with that define. That would imply =
to me<br>
&gt; that either<br>
&gt; 1) You can&#39;t use those functions without the information from the<=
br>
&gt; sd_session_get_leader(); or<br>
&gt; 2) They are introduced at the same time (e.g. in v254<br>
<br>
sd_session_get_leader() was the last added function, all other functions<br=
>
are older. So if sd_session_get_leader() is present, all other functions<br=
>
should be present, too. I doubt that anybody builds a systemd version<br>
and manually removes single, older functions.<br>
<br>
&gt; What I&#39;m concerned here is the compile time works but those functi=
ons are not<br>
&gt; present. What happens then? It looks like its doing the right thing he=
re but<br>
&gt; confirming it would be great.<br>
<br>
This are libsystemd functions. They use the same symbol versioning as<br>
glibc is using. So if you compile with a newer libsystemd and run it<br>
with an older libsystemd, you will get the same function not found errors.<=
br>
<br>
If you use a newer libsystemd with an older systemd-logind: also no<br>
problem, it will continue to work. systemd-logind provides the data<br>
since the beginning, only the libsystemd API was missing.<br>
<br>
&gt; Also, I think what you&#39;re doing here is iterating through what sd_=
get_sessions<br>
&gt; returns which is an array of sessions. For all the subsequent function=
s,<br>
&gt; session=3D=3DNULL means that sd_get_sessions didn&#39;t<br>
&gt; have any sessions so we&#39;re not running on a systemd system?<br>
<br>
No, it means nobody is logged in.<br>
sd_booted() determines, if systemd is running or not.<br>
<br>
&gt; Not sure about all the conditional function calls/definitions, it migh=
t be<br>
&gt; better always to pass the session even when it&#39;s NULL (e.g. not co=
mpiled with<br>
&gt; systemd). On the one hand, it means we aren&#39;t meaninglessly passin=
g that<br>
&gt; pointer, on the other it makes all the function definitions messier.<b=
r>
<br>
That what I was thinking about, too, but was unsure. And you would get<br>
&quot;unused arguments&quot; warnings/errors.<br>
<br>
=C2=A0 Thorsten<br>
<br>
&gt; I&#39;ll compile it in soon and let you know.<br>
&gt; <br>
&gt;=C2=A0 - Craig<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0Would it be Ok this way? Or what to change?<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0 Thorsten<br>
&gt;=C2=A0 =C2=A0 =C2=A0--<br>
&gt;=C2=A0 =C2=A0 =C2=A0Thorsten Kukuk, Distinguished Engineer, Senior Arch=
itect, Future<br>
&gt;=C2=A0 =C2=A0 =C2=A0Technologies<br>
&gt;=C2=A0 =C2=A0 =C2=A0SUSE Software Solutions Germany GmbH, Frankenstra=
=C3=9Fe 146, 90461 Nuernberg,<br>
&gt;=C2=A0 =C2=A0 =C2=A0Germany<br>
&gt;=C2=A0 =C2=A0 =C2=A0Managing Director: Ivo Totev, Andrew Myers, Andrew =
McDonald, Martje Boudien<br>
&gt;=C2=A0 =C2=A0 =C2=A0Moerman<br>
&gt;=C2=A0 =C2=A0 =C2=A0(HRB 36809, AG N=C3=BCrnberg)<br>
&gt; <br>
<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>
<br>
</blockquote></div>

--0000000000003f576a05fea11ce0--