Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Enhance Meshtastic Native Daemon systemd script for better security and resource management #3747

Open
mgoljak opened this issue Apr 29, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mgoljak
Copy link

mgoljak commented Apr 29, 2024

Platform

NRF52, ESP32

Description

The current Meshtastic Native Daemon systemd script runs as the root user, which is generally considered a security risk. Additionally, it lacks automatic service restarts in case of failure and doesn't limit resource consumption effectively.

Proposed Changes

  • Change the service user and group to a dedicated "meshtastic" user.
  • Add the “meshtastic” user to the 995(spi), 994(i2c), and 993(gpio) groups on Raspberry Pi OS.
  • Add automatic service restarts on failure.
  • Set resource limits (such as CPU weight) to prevent excessive resource usage.
  • Add AmbientCapabilities=CAP_NET_BIND_SERVICE to the systemd script.

Example Modified systemd Script

[Unit]
Description=Meshtastic Native Daemon
After=network-online.target

[Service]
User=meshtastic
Group=meshtastic
Type=simple
ExecStart=/usr/sbin/meshtasticd
Restart=on-failure
RestartSec=5s
StartLimitBurst=2
StartLimitInterval=150s
Nice=10
CPUWeight=1
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

Please review and provide feedback!

@mgoljak mgoljak added the enhancement New feature or request label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants