mirror of
https://github.com/QuasarApp/installer-framework.git
synced 2025-04-26 13:44:31 +00:00
Fix MaintenanceTool file write permission check on Linux and macOS
Running the Qt installer on Linux and macOS with sudo will leave the installation target directory and some installation files writable by other users than their owner (root). Make MaintenanceTool check over all subdirectories in the installation directory for write permission so that admin rights can be always requested when needed. Task-number: QTIFW-1324 Change-Id: I9b314853634642b0be1fb3ea7a9164a2d4beb853 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
This commit is contained in:
parent
c97eb6750c
commit
46aecc23b2
@ -345,6 +345,18 @@ QString PackageManagerCorePrivate::targetDir() const
|
||||
return m_core->value(scTargetDir);
|
||||
}
|
||||
|
||||
bool PackageManagerCorePrivate::targetSubDirsWritable()
|
||||
{
|
||||
// Iterate over target directory subdirectories for writing access
|
||||
QDirIterator iterator(targetDir(), QDir::AllDirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||
while (iterator.hasNext()) {
|
||||
QTemporaryFile tempFile(iterator.next() + QLatin1String("/tempFile"));
|
||||
if (!tempFile.open() || !tempFile.isWritable())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString PackageManagerCorePrivate::configurationFileName() const
|
||||
{
|
||||
return m_core->value(scTargetConfigurationFile, QLatin1String("components.xml"));
|
||||
@ -1622,10 +1634,16 @@ bool PackageManagerCorePrivate::runPackageUpdater()
|
||||
//to have some progress for the cleanup/write component.xml step
|
||||
ProgressCoordinator::instance()->addReservePercentagePoints(1);
|
||||
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
||||
// check if we need admin rights and ask before the action happens
|
||||
// on Linux and macOS also check target directory subdirectories
|
||||
if (!QTemporaryFile(targetDir() + QStringLiteral("/XXXXXX")).open() || !targetSubDirsWritable())
|
||||
adminRightsGained = m_core->gainAdminRights();
|
||||
#else
|
||||
// check if we need admin rights and ask before the action happens
|
||||
if (!QTemporaryFile(targetDir() + QStringLiteral("/XXXXXX")).open())
|
||||
adminRightsGained = m_core->gainAdminRights();
|
||||
|
||||
#endif
|
||||
const QList<Component *> componentsToInstall = m_core->orderedComponentsToInstall();
|
||||
qDebug() << "Install size:" << componentsToInstall.size() << "components";
|
||||
|
||||
|
@ -92,6 +92,8 @@ public:
|
||||
QString targetDir() const;
|
||||
QString registerPath();
|
||||
|
||||
bool targetSubDirsWritable();
|
||||
|
||||
QString maintenanceToolName() const;
|
||||
QString installerBinaryPath() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user