I have opened this thread because gksu is depreciated and as some of us are finding out gksu sometimes gets broken for some of us. I am now thinking that it is sensible to switch to using pkexec. It is not a replacement for gksu but it can be used to give root privileges to certain applications but we need to create a policy file for those applications.
Ubuntu comes with a set of policies and we find them in /usr/share/polkit-1/actions/. We can follow the pattern used in those policies to create policies ourselves. This is a policy for Gedit that someone in U+1 provided about a year ago. So, I am not claiming credit for this.
1) create this file
/usr/share/polkit-1/actions/com.ubuntu.gedit.policy
2) put in the file this code
Now we can launch Gedit with root privileges usingCode:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd"> <policyconfig> <vendor>gedit</vendor> <vendor_url>gedit</vendor_url> <icon_name>accessories-text-editor</icon_name> <action id="org.freedesktop.policykit.pkexec.gedit"> <description>Run "gedit"</description> <message>Authentication is required to run Text Editor</message> <defaults> <allow_any>auth_admin</allow_any> <allow_inactive>auth_admin</allow_inactive> <allow_active>auth_admin</allow_active> </defaults> <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/gedit</annotate> <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> </action> </policyconfig>
By following that pattern I have come up with this for nautilusCode:pkexec gedit
File name /usr/share/polkit-1/actions/com.ubuntu.nautilus.policy
Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd"> <policyconfig> <vendor>nautilus</vendor> <vendor_url>nautilus</vendor_url> <icon_name>system-file-manager</icon_name> <action id="org.freedesktop.policykit.pkexec.nautilus"> <description>Run "nautilus"</description> <message>Authentication is required to run File Manager</message> <defaults> <allow_any>auth_admin</allow_any> <allow_inactive>auth_admin</allow_inactive> <allow_active>auth_admin</allow_active> </defaults> <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/nautilus/annotate> <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> </action> </policyconfig>Make use of it if you will and add to the thread any policies that you come up with that would be useful to a Ubuntu development tester.Code:pkexec nautilus
Regards



Adv Reply




Bookmarks