Running gsettings as root

Josef Wolf jw at raven.inka.de
Wed Aug 17 11:22:17 UTC 2016


On Wed, Aug 17, 2016 at 08:59:13PM +1000, Karl Auer wrote:
> On Wed, 2016-08-17 at 12:41 +0200, Josef Wolf wrote:
> > On Wed, Aug 17, 2016 at 08:07:42PM +1000, Karl Auer wrote:
> > > You could run your scripts from the system crontab,
> > This is actually what I do.
> > 
> > But the problem is NOT to run the scripts as the specified user.
> 
> Maybe you misunderstand - the system crontab runs jobs as root AND can
> run jobs as any other specified user.

I know. And myself thinks, you mis-understand ;-)

The commands are executed with proper values for uid/gid and $HOME setting. As
I wrote, setting up the user's environment is NOT the problem.

Besides: setting up the user's environment would not depend on whether the
user is already logged in or not.

> > The problem is that they won't work while the user is logged in
> > because dbus-launch starts a new dbus-instance and the changes done
> > by gsettings will be discarded as soon as dbus-launch exits.
> 
> I have no idea why that is relevant. I'm not saying it is not relevant,
> just that I don't understand why it would be. Why is that relevant?

dbus-launch is run as the proper target user, with the proper value of the
$HOME variable.

When the user is already logged in into the desktop at the time my script
runs, he will already have a dbus instance running. The dbus-launch instance
that is started by my script will notice the fact that there is already a dbus
instance running and start a NEW dbus instance. But the changes that gsettings
makes to this second dbus instance won't be written to the users dbus
database. The effect is that those changes won't have any effect.

-- 
Josef Wolf
jw at raven.inka.de





More information about the ubuntu-users mailing list