I have a desktop entry placed in usr/share/applications
that runs a Java jar and looks something like:
[Desktop Entry]
Encoding=UTF-8
Exec=pkexec /usr/bin/java -jar something-something.jar
Icon=default.png
Type=Application
Terminal=false
Name=foo
GenericName=bar
StartupNotify=false
Categories=Game
I need to run the JAR as root
, so I tried using pkexec
to have a GUI password prompt appear so I can run the JAR as sudo
(I am using Ubuntu 18). However, it would not work and when I tried to open the desktop entry in the terminal (using something like xdg-open
) I got: Refusing to render service to dead parents
I believe the problem is with my using pkexec
. While I would be interested to know why pkexec
does not work for my usage, I would like to know what I can do to run the JAR with sudo
from the GUI? That way, when I click on the desktop entry from the menu, a password prompt appears.
Edit:
Actually, I've been using gtk-open
and getting the dead parents error. xdg-open
results in the desktop entry simply being opened in vim
.
pkexec
is part of PolicyKit, which allows a finer distribution of rights. To execute programs with graphical user interface using pkexec, you can use the following call:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/java -jar something-something.jar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.