All of lore.kernel.org
 help / color / mirror / Atom feed
* Interceptor for org.freedesktop.DBus.Properties.Set
@ 2016-09-13  8:41 vishwa
  2016-09-13 19:08 ` Patrick Williams
  2016-09-13 21:22 ` Chris Austen
  0 siblings, 2 replies; 3+ messages in thread
From: vishwa @ 2016-09-13  8:41 UTC (permalink / raw)
  To: OpenBMC Maillist

[-- Attachment #1: Type: text/plain, Size: 1222 bytes --]

/org/openbmc/settings/host0 provides the dbus properties that are 
settable via org.freedesktop.DBus.properties.Set.
The properties are treated as user settings and are consumed by 
respective daemons by having a signal handler registered for 
PropertyChanged method.

The challenge at the hand is "How to make sure the users that set the 
property are choosing a valid value".

Since its set by org.freedesktop.DBus.Properties.Set, the ideal way 
would be to register a callback that would validate the user input based 
on custom algo and then only would let the .Set continue.

Without an interceptor, the user settings may be as junk as "abcdef" and 
the *settings damon* can only react to that change and can put the 
previous value back into it post verification.

I did a lot of search on ways to register an interceptor and did not see 
one. I then asked in #dbus and they told me that there is no way to 
intercept that.

So the solution what I have at the moment is to

1) Disable the property set via freedesktop
2) Introduce a custom Setter "org.openbmc.Settings.Host.Set" which can 
do the job of validating the inputs also.

Please let me know if there are better approaches.

Thanks.

Vishwanatha Subbanna.

[-- Attachment #2: Type: text/html, Size: 1684 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Interceptor for org.freedesktop.DBus.Properties.Set
  2016-09-13  8:41 Interceptor for org.freedesktop.DBus.Properties.Set vishwa
@ 2016-09-13 19:08 ` Patrick Williams
  2016-09-13 21:22 ` Chris Austen
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick Williams @ 2016-09-13 19:08 UTC (permalink / raw)
  To: vishwa; +Cc: OpenBMC Maillist

[-- Attachment #1: Type: text/plain, Size: 2634 bytes --]

On Tue, Sep 13, 2016 at 02:11:04PM +0530, vishwa wrote:
> /org/openbmc/settings/host0 provides the dbus properties that are 
> settable via org.freedesktop.DBus.properties.Set.
> The properties are treated as user settings and are consumed by 
> respective daemons by having a signal handler registered for 
> PropertyChanged method.
> 
> The challenge at the hand is "How to make sure the users that set the 
> property are choosing a valid value".
> 
> Since its set by org.freedesktop.DBus.Properties.Set, the ideal way 
> would be to register a callback that would validate the user input based 
> on custom algo and then only would let the .Set continue.
> 
> Without an interceptor, the user settings may be as junk as "abcdef" and 
> the *settings damon* can only react to that change and can put the 
> previous value back into it post verification.
> 
> I did a lot of search on ways to register an interceptor and did not see 
> one. I then asked in #dbus and they told me that there is no way to 
> intercept that.

The way to do it entirely depends on the DBus binding in use.  I'm not
sure why people in #dbus would tell you it cannot be done.

The systemd/sd-bus vtable entry for a "writable property" allows a
property to be managed directly by systemd (pass property by pointer) or
via indirect get/set methods:
https://github.com/systemd/systemd/blob/master/src/systemd/sd-bus-vtable.h#L123

If you look through the systemd repository you will find some
SD_BUS_WRITABLE_PROPERTY calls where the get/set methods are used and
those can clearly cause a Dbus.Error instead of returning success.

phosphor-settingsd is currently using a pyphosphor wrapper around the
python dbus bindings.  Here we implement the
org.freedesktop.Dbus.Properties.Set[All]:

https://github.com/openbmc/pyphosphor/blob/master/obmc/dbuslib/bindings.py#L76
https://github.com/openbmc/pyphosphor/blob/master/obmc/dbuslib/bindings.py#L95

I think you could enhance this to call a set/get function, if present, for
specific properties.  Those can throw an exception which will turn into
a Dbus.Error.

> So the solution what I have at the moment is to
> 
> 1) Disable the property set via freedesktop
> 2) Introduce a custom Setter "org.openbmc.Settings.Host.Set" which can 
> do the job of validating the inputs also.
> 
> Please let me know if there are better approaches.
> 
> Thanks.
> 
> Vishwanatha Subbanna.

> _______________________________________________
> openbmc mailing list
> openbmc@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc


-- 
Patrick Williams

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Interceptor for org.freedesktop.DBus.Properties.Set
  2016-09-13  8:41 Interceptor for org.freedesktop.DBus.Properties.Set vishwa
  2016-09-13 19:08 ` Patrick Williams
@ 2016-09-13 21:22 ` Chris Austen
  1 sibling, 0 replies; 3+ messages in thread
From: Chris Austen @ 2016-09-13 21:22 UTC (permalink / raw)
  To: vishwa; +Cc: openbmc

[-- Attachment #1: Type: text/html, Size: 2763 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-13 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-13  8:41 Interceptor for org.freedesktop.DBus.Properties.Set vishwa
2016-09-13 19:08 ` Patrick Williams
2016-09-13 21:22 ` Chris Austen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.