Page 1 of 1

Python Plugin question

Posted: Tuesday 21 March 2017 12:42
by emme
...just a quick question... I think I already know the answer but.. just to be sure:

Domotiz runs as root user...
are Python plugin under the same rule? (so they run as root?)

what If I want to run them as another user?...is that possible?
ciao
M

Re: Python Plugin question

Posted: Tuesday 21 March 2017 17:16
by gerardvs
Never, ever, run Domoticz or any other service as root. This sentence should be read at least 10 times. :!:

That said, any process started by another process will run in the same user-context. So if Domoticz is running as userX, everything else will run as the same user. You could start, e.g. via the Python plugin, another process as another user. Maybe you have a reason to do so but I can't think of any.

--Gerard

Re: Python Plugin question

Posted: Tuesday 21 March 2017 19:12
by emme
My question was in regards of a plugin I'm writing and for which I'm stucked at base level...
I'm using gattlib, that must be run as root to get access to hci0 interface

the plugin doesn't run, so I was wondoering if it could be a user problem, but I assume it is not.... :(

Re: Python Plugin question

Posted: Tuesday 21 March 2017 20:01
by gerardvs
Well, I suppose it's running ok outside domoticz?
Just to be sure you can check from within the plugin if indeed you are running within the root context.

This is how I start (sub)processes

Code: Select all

import subprocess

prc = subprocess.run(['whoami'], stdout=subprocess.PIPE)
iAm = prc.stdout.decode('utf-8')
Domoticz.Log("I am user:" + iAm)
--Gerard