Re: Cmake and dbus daemon on the system bus

2019-10-12 Thread Luca Carlon
Very sorry for the incredibly late answer, but I had to pause this task.

On Mon, Sep 16, 2019 at 9:56 PM David Edmundson
 wrote:
>
> Kauth is a wrapper round using dbus activation on the system bus...

Yes, and that is how my first implementation works. But it seemed less
flexible: the only way I found to implement something like a daemon is
a long running method. But it seems a bad approach when it comes to
multiple clients calling into the helper. I suppose that the helper is
single instance (which is ok), and the call to the method remains in
queue for the following clients. Is this correct? Do you think this is
a good architecture? Any advice?

> It's 99.9% the same.

Yes, code is almost identical, but is the policy file used for the
session bus? I can't find a description for that in the docs.
It seems however that I found something here:
https://techbase.kde.org/Development/Tutorials/PolicyKit/Helper_HowTo.
I skipped that article because it seemed outdated. Is it or can I
refer to it?

> You want to look for dbus-activation and set User=root in the
> activation desktop file that you put in
> /usr/share/dbus-1/system-services

I'll try that, thanks!
Sorry again for the late answer. Regards.


On Mon, Sep 16, 2019 at 9:56 PM David Edmundson
 wrote:
>
> Kauth is a wrapper round using dbus activation on the system bus...
>
> >I read the tutorials related to dbus in the techbase pages, but those seem 
> >more oriented to the sessionBus.
>
> It's 99.9% the same.
>
> >and a way to automatically start with root privileges the daemon
>
> You want to look for dbus-activation and set User=root in the
> activation desktop file that you put in
> /usr/share/dbus-1/system-services
>
> David



-- 
Dr. Luca Carlon
Software Engineer


Re: Cmake and dbus daemon on the system bus

2019-09-16 Thread Thiago Macieira
On Monday, 16 September 2019 12:56:32 PDT David Edmundson wrote:
> You want to look for dbus-activation and set User=root in the
> activation desktop file that you put in
> /usr/share/dbus-1/system-services

Make sure you REALLY need to run as root. If you can run as some other, non-
privileged user, that's better. That can be as a result of dropping privileges 
with setuid() or capset() after acquiring the resource you need.

If you do that, connect to the bus AFTER you've dropped privileges.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products





Re: Cmake and dbus daemon on the system bus

2019-09-16 Thread David Edmundson
Kauth is a wrapper round using dbus activation on the system bus...

>I read the tutorials related to dbus in the techbase pages, but those seem 
>more oriented to the sessionBus.

It's 99.9% the same.

>and a way to automatically start with root privileges the daemon

You want to look for dbus-activation and set User=root in the
activation desktop file that you put in
/usr/share/dbus-1/system-services

David


Cmake and dbus daemon on the system bus

2019-09-16 Thread Luca Carlon
Hello,
not sure if this is the right place to ask. I'm working on this new
feature: https://bugs.kde.org/show_bug.cgi?id=410902. In the current
implementation I used KAuth, but it seems to me a dbus daemon would be a
better fit for this case. The daemon must be run as root, and should
therefore probably use the systemBus. I read the tutorials related to dbus
in the techbase pages, but those seem more oriented to the sessionBus.

I already implemented the communication, which seems to work properly. I'm
missing a way to automatically install the policy file with cmake (which
should be in /etc/dbus-1/system.d) and a way to automatically start with
root privileges the daemon (can that be done with a .desktop file?). Anyone
who can provide some info? Is there maybe a place where to find guidelines
about these two points? Or even examples doing the same?

Thank you very much for any help!
Regards.

-- 
Dr. Luca Carlon
Software Engineer