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 <= <a href=3D"mailto:[email protected]">[email protected]<= /a>> 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> > On Fri, 9 Jun 2023 at 23:27, Thorsten Kukuk <<a href=3D"mailto:dmar= [email protected]" target=3D"_blank">[email protected]</a>&= gt;<br> > wrote:<br> > <br> > <br> >=C2=A0 =C2=A0 =C2=A0with w there is one binary left which only uses utm= p, here is a patch to<br> >=C2=A0 =C2=A0 =C2=A0add logind support, too.<br> > <br> > OK, thanks for looking into this.<br> >=C2=A0 <br> > <br> >=C2=A0 =C2=A0 =C2=A0systemd-logind v245 (or current git) will be necess= ary for this, as only<br> >=C2=A0 =C2=A0 =C2=A0this version has all the APIs to access the data.<b= r> > <br> > The autoconf only checks for sd_session_get_leader() but I see that yo= u have<br> > ringfenced a few systemd functions with that define. That would imply = to me<br> > that either<br> > 1) You can't use those functions without the information from the<= br> > sd_session_get_leader(); or<br> > 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> > What I'm concerned here is the compile time works but those functi= ons are not<br> > present. What happens then? It looks like its doing the right thing he= re but<br> > 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> > Also, I think what you're doing here is iterating through what sd_= get_sessions<br> > returns which is an array of sessions. For all the subsequent function= s,<br> > session=3D=3DNULL means that sd_get_sessions didn't<br> > have any sessions so we'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> > Not sure about all the conditional function calls/definitions, it migh= t be<br> > better always to pass the session even when it's NULL (e.g. not co= mpiled with<br> > systemd). On the one hand, it means we aren't meaninglessly passin= g that<br> > 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> "unused arguments" warnings/errors.<br> <br> =C2=A0 Thorsten<br> <br> > I'll compile it in soon and let you know.<br> > <br> >=C2=A0 - Craig<br> > <br> > <br> > <br> >=C2=A0 =C2=A0 =C2=A0Would it be Ok this way? Or what to change?<br> > <br> >=C2=A0 =C2=A0 =C2=A0 Thorsten<br> >=C2=A0 =C2=A0 =C2=A0--<br> >=C2=A0 =C2=A0 =C2=A0Thorsten Kukuk, Distinguished Engineer, Senior Arch= itect, Future<br> >=C2=A0 =C2=A0 =C2=A0Technologies<br> >=C2=A0 =C2=A0 =C2=A0SUSE Software Solutions Germany GmbH, Frankenstra= =C3=9Fe 146, 90461 Nuernberg,<br> >=C2=A0 =C2=A0 =C2=A0Germany<br> >=C2=A0 =C2=A0 =C2=A0Managing Director: Ivo Totev, Andrew Myers, Andrew = McDonald, Martje Boudien<br> >=C2=A0 =C2=A0 =C2=A0Moerman<br> >=C2=A0 =C2=A0 =C2=A0(HRB 36809, AG N=C3=BCrnberg)<br> > <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--