Unsolved How to create a GUI that can enter root mode as well as Gparted applications
-
Hello, does anyone want to help solve this problem? The problem is my problem to create a GUI that I made to enter root mode, as well as gparted application. If you answered wearing PolicyKit or Polkit, how?
-
Hi,
Something like kdesudo ?
-
@SGaist Yes I know, but to implement it I do not know, if for GNOME does this work?
-
Gnome also has the equivalent. You can check the source of kdesudo for inspiration, or depending on your needs use the module itself.
-
@SGaist For example, to wear kdesudo in the application? For Qt.
-
I don't understand your question
-
@SGaist I mean, give me a sample code to get into root mode in Qt GUI.
-
@SGaist I do not know to implement kdesudo to the application that I created.
-
kdesudo is open source, so you can get the source code and see how kdesudo is doing it
-
@jsulm Yes I just know it, but on this issue I can not implement into my application.
-
What do you mean by that ? You can't use the code ?
-
@SGaist True, I can not use. Please provide one project about taking kdesudo gui.
-
Why can't you use ? Or do you mean you don't know how to use it ?
-
@SGaist Yes, I do not know how to use it, so I want to ask the tutorial to you.
-
Are you targeting KDE ? If so you can simply call Kdesudo using e.g. QProcess to execute what you need.
-
@SGaist Is it just like that? Instead will be looping continuously? If I use the method if else, it generates Segmentation fault.
So I want it like this. If the user was not logged in root mode, then he gave the password root and opened the application, if he has entered the root mode, then he does not need to enter a password. -
The desktop environment is not matter. Your application should have a .desktop file. In this file (Menu entry) you can set the app how should be show on menu, or how should be executed. In this example:
[Desktop Entry] Exec=/home/blackdal/Desktop/webdesigner GenericName=This is my test application Icon=exec Name=Test App Path=/home/blackdal StartupNotify=true Terminal=false X-DBUS-StartupType=none X-KDE-SubstituteUID=true X-KDE-Username=root
I've created a sample file named 'My App.desktop' in the line that X-KDE-Username seted to root define that this app will be run as root user.
-
@Renn said in How to create a GUI that can enter root mode as well as Gparted applications:
gparted
hi,did you solve this problem?I also meet this kind of problem,can you help me?
-
@_hunter This thread is 3 years old. You would have been better off starting a new one.
That being said, the normal way for getting root to a gui application in linux is
sudo -E ./yourapp
. Or using something like kdesudo or gksu, etc. Very very few applications try to escalate their permissions dynamically. Linux users are used to having to launch apps like gparted with kdesu or sudo -E.If your app requires root all the time and you don't want to have to launch with sudo or something, then install it with the sticky bit set to run as root and set it's user to root. Note: this is typically frowned on because of the security holes it opens if your app has any security issues like buffer overflows that can be used to gain a root shell.
Oh and the actual thing you were looking for is
pkexec
. That is how gparted launches as a different user graphically. It just uses pkexec to restart itself as root.