[Debian]Set an auto password in code for SU in Konsole
-
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
-
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
Hi @Lenawel
I don't have an answer for your problem, but a suggestion how to give your program root access privileges.
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 :)
-
Hi,
Isn't that what NetworkManager is for with the help for example of Plasma NM ?
-
@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. -
@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. -
@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.