Run Streamlit without root permissions

Hi,

I want to run a streamlit app on a linux server on which I do not have root permissions.
I installed all dependencies using pip with --user flag.

For testing, a port was assigned to me.
So I started streamlit with --server.port and --browser.serverAddress set according to our Network.
As I started streamlit for testing, I was prompted for root PW. This is odd, I thought to myself…
Anyways, I ignored it. I checked the browser and streamlit seems to run. (Got some errors presumably unrelated to this problem).
A few minutes later, the admin called and said that I am spamming him with security alerts since something streamlit related tries to execute some stuff as root every few seconds.
More precisely:
USER=root ; COMMAND=dbus-uuidgen --ensure

Any ideas what this is ?
I thought streamlit can be run without root permissions.

kind regards

Hey @BitBernd!

First off, Welcome to the Streamlit Community! :partying_face: :tada: :tada: :partying_face: :partying_face: :tada:

I’m sorry this is happening and thank you for bringing it to our attention! This is actually a problem that has been seen before: https://github.com/streamlit/streamlit/issues/1584

Are you also working in a Linux environment? Can you let us know what version of Streamlit you have installed?

I have let our Product Manager, @abhi, know about your issue. Now that we know it is not an isolated incident, we can get a better understanding of what is happening and get a workaround/fix in the making!

Sorry for not being able to fix this for you immediately!

Marisa

1 Like

Hi,

thanks for the fast reply!

The Host machine is a virtualized Gentoo: 4.19.27-gentoo-r1-kvmU
Python Version: 3.7.9
Streamlit Version: 0.70.0

1 Like

Hey @BitBernd,

No problem, I like to try and get on top of potential :beetle: as fast as possible! :racing_car:

Thanks for the details on your system setup, I have already send these details internally so we can get to bug hunting!

Thanks so much!
Marisa

Hi @BitBernd

This is a known issue on our end. This piece of code is invoked to generate a machine-id as part of our metrics collection pipeline. We collect some aggregated metrics to improve our open source product offering(See our privacy policy for details: https://www.streamlit.io/privacy-policy, no data from apps is collected).

We have observed this issue in containerized environments and we are working on a long term solution over the next couple of months. In the short term, here are 2 workarounds to unblock you:

Option #1
Comment out some of the code in [streamlit_path]/lib/streamlit/metrics_util.py

if (
platform.system() == “Linux”
and os.path.isfile("/etc/machine-id") == False
and os.path.isfile("/var/lib/dbus/machine-id") == False
):
subprocess.run([“sudo”, “dbus-uuidgen”, “–ensure”])

Option #2
If the first option isn’t feasible, then you can try to get the admin with root privileges generate the following files:

cat “12345” | sudo tee -a /etc/machine-id
cat “12345” | sudo tee -a /var/lib/dbus/machine-id

This will generate a machine-id which will work with metrics_util.py and should not throw an error anymore.

Thanks,
Abhi