`/etc/polkit-1/rules.d/46-test.rules`:
```
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.NetworkManager.settings.modify.system" &&
subject.user == "benjamin_loison") {
return polkit.Result.YES;
}
});
```

How to check if `action.id` starts with `org.freedesktop.NetworkManager`?
Jul 26, 8:25pm

To check if the action.id starts with the string "org.freedesktop.NetworkManager" in your Polkit rule, you can use the JavaScript startsWith() method. Here's how you can modify your rule to include this check:

javascript
polkit.addRule(function(action, subject) {
    if (action.id.startsWith("org.freedesktop.NetworkManager") &&
        subject.user == "benjamin_loison") {
        return polkit.Result.YES;
    }
});

Explanation:

  • action.id.startsWith("org.freedesktop.NetworkManager"): This checks if the action.id begins with the specified string.
  • The rest of the rule remains the same, ensuring that the user benjamin_loison is allowed to perform actions where the action.id starts with "org.freedesktop.NetworkManager".

This approach is clean and directly leverages JavaScript's built-in string methods.

Jul 26, 8:25pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more