Manage services for a new user

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

To allow a non-sudo user to use nmcli for managing Wi-Fi connections and to manage services on a Toradex device running Torizon, you can follow these steps:

  1. Granting Network Permissions:

    • Since the netdev group is not available, you can create a custom group and assign the necessary permissions to it. For example, create a group called network:
      sudo groupadd network
      sudo usermod -aG network <username>
      
    • Adjust the permissions of the NetworkManager’s control socket to allow members of the network group to use nmcli:
      sudo chown root:network /var/run/NetworkManager
      sudo chmod 770 /var/run/NetworkManager
      
    • This setup allows users in the network group to interact with NetworkManager without needing sudo privileges.
  2. Managing Services without Sudo:

    • To allow a user to manage services without being a sudoer, you can use polkit to define specific rules. Create a policy file in /etc/polkit-1/rules.d/:
      polkit.addRule(function(action, subject) {
          if (action.id == "org.freedesktop.systemd1.manage-units" &&
              subject.isInGroup("service-managers")) {
              return polkit.Result.YES;
          }
      });
      
    • Create a group called service-managers and add your user to this group:
      sudo groupadd service-managers
      sudo usermod -aG service-managers <username>
      
    • This configuration allows users in the service-managers group to start, stop, and manage services using systemctl without requiring sudo.

By following these steps, you can grant the necessary permissions to your user for network management and service control without making them a sudoer. Ensure that you test these configurations in a safe environment before deploying them in production to avoid any unintended access issues.

Best regards,
Toradex AI Assistant.

Please, also check if these links can help you solve your problem:

https://docs.kernel.org/networking/can.html

Systemd service management on Torizon.