Commit 9b5b458e authored by Raine Makelainen's avatar Raine Makelainen

Merge branch 'jb46420' into 'master'

[nemo-storage] Do not accept invalid block devices. Fixes JB#46420

See merge request !110
parents d5b60ad8 a819cb1f
......@@ -267,7 +267,11 @@ bool UDisks2::Block::isExternal() const
bool UDisks2::Block::isValid() const
{
return m_interfacePropertyMap.contains(UDISKS2_BLOCK_INTERFACE);
bool hasBlock = m_interfacePropertyMap.contains(UDISKS2_BLOCK_INTERFACE);
if (hasBlock && device().startsWith(QStringLiteral("/dev/dm"))) {
return hasCryptoBackingDevice();
}
return hasBlock;
}
QString UDisks2::Block::idType() const
......
......@@ -66,8 +66,11 @@ bool BlockDevices::contains(const QString &dbusObjectPath) const
void BlockDevices::remove(const QString &dbusObjectPath)
{
Block *block = m_blockDevices.take(dbusObjectPath);
block->deleteLater();
if (contains(dbusObjectPath)) {
Block *block = m_blockDevices.take(dbusObjectPath);
clearPartitionWait(dbusObjectPath, false);
delete block;
}
}
Block *BlockDevices::device(const QString &dbusObjectPath) const
......@@ -189,16 +192,22 @@ void BlockDevices::clearPartitionWait(const QString &dbusObjectPath, bool destro
void BlockDevices::removeInterfaces(const QString &dbusObjectPath, const QStringList &interfaces)
{
if (contains(dbusObjectPath)) {
UDisks2::Block *block = device(dbusObjectPath);
clearPartitionWait(dbusObjectPath, false);
UDisks2::Block *block = device(dbusObjectPath);
if (block) {
if (interfaces.contains(UDISKS2_FILESYSTEM_INTERFACE)) {
block->removeInterface(UDISKS2_FILESYSTEM_INTERFACE);
}
if (interfaces.contains(UDISKS2_ENCRYPTED_INTERFACE)) {
block->removeInterface(UDISKS2_ENCRYPTED_INTERFACE);
}
if (interfaces.contains(UDISKS2_BLOCK_INTERFACE)) {
delete block;
m_blockDevices.remove(dbusObjectPath);
}
}
clearPartitionWait(dbusObjectPath, true);
}
bool BlockDevices::isExternal(const QString &dbusObjectPath)
......@@ -210,7 +219,8 @@ bool BlockDevices::isExternal(const QString &dbusObjectPath)
void BlockDevices::blockCompleted()
{
Block *completedBlock = qobject_cast<Block *>(sender());
if (completedBlock->isPartitionTable() || (completedBlock->hasInterface(UDISKS2_BLOCK_INTERFACE) && completedBlock->interfaceCount() == 1)) {
if (completedBlock->isValid() && (completedBlock->isPartitionTable() ||
(completedBlock->hasInterface(UDISKS2_BLOCK_INTERFACE) && completedBlock->interfaceCount() == 1)) ){
qCInfo(lcMemoryCardLog) << "Start waiting for block" << completedBlock->device();
waitPartition(completedBlock);
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment