Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Commit 8bd1feb

Browse files
committed
[nemo-storage] Do not expose /home and / partitions through udisk block devices. Fixes JB#45974
1 parent 620b7d9 commit 8bd1feb

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/udisks2block.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ bool UDisks2::Block::isReadOnly() const
261261
bool UDisks2::Block::isExternal() const
262262
{
263263
const QString prefDevice = preferredDevice();
264-
return prefDevice != QStringLiteral("/dev/sailfish/home") && prefDevice != QStringLiteral("/dev/sailfish/root");
264+
return prefDevice != QStringLiteral("/dev/sailfish/home") && prefDevice != QStringLiteral("/dev/sailfish/root")
265+
&& mountPath() != QStringLiteral("/home") && mountPath() != QStringLiteral("/");
265266
}
266267

267268
bool UDisks2::Block::isValid() const
@@ -332,7 +333,7 @@ void UDisks2::Block::addInterface(const QString &interface, QVariantMap property
332333
{
333334
m_interfacePropertyMap.insert(interface, propertyMap);
334335
if (interface == UDISKS2_FILESYSTEM_INTERFACE) {
335-
setMountable(true);
336+
updateFileSystemInterface(propertyMap);
336337
} else if (interface == UDISKS2_ENCRYPTED_INTERFACE) {
337338
setEncrypted(true);
338339
}
@@ -346,7 +347,7 @@ void UDisks2::Block::removeInterface(const QString &interface)
346347
} else if (interface == UDISKS2_DRIVE_INTERFACE) {
347348
m_drive.clear();
348349
} else if (interface == UDISKS2_FILESYSTEM_INTERFACE) {
349-
setMountable(false);
350+
updateFileSystemInterface(QVariantMap());
350351
} else if (interface == UDISKS2_ENCRYPTED_INTERFACE) {
351352
setEncrypted(false);
352353
}
@@ -438,21 +439,25 @@ bool UDisks2::Block::isCompleted() const
438439
void UDisks2::Block::updateFileSystemInterface(const QVariant &filesystemInterface)
439440
{
440441
QVariantMap filesystem = NemoDBus::demarshallArgument<QVariantMap>(filesystemInterface);
441-
m_interfacePropertyMap.insert(UDISKS2_FILESYSTEM_INTERFACE, filesystem);
442+
443+
bool interfaceChange = m_interfacePropertyMap.contains(UDISKS2_FILESYSTEM_INTERFACE) != filesystem.isEmpty();
444+
if (filesystem.isEmpty()) {
445+
m_interfacePropertyMap.remove(UDISKS2_FILESYSTEM_INTERFACE);
446+
} else {
447+
m_interfacePropertyMap.insert(UDISKS2_FILESYSTEM_INTERFACE, filesystem);
448+
}
442449
QList<QByteArray> mountPointList = NemoDBus::demarshallArgument<QList<QByteArray> >(filesystem.value(QStringLiteral("MountPoints")));
443450
m_mountPath.clear();
444451

445-
for (const QByteArray &bytes : mountPointList) {
446-
if (bytes.startsWith("/run")) {
447-
m_mountPath = QString::fromLocal8Bit(bytes);
448-
break;
449-
}
452+
if (!mountPointList.isEmpty()) {
453+
m_mountPath = QString::fromLocal8Bit(mountPointList.at(0));
450454
}
451455

452456
bool triggerUpdate = false;
453457
blockSignals(true);
454-
triggerUpdate = setMountable(true);
458+
triggerUpdate = setMountable(!filesystem.isEmpty());
455459
triggerUpdate |= clearFormattingState();
460+
triggerUpdate |= interfaceChange;
456461
blockSignals(false);
457462

458463
if (triggerUpdate) {

0 commit comments

Comments
 (0)