Running application with user privillegions.
-
You could ask ai or search on google
sudo cp your_program.exe /usr/local/bin/your_program sudo chmod +x /usr/local/bin/your_programThese are Linux-related tasks.
@Joe-von-Habsburg said in Running application with user privillegions.:
sudo chmod +x /usr/local/bin/your_program
It's already executable after the copy, and
chmod +xdoes nothing more than it already is. It does not make the executable run as root. You want/intended instead:chmod u+s path-to-executableso it will look like:
root@ubuntu-22:~/QtTests/C++/sudopassword/build/Desktop-Debug# chmod u+s fred root@ubuntu-22:~/QtTests/C++/sudopassword/build/Desktop-Debug# ls -l fred -rwsr-xr-x 1 root root 379112 Mar 30 08:48 fredNote the
-rws, thesthere.Note that you will need to repeat the
chmodevery time after you recompile/recopy your executable. If you redistribute your executable then wherever it gets installed the root user would need to choose to run thechmod u+sthere once, you cannot distribute (I don't think) with the executable owned by root and setuid. -
You have ubuntu. I have Debian. This is method change chmod, not exit for programmers.First post with running command very nice,but not full.
-
You have ubuntu. I have Debian. This is method change chmod, not exit for programmers.First post with running command very nice,but not full.
@nicholas_ru
Did you even try it?? Debian man page https://manpages.debian.org/bookworm/coreutils/chmod.1.en.htmlEach MODE is of the form
'[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.How else would you setuid under Debian? No point my suggesting things if they do work but you say they do not.
.First post with running command very nice,but not full.
If you mean @Joe-von-Habsburg 's
QString command = QString("echo %1 | sudo -S %2").arg(1234).arg("ifconfig")it won't work as written if passed toQProcess::start().... But I am getting a bit dispirited trying to help you so up to you. -
@nicholas_ru
Did you even try it?? Debian man page https://manpages.debian.org/bookworm/coreutils/chmod.1.en.htmlEach MODE is of the form
'[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.How else would you setuid under Debian? No point my suggesting things if they do work but you say they do not.
.First post with running command very nice,but not full.
If you mean @Joe-von-Habsburg 's
QString command = QString("echo %1 | sudo -S %2").arg(1234).arg("ifconfig")it won't work as written if passed toQProcess::start().... But I am getting a bit dispirited trying to help you so up to you.@JonB said in Running application with user privillegions.:
But I am getting a bit dispirited trying to help you so up to you.
:(
@nicholas_ru said in Running application with user privillegions.:
You have ubuntu. I have Debian. This is method change chmod, not exit for programmers.First post with running command very nice,but not full.
so ? linux is linux and there is a qt forum. we try to help you
-
@JonB said in Running application with user privillegions.:
But I am getting a bit dispirited trying to help you so up to you.
:(
@nicholas_ru said in Running application with user privillegions.:
You have ubuntu. I have Debian. This is method change chmod, not exit for programmers.First post with running command very nice,but not full.
so ? linux is linux and there is a qt forum. we try to help you
@Joe-von-Habsburg said in Running application with user privillegions.:
But I am getting a bit dispirited trying to help you so up to you.
:(
To be clear: it is the OP I am getting "dispirited" trying to help, not your posts! :)
He could use your code approach (perhaps, if that is what he wants), just that it needs changing to work. But since we (at least I) don't even know exactly what he wants I have not corrected it so far, waiting to see.....
-
@nicholas_ru
Did you even try it?? Debian man page https://manpages.debian.org/bookworm/coreutils/chmod.1.en.htmlEach MODE is of the form
'[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.How else would you setuid under Debian? No point my suggesting things if they do work but you say they do not.
.First post with running command very nice,but not full.
If you mean @Joe-von-Habsburg 's
QString command = QString("echo %1 | sudo -S %2").arg(1234).arg("ifconfig")it won't work as written if passed toQProcess::start().... But I am getting a bit dispirited trying to help you so up to you.@JonB i am think in Qt framework must be integrated this is function.
-
@JonB i am think in Qt framework must be integrated this is function.
@nicholas_ru No idea what you mean. You have plenty of answers & suggestions above, so over to you to do something....
-
@nicholas_ru No idea what you mean. You have plenty of answers & suggestions above, so over to you to do something....
@JonB if QProcess running with root true, if without false.
-
@JonB if QProcess running with root true, if without false.
@nicholas_ru
Again, I don't know what that phrase means. You might trying typing in your questions/answers with full detail in your native language into Google and asking it to translate to English, that may give a more meaningful question.We have explained what the possibilities are for running programs under Linux setuid/as root. You have to pick one. You have to try the suggestions you have been given. I don't even believe what you said about
chmod u+snot being available under your Debian. Qt as a framework has nothing to say or do about setuid.QProcesscan be used to run other programs in the standard Linuxexec-type way. Just because you say "i am think in Qt framework must be integrated this is function." does not make it so there is magically something else in Qt we have not discussed.At this point I don't think anybody here knows what you actually want, what your problem is or what you have tried from the suggestions.
-
There is a reason why you can't just run anything with root privileges. And under normal circumstance you should not try to circumvent it. The most important question is if you really need to run something as root (while your own software is not started with root privileges). Qt does not provide anything special to run a process as root. You need to use OS functionality to run an elevated process (you can use QProcess to start sudo or use any of the other methods mentioned before). In the case of sudo it is up to you to ask the user for the password and hand it to sudo. But, even this is a bad idea because it is really easy to leak the password for an attacker.