Python Plugin question

Python and python framework

Moderator: leecollings

Post Reply
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Python Plugin question

Post 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
The most dangerous phrase in any language is:
"We always done this way"
gerardvs
Posts: 81
Joined: Sunday 04 January 2015 0:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest-1
Location: /dev/null
Contact:

Re: Python Plugin question

Post 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
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Python Plugin question

Post 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.... :(
The most dangerous phrase in any language is:
"We always done this way"
gerardvs
Posts: 81
Joined: Sunday 04 January 2015 0:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest-1
Location: /dev/null
Contact:

Re: Python Plugin question

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest