Methods to run applications as authorized user (admin/root) More...
Functions | |
Q_AUTOUPDATERCORE_EXPORT bool | needsAdminPermission (const QString &program) |
Tries to find out if the given executable needs to be run as priviledged user. More... | |
Q_AUTOUPDATERCORE_EXPORT bool | executeAsAdmin (const QString &program, const QStringList &arguments, const QString &workingDir) |
Prompts the user to execute the given executable as priviledged user. More... | |
Methods to run applications as authorized user (admin/root)
The AdminAuthoriser's task is to run a program with elevated rigths. Since the way to archive this is different on every platform, it will behave differently on different systems. Generelly it will prompt the user for admin credentials using the system API and then execute the program on success. This may not work on any platform.
This namespace can be used when implementing custom plugins to run elevated tasks
QtAutoUpdater::AdminAuthoriser::executeAsAdmin | ( | const QString & | program, |
const QStringList & | arguments, | ||
const QString & | workingDir | ||
) |
Prompts the user to execute the given executable as priviledged user.
program | The path to the executable. This will be an absolute path |
arguments | A list of arguments to be passed to the executable |
workingDir | The working directory to execute the program in. Should always be a valid path |
true
, if the program could be started with elevated rights, false
if notThis function will try to prompt the user for elevation and the execute the given program with elevation. Please note that workingDir may be ignored on some platforms. You should not rely on it beeing set correctly. Also, it may return true
, even if the user rejected priviledged execution.
This function can return false if:
QtAutoUpdater::AdminAuthoriser::needsAdminPermission | ( | const QString & | program | ) |
Tries to find out if the given executable needs to be run as priviledged user.
true
, if this program needs to be run as priviledged user, false
if not or unable to determineThis might return false even if a application needs such permissions in three cases: