<div dir="ltr"><span class="gmail-ui-provider gmail-rh gmail-b gmail-c gmail-d gmail-e gmail-f gmail-g gmail-h gmail-i gmail-j gmail-k gmail-l gmail-m gmail-n gmail-o gmail-p gmail-q gmail-r gmail-s gmail-t gmail-aqt gmail-aqu gmail-w gmail-x gmail-y gmail-z gmail-ab gmail-ac gmail-ae gmail-af gmail-ag gmail-ah gmail-ai gmail-aj gmail-ak" dir="ltr"><span style="font-family:"Segoe UI",system-ui,"Apple Color Emoji","Segoe UI Emoji",sans-serif;font-size:14px"><p style="margin:0px">Sorry my previous analysis is wrong, the <b>sd_bus_query_sender_privilege</b> return 0 due to check <b>if (sender_uid == our_uid)</b> and then the <b>bus_verify_polkit_async return -EACCES</b>;<br></p>
</span><p><span style="font-family:"Segoe UI",system-ui,"Apple Color Emoji","Segoe UI Emoji",sans-serif;font-size:14px">if (sender_uid == our_uid)</span><br></p><span style="font-family:"Segoe UI",system-ui,"Apple Color Emoji","Segoe UI Emoji",sans-serif;font-size:14px"><p>
(gdb) p sender_uid<br>
$25 = 997<br>
(gdb) p our_uid<br>
$26 = 0</p>
</span><p><span style="font-family:"Segoe UI",system-ui,"Apple Color Emoji","Segoe UI Emoji",sans-serif;font-size:14px">guest@imx6quad:/$ echo $UID</span><br></p><span style="font-family:"Segoe UI",system-ui,"Apple Color Emoji","Segoe UI Emoji",sans-serif;font-size:14px"><p>
997</p>
</span></span></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 2 déc. 2021 à 13:55, Mohamed Ali Fodha <<a href="mailto:fodha.mohamed.ali@gmail.com">fodha.mohamed.ali@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">After debug, the root cause comes from below code (bus-convenience.c):<div><br><div>   /* We cannot use augmented uid/euid for authorization,<br>    * since then data is acquired raceful from<br>    * /proc. This can never actually happen, but let's<br>    * better be safe than sorry, and do an extra check<br>    * here. */<br>    assert_return((sd_bus_creds_get_augmented_mask(creds) & (SD_BUS_CREDS_UID|SD_BUS_CREDS_EUID)) == 0, -EPERM);<br></div><div><br></div><div>Mohamed Ali</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 2 déc. 2021 à 08:42, Mohamed Ali Fodha <<a href="mailto:fodha.mohamed.ali@gmail.com" target="_blank">fodha.mohamed.ali@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">According to this thread <a href="https://github.com/systemd/systemd/issues/11034" target="_blank">https://github.com/systemd/systemd/issues/11034</a>, kdbus can manage linux capabilities but dbus can't, isn't it?<div><div>Below is what I did in my binary</div><div><br></div><div><i> r = sd_bus_open_system(&bus);<br> if (r < 0) {<br>         sm_error("Failed to connect to system bus\n");<br> }<br><br> r = sd_bus_call_method(bus,<br>         "org.freedesktop.systemd1",     <br>         "/org/freedesktop/systemd1",      <br>         "org.freedesktop.systemd1.Manager",  <br>         "StartUnit",                   <br>         &error,                            <br>         &m,                                  <br>         "ss",                                <br>         "reboot.target",                    <br>         "replace-irreversibly");</i><br></div><div><br></div><div>This call returns -13 (<span style="box-sizing:border-box;margin:0px;padding:0px;color:rgb(136,0,0)">#define</span><span style="box-sizing:border-box;margin:0px;padding:0px">    EACCES          </span><span style="box-sizing:border-box;margin:0px;padding:0px;color:rgb(0,102,102)">13</span><span style="box-sizing:border-box;margin:0px;padding:0px"> </span><span style="box-sizing:border-box;margin:0px;padding:0px;color:rgb(136,0,0)">/* Permission denied */)</span></div><div>Below are the capabilities of the binary (hwmanager is called by regular user)<br></div><div><br></div><div><i>root@imx6quad:~# getcap /usr/sbin/hwmanager</i></div><div><i>/usr/sbin/hwmanager  = cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_kill,cap_net_bind_service,cap_net_admin,cap_net_raw,cap_sys_rawio,cap_sys_admin,cap_sys_boot,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_syslog+eip<br></i></div><div><br></div><div>Mohamed Ali</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 1 déc. 2021 à 11:38, Ulrich Windl <<a href="mailto:Ulrich.Windl@rz.uni-regensburg.de" target="_blank">Ulrich.Windl@rz.uni-regensburg.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">>>> Martin Wilck <<a href="mailto:mwilck@suse.com" target="_blank">mwilck@suse.com</a>> schrieb am 01.12.2021 um 10:41 in Nachricht<br>
<<a href="mailto:a64771271a667804c450a13481cee06180965b12.camel@suse.com" target="_blank">a64771271a667804c450a13481cee06180965b12.camel@suse.com</a>>:<br>
> On Wed, 2021‑12‑01 at 10:24 +0100, Ulrich Windl wrote:<br>
>> > > <br>
>> <br>
>> And I wonder what's wrong with allowing the shutdown command for the<br>
>> user in<br>
>> sudoers.<br>
>> (sudo $(which shutdown) ‑r now)<br>
> <br>
> Sure. I thought sudo might not be installed on that embedded system,<br>
> either. If it is, I'd prefer it over other solutions simply because<br>
> it's more transparent. Capability bits tend to go unnoticed.<br>
> <br>
<br>
Quote from OP: "Previously the guest user was in sudoers (so to run reboot the<br>
systemd<br>
service uses "sudo") but actually our customer wants to remove the guest<br>
user from sudoers."<br>
<br>
It was some odd security debate: If someone can operate as guest he/she should<br>
not be able to reboot, while the guest user should be.<br>
(Maybe I misunderstood. Any case some details for the problem are missing)<br>
<br>
<br>
> Martin<br>
<br>
<br>
<br>
</blockquote></div>
</blockquote></div>
</blockquote></div>