gnome-control-center talks to NetworkManager (via D-Bus) for configuring the network.
Even if the user cannot run the gnome-control-center application, they still can directly talk to NetworkManager via D-Bus. For example, via nmcli or nm-connection-editor or just plain dbus-send. Restricting which programs a user can run, won't work -- unless you care about only blocking users who would not know any better.
The way to restrict access to NetworkManager is via PolicyKit. See nmcli general permissions
for the actions, and which permissions the user has. Configure PolicyKit to restrict that to certain users. How to do that exactly, is a longer story.
Most read-only operations in NetworkManager however don't get checked by PolicyKit. Every user who can talk to D-Bus, can see them. To prevent a user to even see that, configure dbus-daemon (it also has policies that can prevent users from seeing the NetworkManager API). that again would be a longer story.
Finally, D-Bus works by using a unix socket (e.g. /var/run/dbus/system_bus_socket
). You can also take the unix permissions away from that user to even access D-Bus at all. However, that might break a lot of things, because D-Bus is just an IPC mechanism, and you basically disable this kind of inter process communication for the user, which may be too limiting (depending on what they should do).
How can we prevent these users (user_c, user_d) from turning the network connections ON/OFF?
nmcli general permissions
lists org.freedesktop.NetworkManager.enable-disable-network
PolicyKit permission. Disallow the user that.
EDIT: The permissions in the org.freedesktop.NetworkManager.policy PolicyKit file can be edited using the PolicyKit file found at:
/usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy
For the following actions, the permissions that are set to 'yes' by default, should be changed to 'auth_admin' :
org.freedesktop.NetworkManager.settings.modify.own
org.freedesktop.NetworkManager.network-control
org.freedesktop.NetworkManager.enable-disable-network
('yes' means that the action is allowed for any users.
'auth_admin' means that the action needs to authenticated by administrative users)
Initially, I had tried only modifying the permissions for org.freedesktop.NetworkManager.enable-disable-network
action.
However, I noticed that the non-admins could still turn the network connections on/off. So I included these other actions (listed above) as well.
This may be a bit overkill. But it works well.
Now it works as expected: For non-admin users, the option to configure the Network connection is disabled. An admin user can turn on/off the network connection after entering the password.
The different actions & permissions are documented at freedesktop.org/software/polkit/docs/latest/polkit.8.html