Problem:
How can I run a script owned by root with root permission as normal user?
Let's take for example a folder /path/to/folder
.
First I make sure that the folder and all content is owned by root:
sudo chown -R root:root /path/to/folder
Then I tried different approaches of giving permissions to other users:
sudo chmod -R +x /path/to/folder
sudo chmod -R u+s /path/to/folder
sudo chmod -R 4755 /path/to/folder
But the script I want to run, still gives me:
Can't open /dev/mem: Permission denied
Detailed
I have a Flask application which changes colours of an led-strip according to incoming requests.
Regardless of which library is used, accessing GPIO always needs root permission.
I would like to change this for two reasons:
I am using venv and running the app with
sudo
causes the globally installed python packaged to be used rather than the ones in venv.In its finished state the application should run in apache. So far I didn't get apache to run the app with sudo.
I would like to focus on the main problem, rather than Flask or the led-strip library.
Thanks in advance!
Edit
I looked into the suggested question and my user is in the gpio group, the dev/gpiomem
folder exists and has the exact same permissions and still I get the /dev/mem
permission denied error.
Now I found out, that the package I am using apparently uses /dev/mem
exclusively and doesn't support /dev/gpiomem
.
(https://github.com/jgarff/rpi_ws281x)
I'm now looking for an alternative and I am open for suggestions :-)