linux - Authenticating GTK app to run with root permissions -


For Linux, a UI app (uses GTK) must be run as a root (it reads and / dev / writes)

SD *).

While the user needs to open the root app or use "sudo" manually manually, I wonder if the app can access some OS-provided APIs for root permissions. (Note: GTK app's "Setuid" mode can not be used, so this is not an option.)

Here the benefits will be an easy workflow: the user can double-click the user's default user account Instead of opening a root terminal and launching it from there, my app from desktop

I ask this because OS X offers exactly this type: An app can ask OS to execute executable with root permissions - OS (and no app) then the user will have to Asks to input credentials, verifies them and then launches the desired target.

I am surprised that something similar is for Linux (like Ubuntu)

Explanation:

< P> So, after the signal on the monitored I wonder if I use r / w to use "/ Dev / sd ..." block device I think it is very difficult to understand, so I have Was asked before that before I could spend it in hours to understand it in vain it is possible.

Update:

Escape is a remote operating disk repair tool for unusual Linux users, and sudo to those Linux nodes Would not have much understanding of using or even changing their user group membership, especially if their discs just started acting and they are angry, this is the reason why I find a solution that is similar to the technical Avoids

The old way, simple but now being phased out, is the discussion of the future of GKSU .

To use the new way I'm pretty sure how it works, but I think you need to use your code with the pkexec command.

Update:

Looking at the example code, it looks like you have the .policy files in / usr You can use PolicyKit to obtain authorization for some of the tasks described by / share / polkit -1 / action . The action to implement a program as another user is org.freedesktop.policykit.exec . I am not getting any work to reach the block device directly, but I have to admit that the policycit documentation breaks my mind too.

Therefore, the easiest way to act for you is to have your disk-mangling code privileged in a command line utility, and it should be g_spawn_ [a] sync () With the pkexec can be run from your GUI application. In this way, you will not have to bother with requests for action and things like that. This is probably a bad practice, so that your entire GUI application can be run as a root.

Another suggestion is to ask directly to the author of PolicyKit (David Zethane) or try posting on your question gtk-app-devel list.


Comments

Popular posts from this blog

bytearray - Removing trailing nulls from byte array in C# -

WPF TextBlock Overflow Text to the Left -