Re: [systemd-devel] hostnamectl set-hostname non-admin user

2021-04-07 Thread Damien LEFEVRE
Thanks Silvio! That's just what I needed.

Cheers,
-Damien

On Tue, Apr 6, 2021 at 9:26 PM Silvio Knizek  wrote:

> Am Dienstag, dem 06.04.2021 um 16:21 +0300 schrieb Damien LEFEVRE:
> > Hi,
> >
> > I have an embedded device and I do not install sudo. I need to have a
> > non-root running the main service capable of changing the hostname.
> >
> > After spending a long afternoon on this I still have not managed.
> >
> > Here i've tried adding my new user but only read-only requests go
> > through
> > /usr/share/dbus-1/system.d/org.freedesktop.hostname1.conf
> > ```xml
> >  
> >  > Configuration 1.0//EN"
> >
> > "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd;>
> >
> > 
> >
> > 
> >
> > 
> > 
> > 
> > 
> > 
> >
> > 
> > 
> > 
> > 
> > 
> >
> > 
> > 
> > 
> > 
> >
> > 
> > ```
> >
> >
> > /usr/share/polkit-1/actions/org.freedesktop.hostname1.policy
> > ```xml
> >  
> >  > Configuration 1.0//EN"
> > "
> > http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd;>
> >
> > 
> >
> > 
> >
> > The systemd Project
> >
> > http://www.freedesktop.org/wiki/Software/systemd > url>
> >
> > 
> > Set host
> > name
> > Authentication is
> > required to set the local host name.
> > 
> > auth_admin_keep
> >
> > auth_admin_keep
> > auth_admin_keep
> > 
> > 
> >
> > 
> > Set static host
> > name
> > Authentication is
> > required to set the statically configured local host name, as well as
> > the pretty host name.
> > 
> > auth_admin_keep
> >
> > auth_admin_keep
> > auth_admin_keep
> > 
> >  > key="org.freedesktop.policykit.imply">org.freedesktop.hostname1.set-
> > hostname org.freedesktop.hostname1.set-machine-info
> > 
> >
> > 
> > Set machine
> > information
> > Authentication is
> > required to set local machine information.
> > 
> > auth_admin_keep
> >
> > auth_admin_keep
> > auth_admin_keep
> > 
> > 
> >
> > 
> > Get product
> > UUID
> > Authentication is
> > required to get product UUID.
> > 
> > auth_admin_keep
> >
> > auth_admin_keep
> > auth_admin_keep
> > 
> > 
> >
> > 
> > ```
> >
> > Despite all my attempts I always get 'Could not set property: Access
> > denied' for hostnamectl set-hostname
> >
> > And get the 'org.freedesktop.DBus.Error.AccessDenied' in dbus-monitor
> >
> > method call time=1617739342.317948 sender=:1.23 ->
> > destination=org.freedesktop.hostname1 serial=3
> > path=/org/freedesktop/hostname1; interface=org.freedesktop.hostname1;
> > member=SetStaticHostname
> >string "blabla"
> >boolean true
> > ...
> > error time=1617739342.320289 sender=:1.24 -> destination=:1.23
> > error_name=org.freedesktop.DBus.Error.AccessDenied reply_serial=3
> >string "Permission denied"
> >
> >
> > Any help would be greatly appreciated =)
> >
> > -Damien
>
> Hi Damien,
>
> you actually need to configure polkit for this. Something like
> /etc/polkit-1/rules.d/49-allow-myuser-access-to-hostnamed.rules
>
> ```javascript
> polkit.addRule(function(action, subject) {
> if (action.id == "org.freedesktop.hostname1.set-hostname") {
> if (subject.user == "myuser") {
> return polkit.Result.YES;
> }
> }
> });
> ```
>
> Your dbus definition only says that one can define rules including such
> actions.
>
> HTH
> Silvio
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] hostnamectl set-hostname non-admin user

2021-04-06 Thread Damien LEFEVRE
Hi,

I have an embedded device and I do not install sudo. I need to have a
non-root running the main service capable of changing the hostname.

After spending a long afternoon on this I still have not managed.

Here i've tried adding my new user but only read-only requests go through
/usr/share/dbus-1/system.d/org.freedesktop.hostname1.conf
```xml
 
http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd;>























```


/usr/share/polkit-1/actions/org.freedesktop.hostname1.policy
```xml
 
http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd;>





The systemd Project
http://www.freedesktop.org/wiki/Software/systemd



Set host
name
Authentication is
required to set the local host name.

auth_admin_keep
auth_admin_keep
auth_admin_keep




Set static host
name
Authentication is
required to set the statically configured local host name, as well as the
pretty host name.

auth_admin_keep
auth_admin_keep
auth_admin_keep

org.freedesktop.hostname1.set-hostname
org.freedesktop.hostname1.set-machine-info



Set machine
information
Authentication is
required to set local machine information.

auth_admin_keep
auth_admin_keep
auth_admin_keep




Get product
UUID
Authentication is
required to get product UUID.

auth_admin_keep
auth_admin_keep
auth_admin_keep




```

Despite all my attempts I always get 'Could not set property: Access
denied' for hostnamectl set-hostname

And get the 'org.freedesktop.DBus.Error.AccessDenied' in dbus-monitor

method call time=1617739342.317948 sender=:1.23 ->
destination=org.freedesktop.hostname1 serial=3
path=/org/freedesktop/hostname1; interface=org.freedesktop.hostname1;
member=SetStaticHostname
   string "blabla"
   boolean true
...
error time=1617739342.320289 sender=:1.24 -> destination=:1.23
error_name=org.freedesktop.DBus.Error.AccessDenied reply_serial=3
   string "Permission denied"


Any help would be greatly appreciated =)

-Damien
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel