Unable to execute GUI application as a different user using `pkexec`

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have created following policy file at /usr/share/polkit-1/actions/com.xyz.xyz.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>
<vendor>XYZ Technologies Inc.</vendor>
<vendor_url>http://www.xyz.com</vendor_url>
<action id="org.xyz.policykit.pkexec.run-xyz">
<description>Run XYZ</description>
<message>Authentication is required to run XYZ</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/xyz</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
</action>
</policyconfig>


and desktop file at /usr/local/share/applications/xyz-gui-root.desktop



[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Name[en_in]=XYZ administrator (root)
Exec=pkexec xyz
Comment[en_IN]=Launches XYZ administrator
Name=XYZ administrator (root)
Comment=Launches XYZ administrator
Icon[en_IN]=/xyz/xyzroot.png
Icon=/xyz/xyzroot.png


When I search XYZ and run through Activity->Search, it doesn't show any activity, not even ask for password. But double clicking on xyz-gui-root.desktop file it works as expected with password authentication.



If I change



Exec=pkexec xyz


as



Exec=gnome-terminal -x pkexec xyz


it works fine with Activity->Search with authentication, but it opens a unwanted terminal.



What I am missing in above files? How can I avoid unwanted terminal to open with gnome-terminal entry? Is there any way to execute GUI application with authentication using pkexec or any other method like consolehelper?



Thanks in advance!







share|improve this question
























    up vote
    1
    down vote

    favorite












    I have created following policy file at /usr/share/polkit-1/actions/com.xyz.xyz.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>
    <vendor>XYZ Technologies Inc.</vendor>
    <vendor_url>http://www.xyz.com</vendor_url>
    <action id="org.xyz.policykit.pkexec.run-xyz">
    <description>Run XYZ</description>
    <message>Authentication is required to run XYZ</message>
    <defaults>
    <allow_any>no</allow_any>
    <allow_inactive>no</allow_inactive>
    <allow_active>auth_admin</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/xyz</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
    </action>
    </policyconfig>


    and desktop file at /usr/local/share/applications/xyz-gui-root.desktop



    [Desktop Entry]
    Encoding=UTF-8
    Version=1.0
    Type=Application
    Terminal=false
    Name[en_in]=XYZ administrator (root)
    Exec=pkexec xyz
    Comment[en_IN]=Launches XYZ administrator
    Name=XYZ administrator (root)
    Comment=Launches XYZ administrator
    Icon[en_IN]=/xyz/xyzroot.png
    Icon=/xyz/xyzroot.png


    When I search XYZ and run through Activity->Search, it doesn't show any activity, not even ask for password. But double clicking on xyz-gui-root.desktop file it works as expected with password authentication.



    If I change



    Exec=pkexec xyz


    as



    Exec=gnome-terminal -x pkexec xyz


    it works fine with Activity->Search with authentication, but it opens a unwanted terminal.



    What I am missing in above files? How can I avoid unwanted terminal to open with gnome-terminal entry? Is there any way to execute GUI application with authentication using pkexec or any other method like consolehelper?



    Thanks in advance!







    share|improve this question






















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have created following policy file at /usr/share/polkit-1/actions/com.xyz.xyz.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>
      <vendor>XYZ Technologies Inc.</vendor>
      <vendor_url>http://www.xyz.com</vendor_url>
      <action id="org.xyz.policykit.pkexec.run-xyz">
      <description>Run XYZ</description>
      <message>Authentication is required to run XYZ</message>
      <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin</allow_active>
      </defaults>
      <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/xyz</annotate>
      <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
      </action>
      </policyconfig>


      and desktop file at /usr/local/share/applications/xyz-gui-root.desktop



      [Desktop Entry]
      Encoding=UTF-8
      Version=1.0
      Type=Application
      Terminal=false
      Name[en_in]=XYZ administrator (root)
      Exec=pkexec xyz
      Comment[en_IN]=Launches XYZ administrator
      Name=XYZ administrator (root)
      Comment=Launches XYZ administrator
      Icon[en_IN]=/xyz/xyzroot.png
      Icon=/xyz/xyzroot.png


      When I search XYZ and run through Activity->Search, it doesn't show any activity, not even ask for password. But double clicking on xyz-gui-root.desktop file it works as expected with password authentication.



      If I change



      Exec=pkexec xyz


      as



      Exec=gnome-terminal -x pkexec xyz


      it works fine with Activity->Search with authentication, but it opens a unwanted terminal.



      What I am missing in above files? How can I avoid unwanted terminal to open with gnome-terminal entry? Is there any way to execute GUI application with authentication using pkexec or any other method like consolehelper?



      Thanks in advance!







      share|improve this question












      I have created following policy file at /usr/share/polkit-1/actions/com.xyz.xyz.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>
      <vendor>XYZ Technologies Inc.</vendor>
      <vendor_url>http://www.xyz.com</vendor_url>
      <action id="org.xyz.policykit.pkexec.run-xyz">
      <description>Run XYZ</description>
      <message>Authentication is required to run XYZ</message>
      <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin</allow_active>
      </defaults>
      <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/xyz</annotate>
      <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
      </action>
      </policyconfig>


      and desktop file at /usr/local/share/applications/xyz-gui-root.desktop



      [Desktop Entry]
      Encoding=UTF-8
      Version=1.0
      Type=Application
      Terminal=false
      Name[en_in]=XYZ administrator (root)
      Exec=pkexec xyz
      Comment[en_IN]=Launches XYZ administrator
      Name=XYZ administrator (root)
      Comment=Launches XYZ administrator
      Icon[en_IN]=/xyz/xyzroot.png
      Icon=/xyz/xyzroot.png


      When I search XYZ and run through Activity->Search, it doesn't show any activity, not even ask for password. But double clicking on xyz-gui-root.desktop file it works as expected with password authentication.



      If I change



      Exec=pkexec xyz


      as



      Exec=gnome-terminal -x pkexec xyz


      it works fine with Activity->Search with authentication, but it opens a unwanted terminal.



      What I am missing in above files? How can I avoid unwanted terminal to open with gnome-terminal entry? Is there any way to execute GUI application with authentication using pkexec or any other method like consolehelper?



      Thanks in advance!









      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 16 '17 at 13:30









      Nitinkumar Ambekar

      1456




      1456




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          The complete answer for my question is here. In short:



          1) Create a shell script as /usr/local/bin/foo.sh:



          #!/bin/sh
          pkexec "/usr/sbin/foo" "$@"


          2) Give executable permission to above script:



          chmod +x /usr/local/bin/foo.sh


          3) If you are using .desktop file, change Exec value as:



          Exec=/usr/local/bin/foo.sh


          4) Make sure that your policy file in /usr/share/polkit-1/actions/ has following entry to allow GUI:



          <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>


          Thats it!






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f411251%2funable-to-execute-gui-application-as-a-different-user-using-pkexec%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            The complete answer for my question is here. In short:



            1) Create a shell script as /usr/local/bin/foo.sh:



            #!/bin/sh
            pkexec "/usr/sbin/foo" "$@"


            2) Give executable permission to above script:



            chmod +x /usr/local/bin/foo.sh


            3) If you are using .desktop file, change Exec value as:



            Exec=/usr/local/bin/foo.sh


            4) Make sure that your policy file in /usr/share/polkit-1/actions/ has following entry to allow GUI:



            <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>


            Thats it!






            share|improve this answer
























              up vote
              1
              down vote



              accepted










              The complete answer for my question is here. In short:



              1) Create a shell script as /usr/local/bin/foo.sh:



              #!/bin/sh
              pkexec "/usr/sbin/foo" "$@"


              2) Give executable permission to above script:



              chmod +x /usr/local/bin/foo.sh


              3) If you are using .desktop file, change Exec value as:



              Exec=/usr/local/bin/foo.sh


              4) Make sure that your policy file in /usr/share/polkit-1/actions/ has following entry to allow GUI:



              <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>


              Thats it!






              share|improve this answer






















                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                The complete answer for my question is here. In short:



                1) Create a shell script as /usr/local/bin/foo.sh:



                #!/bin/sh
                pkexec "/usr/sbin/foo" "$@"


                2) Give executable permission to above script:



                chmod +x /usr/local/bin/foo.sh


                3) If you are using .desktop file, change Exec value as:



                Exec=/usr/local/bin/foo.sh


                4) Make sure that your policy file in /usr/share/polkit-1/actions/ has following entry to allow GUI:



                <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>


                Thats it!






                share|improve this answer












                The complete answer for my question is here. In short:



                1) Create a shell script as /usr/local/bin/foo.sh:



                #!/bin/sh
                pkexec "/usr/sbin/foo" "$@"


                2) Give executable permission to above script:



                chmod +x /usr/local/bin/foo.sh


                3) If you are using .desktop file, change Exec value as:



                Exec=/usr/local/bin/foo.sh


                4) Make sure that your policy file in /usr/share/polkit-1/actions/ has following entry to allow GUI:



                <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>


                Thats it!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 18 '17 at 10:15









                Nitinkumar Ambekar

                1456




                1456






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f411251%2funable-to-execute-gui-application-as-a-different-user-using-pkexec%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)