Simple.NFS.GUI icon indicating copy to clipboard operation
Simple.NFS.GUI copied to clipboard

sudo -H Simple_NFS_GUI gives "Invalid MIT-MAGIC-COOKIE-1" and "cannot open display: :10.0" (with fix)

Open kmbgit opened this issue 3 years ago • 0 comments

Running Simple_NFS_Client as root using "sudo" as per the instructions does not work on Ubuntu 22.04:-

$ sudo -H Simple_NFS_GUI 
[sudo] password for xxxx: 
Invalid MIT-MAGIC-COOKIE-1 key
(Simple_NFS_GUI:142938): Gtk-WARNING **: 11:38:41.399: cannot open display: :10.0

It needs to be run under pkexec, but care must be taken to pass $DISPLAY to the app - see https://unix.stackexchange.com/a/203149/85554.

I came up with this for /usr/share/polkit-1/actions/org.freedesktop.policykit.Simple_NFS_GUI.policy:

<?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/policyconfig.dtd">
<policyconfig>
    <action id="org.freedesktop.policykit.pkexec.Simple_NFS_GUI">
    <description>Run Simple_NFS_GUI program</description>
    <message>Authentication is required to run Simple_NFS_GUI</message>
    <defaults>
        <allow_any>auth_admin_keep</allow_any>
        <allow_inactive>auth_admin_keep</allow_inactive>
        <allow_active>auth_admin_keep</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/Simple_NFS_GUI</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
    </action>
</policyconfig>

Now when you run pkexec Simple_NFS_GUI you get prompted for your user password (assuming you're in the sudo group) and the app runs. You can also hack the command in the menu using the Main Menu editor to add pkexec to it, though there may be a better way!

kmbgit avatar Nov 15 '22 12:11 kmbgit