Allowing Users to Run System Apps in Gentoo

Content:

If you’re a Gentoo user, you might come across an issue with certain applications or tasks which prompt for the system (root) password. Ideally, the root user will not have a defined password, to prevent logins, which makes the prompt impossible to pass.

Fortunately, a simple polkit rule is all it takes to change the prompt, so the user password is required instead. This guide will show you how to make this change, as well as explaining the cause of the problem.

This technique can also be used with other distros, though generally this functionality will be configured out of the box.

Permissions Issues

By default, certain actions will prompt for the system administrator (root) password. This occurs even when the user has sudo privileges, as defined in the /etc/sudoers file.

The cause of this is down to the way certain actions request permissions. Actions which utilise sudo to gain root privileges will work correctly. System applications will often attempt to use a different authentication system, to provide an extra layer of security to the system.

Polkit Permissions

Polkit is an API designed to provide authentication services to system components, and any other applications which wish to include enhanced permission controls. It uses a set of rules to control the actions accessible to a user.

Without suitable polkit rules configured, administration tasks (including mounting external drives) will be blocked for a standard user. For this reason, the root password is requested.

To allow users of the wheel group to run admin tasks, a new polkit rule will need to be created. Create a new file in /etc/polkit-1/rules.d, with the .rules file extension. For example, /etc/polkit-1/rules.d/10-admin.rules.

In this file, add the following code:

polkit.addAdminRule(function(action, subject) {
    return ["unix-group:wheel"];
});

This creates the required rule to allow users of the wheel group to run admin tasks. If your admin group defined in /etc/sudoers has a different name, simply substitute this for ‘wheel’ in the code.

After a reboot, you should find that your system now prompts the user for their password, rather than the root password.