I have to use a home-built tool at my company which requires 'root' privileges.
To make things worse, it's a GUI application. Normally, I wouldn't execute such things, but I don't have much of a choice.
Currently, I am using
xhost + && sudo java -jar servermanager.jar && xhost -
to execute the application. This means though, that for the time java is running, access control to the X-Server is disabled.
Granted, this might not be the worst of security issues, but it still got me wondering whether there is a better timed method to execute xhost - immediately after the application has opened its X connection.
TL;DR: How can I execute a command right after a GUI window has opened?