mycroft-core icon indicating copy to clipboard operation
mycroft-core copied to clipboard

Starting as superuser will break permissions of tmp files

Open SekoiaTree opened this issue 3 years ago • 2 comments

Describe the bug Launching start_mycroft.sh as superuser makes the files in /tmp/mycroft only readable to root. This crashes the bus when launched in non-superuser. Launching as root causes other issues.

To Reproduce Steps to reproduce the behavior:

  1. Run sudo ./start-mycroft.sh all
  2. Run sudo ./stop-mycroft.sh
  3. Run ./start-mycroft.sh all
  4. Run ./start-mycroft.sh cli
  5. Check logs, see crash.

Expected behavior CLI connects to bus.

Log files

PermissionError: [Errno 13] Permission denied: '/tmp/mycroft/service.pid'
2022-11-19 00:39:20.714 | INFO     | 95140 | __main__:main:50 | Starting message bus service...
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "[removed by SekoiaTree]/mycroft-core/mycroft/messagebus/service/__main__.py", line 72, in <module>
    main()
  File "[removed by SekoiaTree]/mycroft-core/mycroft/messagebus/service/__main__.py", line 52, in main
    lock = Lock("service")
  File "[removed by SekoiaTree]/mycroft-core/mycroft/lock/__init__.py", line 119, in __init__
    self.create()
  File "[removed by SekoiaTree]/mycroft-core/mycroft/lock/__init__.py", line 173, in create
    self.touch()
  File "[removed by SekoiaTree]/mycroft-core/mycroft/lock/__init__.py", line 160, in touch
    with open(self.path, 'w') as L:
PermissionError: [Errno 13] Permission denied: '/tmp/mycroft/service.pid'

**Environment (please complete the following information):**
 - Device type: desktop
 - OS: Ubuntu (Pop!_OS)
 - Mycroft-core version: 21.2.2

**Additional context**
Probably shouldn't run it as sudo, but still, feel like it's worth reporting. Maybe a check if running as root with a warning and an override?

Since the broken files are in /tmp/mycroft/, removing those files fixes this entirely (until you run the bus as superuser again).

SekoiaTree avatar Nov 18 '22 23:11 SekoiaTree

Hi there, thanks for reporting this.

I'm guessing you've already come to the conclusion that you shouldn't run Mycroft with sudo. But it would be nice to add in something that actually prevents people from causing this. Or at least makes them jump through a small hoop to make sure they truly want to do it.

I've marked it as help wanted so others might take a look. It's not something we'll be prioritizing at the moment.

Thanks

krisgesling avatar Nov 21 '22 22:11 krisgesling

Understandable, thanks!

SekoiaTree avatar Nov 22 '22 08:11 SekoiaTree