Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to create a GUI that can enter root mode as well as Gparted applications
Qt 6.12 LTS is out! See what's new in the release blog

How to create a GUI that can enter root mode as well as Gparted applications

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++
19 Posts 6 Posters 5.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Something like kdesudo ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    ? 1 Reply Last reply
    1
    • SGaistS SGaist

      Hi,

      Something like kdesudo ?

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #3

      @SGaist Yes I know, but to implement it I do not know, if for GNOME does this work?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Gnome also has the equivalent. You can check the source of kdesudo for inspiration, or depending on your needs use the module itself.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        ? 1 Reply Last reply
        0
        • SGaistS SGaist

          Gnome also has the equivalent. You can check the source of kdesudo for inspiration, or depending on your needs use the module itself.

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #5

          @SGaist For example, to wear kdesudo in the application? For Qt.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            I don't understand your question

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            ? 2 Replies Last reply
            0
            • SGaistS SGaist

              I don't understand your question

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #7

              @SGaist I mean, give me a sample code to get into root mode in Qt GUI.

              1 Reply Last reply
              0
              • SGaistS SGaist

                I don't understand your question

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #8

                @SGaist I do not know to implement kdesudo to the application that I created.

                1 Reply Last reply
                0
                • jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  kdesudo is open source, so you can get the source code and see how kdesudo is doing it

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  ? 1 Reply Last reply
                  1
                  • jsulmJ jsulm

                    kdesudo is open source, so you can get the source code and see how kdesudo is doing it

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #10

                    @jsulm Yes I just know it, but on this issue I can not implement into my application.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      What do you mean by that ? You can't use the code ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      ? 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        What do you mean by that ? You can't use the code ?

                        ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #12

                        @SGaist True, I can not use. Please provide one project about taking kdesudo gui.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          Why can't you use ? Or do you mean you don't know how to use it ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          ? 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Why can't you use ? Or do you mean you don't know how to use it ?

                            ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #14

                            @SGaist Yes, I do not know how to use it, so I want to ask the tutorial to you.

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              Are you targeting KDE ? If so you can simply call Kdesudo using e.g. QProcess to execute what you need.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              ? 1 Reply Last reply
                              0
                              • SGaistS SGaist

                                Are you targeting KDE ? If so you can simply call Kdesudo using e.g. QProcess to execute what you need.

                                ? Offline
                                ? Offline
                                A Former User
                                wrote on last edited by A Former User
                                #16

                                @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.

                                1 Reply Last reply
                                0
                                • Hamed.MasafiH Offline
                                  Hamed.MasafiH Offline
                                  Hamed.Masafi
                                  wrote on last edited by
                                  #17

                                  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.

                                  Remote object sharing (OO RPC)
                                  http://forum.qt.io/topic/60680/remote-object-sharing-oo-rpc-solved

                                  Advanced, Powerful and easy to use ORM for Qt5
                                  https://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

                                  1 Reply Last reply
                                  1
                                  • _ Offline
                                    _ Offline
                                    _hunter
                                    wrote on last edited by
                                    #18

                                    @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?

                                    A 1 Reply Last reply
                                    0
                                    • _ _hunter

                                      @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?

                                      A Offline
                                      A Offline
                                      ambershark
                                      wrote on last edited by ambershark
                                      #19

                                      @_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.

                                      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                                      1 Reply Last reply
                                      3

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt
                                      • Unsolved