[systemd-devel] How to make vtable entry as SD_BUS_VTABLE_UNPRIVILEGED

Lal, Arun arun.lal at intel.com
Fri Mar 31 16:01:48 UTC 2023


Hi Lennart,

Thanks for the reply 😊 

I had seen SD_BUS_METHOD function. But my doubt was bit different. 

check_access function get the variable v as shown below 

/* Then, look for a known method */
        vtable_key.path = (char*) p;
        vtable_key.interface = m->interface;
        vtable_key.member = m->member;

v = hashmap_get(bus->vtable_methods, &vtable_key);

But SD_BUS_METHOD does not show how to add a path and interface, it just takes member. That got me bit confused. 
As in how to mention path and interface while making the vtable entry. 

Another question I had is what is the clean way of adding vtable entry in code. 
As in, as maintainer do you have a recommendation on how I do this?

Right now I am thinking of adding a new file and making it part of systemd which will have a function which will make the vtable entry. 
And call this function somewhere from boot of systemd. Your comments here will be helpful. 

Regards,
Arun Lal K M

-----Original Message-----
From: Lennart Poettering <lennart at poettering.net> 
Sent: Friday, March 31, 2023 3:30 PM
To: Lal, Arun <arun.lal at intel.com>
Cc: systemd-devel at lists.freedesktop.org
Subject: Re: [systemd-devel] How to make vtable entry as SD_BUS_VTABLE_UNPRIVILEGED

On Fr, 31.03.23 05:32, Lal, Arun (arun.lal at intel.com) wrote:

> Hi All,
>
> In file systemd\src\libsystemd\sd-bus\bus-objects.c function check_access has the following check:
>
> /* If the member is marked UNPRIVILEGED let's grant access */
>         if (c->vtable->flags & SD_BUS_VTABLE_UNPRIVILEGED)
>                 return 0;
>
> Can someone tell me how to set the flag as SD_BUS_VTABLE_UNPRIVILEGED?
>
> This is because I want a non-root user to make dbus method call. As of now this get's blocked in check_access function.
> I would like to allow this by satisfying the condition 
> c->vtable->flags & SD_BUS_VTABLE_UNPRIVILEGED

There are roughly a bazillion examples in the systemd source tree for that. For example here:

https://github.com/systemd/systemd/blob/main/src/login/logind-session-dbus.c#L857

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list