diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2019-10-28 16:55:21 +0200 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2019-11-14 11:36:30 +0000 |
commit | 9c2a50721500cdff345d809938076cce0963d888 (patch) | |
tree | 1077ab2e80d21e0e89fe0edf94eb596a2a4add2f | |
parent | 8053f11af1462f848d1b004500435d6af38827e7 (diff) |
Add early prompt to run MaintenanceTool as admin when needed
Currently IFW does not support manipulating Windows Access Control Lists
for files. If a user does not have reading permissions to installer.dat
it will throw error on QInstaller::openForRead() before the wizard GUI
is shown. At very least, add a MessageBox to prompt the user to run the
executable again as administrator in such a case.
Task-number: QTIFW-1392
Change-Id: I9e20c34b215ee697118af9c15a7e344f9cfc3c3f
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
-rw-r--r-- | src/sdk/installerbase.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp index d7f21bbd0..247b4ab57 100644 --- a/src/sdk/installerbase.cpp +++ b/src/sdk/installerbase.cpp @@ -95,6 +95,22 @@ int InstallerBase::run() } } + QFile binary(binaryFile()); + +#ifdef Q_OS_WIN + // On some admin user installations it is possible that the installer.dat + // file is left without reading permissions for non-administrator users, + // we should check this and prompt the user to run the executable as admin if needed. + if (!binary.open(QIODevice::ReadOnly)) { + QFileInfo binaryInfo(binary.fileName()); + QInstaller::MessageBoxHandler::information(nullptr, QLatin1String("NoReadingPermissions"), + tr("Cannot open file \"%1\" for reading").arg(binaryInfo.fileName()), + tr("Please make sure that the current user has reading access " + "to file \"%1\" or try running %2 as an administrator.").arg(binaryInfo.fileName(), qAppName())); + return EXIT_FAILURE; + } + binary.close(); +#endif QString fileName = datFile(binaryFile()); quint64 cookie = QInstaller::BinaryContent::MagicCookieDat; if (fileName.isEmpty()) { @@ -102,7 +118,7 @@ int InstallerBase::run() cookie = QInstaller::BinaryContent::MagicCookie; } - QFile binary(fileName); + binary.setFileName(fileName); QInstaller::openForRead(&binary); qint64 magicMarker; |