Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Debian]Set an auto password in code for SU in Konsole
Forum Updated to NodeBB v4.3 + New Features

[Debian]Set an auto password in code for SU in Konsole

Scheduled Pinned Locked Moved Unsolved General and Desktop
ccoun
9 Posts 5 Posters 1.6k 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.
  • L Offline
    L Offline
    Lenawel
    wrote on last edited by Lenawel
    #1

    Hello everybody ,

    I am currently working on a project that would allow users to configure their computer's network from a graphical interface and not to modify files (/etc/network/interfaces) or using some commands with Konsole .
    The application works great when i am connect in SU account .but I don't want these users have some access on this account or use sudo commands .
    So i will try to put in my GUI application a Konsole who oppening and running all commands for delete and copy /etc/network/interfaces when the user click on "Ok" button .
    I've already gone a bit but I'm stuck because I can only place One order. Beyond the console opens and crash immediately. i will need your help to solve this error and give me some tips to continu my project.

    Thanck you i give you a part of my work.

    QProcess ConsoleObtentionDroit;
    QStringList arguments;
    arguments <<"-e"
              <<"su";
    ConsoleObtentionDroit.startDetached("konsole", arguments);
    ConsoleObtentionDroit.waitForFinished();
    

    This is works but i have this warning

    Qdbusconnection session d-bus connection created before Qcoreapplication. application may misbehave
    

    but if i make

    QProcess ConsoleObtentionDroit;
    QStringList arguments;
    arguments <<"-e"
              <<"su"
              <<"-e"
              <<"password";
    ConsoleObtentionDroit.startDetached("konsole", arguments);
    ConsoleObtentionDroit.waitForFinished();
    

    its a crash

    aha_1980A 1 Reply Last reply
    0
    • L Lenawel

      Hello everybody ,

      I am currently working on a project that would allow users to configure their computer's network from a graphical interface and not to modify files (/etc/network/interfaces) or using some commands with Konsole .
      The application works great when i am connect in SU account .but I don't want these users have some access on this account or use sudo commands .
      So i will try to put in my GUI application a Konsole who oppening and running all commands for delete and copy /etc/network/interfaces when the user click on "Ok" button .
      I've already gone a bit but I'm stuck because I can only place One order. Beyond the console opens and crash immediately. i will need your help to solve this error and give me some tips to continu my project.

      Thanck you i give you a part of my work.

      QProcess ConsoleObtentionDroit;
      QStringList arguments;
      arguments <<"-e"
                <<"su";
      ConsoleObtentionDroit.startDetached("konsole", arguments);
      ConsoleObtentionDroit.waitForFinished();
      

      This is works but i have this warning

      Qdbusconnection session d-bus connection created before Qcoreapplication. application may misbehave
      

      but if i make

      QProcess ConsoleObtentionDroit;
      QStringList arguments;
      arguments <<"-e"
                <<"su"
                <<"-e"
                <<"password";
      ConsoleObtentionDroit.startDetached("konsole", arguments);
      ConsoleObtentionDroit.waitForFinished();
      

      its a crash

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @Lenawel

      I don't have an answer for your problem, but a suggestion how to give your program root access privileges.

      1. setuid
      2. Linux capabilities

      The most common way is to "set user ID root" for a program, which means it gains root rights when running. As this gives your program access to everything, the capabilities were invented. Here you have fine-grained permission settings for your program.

      In both cases, the user would not need to enter a password at runtime :)

      Qt has to stay free or it will die.

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

        Hi,

        Isn't that what NetworkManager is for with the help for example of Plasma NM ?

        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
        • L Offline
          L Offline
          Lenawel
          wrote on last edited by
          #4

          thx for your answer but i need to not install another programm i must make all the commands in the code (cant use shell or another things like that)

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @Lenawel said in [Debian]Set an auto password in code for SU in Konsole:

            Qdbusconnection session d-bus connection created before Qcoreapplication.

            Hi
            That normally comes from using global variables.
            Do you have any you use in the code shown ?
            Like before main.

            L 1 Reply Last reply
            0
            • mrjjM mrjj

              @Lenawel said in [Debian]Set an auto password in code for SU in Konsole:

              Qdbusconnection session d-bus connection created before Qcoreapplication.

              Hi
              That normally comes from using global variables.
              Do you have any you use in the code shown ?
              Like before main.

              L Offline
              L Offline
              Lenawel
              wrote on last edited by
              #6

              @mrjj
              hi ,
              No i have only 1 class and 0 variables on my main

              jsulmJ mrjjM 2 Replies Last reply
              0
              • L Lenawel

                @mrjj
                hi ,
                No i have only 1 class and 0 variables on my main

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Lenawel said in [Debian]Set an auto password in code for SU in Konsole:

                0 variables on my main

                They do not have to be in main. Any static variables anywhere in your app of a Qt type depending on QApplication instance is bad.

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

                1 Reply Last reply
                0
                • L Lenawel

                  @mrjj
                  hi ,
                  No i have only 1 class and 0 variables on my main

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Lenawel

                  Hi
                  Ok. if we can find out why it says "before Qcoreapplication"
                  then all should be good.

                  Where do it say this exactly ?

                  does konsole say this or is it your app ?

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    Lenawel
                    wrote on last edited by
                    #9

                    it's when my app runing this error spawn on Qt windows debug

                    1 Reply Last reply
                    0

                    • Login

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