Running gsettings as root
Josef Wolf
jw at raven.inka.de
Wed Aug 17 13:09:03 UTC 2016
On Wed, Aug 17, 2016 at 02:37:50PM +0200, Oliver Grawert wrote:
> On Mi, 2016-08-17 at 11:21 +0200, Josef Wolf wrote:
> >
> > I want to do lots of configuration settings as root in the background
> > I know, I can do this with
> >
> > sudo -u $USER dbus-launch --exit-with-session gsettings set [ .... ]
> >
> > This works fine while the user is NOT logged in.
> >
> > But it won't work if the user IS logged in.
>
> have a look at the dconf command (dconf-cli package), IIRC dbus will
> check if there is a gsettings-daemon running and block if there is one
> (to prevent concurrent access to the same key) ...
>
> dconf can modify the db directly without involving the daemon.
Are you sure about this? The dconf man page says:
Note that dconf needs a D-Bus session bus connection to write changes
to the dconf database.
And IF it can directly write: istn't there a risk to corrupt the database when
accessing it directly while it is opened by another process?
Or will dconf automatically use the existing connection when a user is logged
in and otherwise create a new one?
gsettings has the additional benefit that it will do type and consistency
checks.
--
Josef Wolf
jw at raven.inka.de
More information about the ubuntu-users
mailing list