summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2019-08-17 14:24:14 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-10-17 10:48:27 +0800
commite74e9afe2c46389b709411f7c2f6012bdfb3a0e8 (patch)
tree24a05f0c2c02762631303a90dd002b8cfda9d04d
parent3676cf129d85151dd430633847e3c289327405d5 (diff)
downloadtdebase-e74e9afe2c46389b709411f7c2f6012bdfb3a0e8.tar.gz
tdebase-e74e9afe2c46389b709411f7c2f6012bdfb3a0e8.zip
tdeioslave media: fixed displaying of encrypted disks.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.cpp235
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.h8
-rw-r--r--tdeioslave/media/services/media_eject.desktop2
-rw-r--r--tdeioslave/media/services/media_mount.desktop2
-rw-r--r--tdeioslave/media/services/media_safelyremove.desktop2
5 files changed, 66 insertions, 183 deletions
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
index f0c432a37..bcc46743f 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
@@ -49,7 +49,6 @@
TDEBackend::TDEBackend(MediaList &list, TQObject* parent)
: TQObject()
, BackendBase(list)
- , m_unlockDialog(0)
, m_parent(parent)
{
// Initialize the TDE device manager
@@ -146,22 +145,23 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
// Add volume block devices
if (sdevice->isDiskOfType(TDEDiskDeviceType::HDD)) {
/* We only list volumes that...
- * - are encrypted with LUKS or
+ * - are encrypted or
* - have a filesystem or
* - have an audio track
*/
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
//
}
- /* We also don't display devices that underlie other devices;
- * e.g. the raw partition of a device mapper volume
- */
- else if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)
- || (sdevice->fileSystemUsage().upper() == "RAID")) {
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
//
}
else {
@@ -169,16 +169,6 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
Medium* medium = new Medium(sdevice->uniqueID(), driveUDIFromDeviceUID(sdevice->uniqueID()), "");
setVolumeProperties(medium);
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- medium->setHidden(true);
- }
- else {
- medium->setHidden(false);
- }
- }
-
// Hide udev hidden devices by default but allow the user to override if desired via Show Hidden Files
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden)) {
medium->setSoftHidden(true);
@@ -266,33 +256,29 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
}
/* We only list volumes that...
- * - are encrypted with LUKS or
+ * - are encrypted or
* - have a filesystem or
- * - are a floppy disk
+ * - have an audio track
*/
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::Floppy))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
//
}
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ //
+ }
else {
// Create medium
Medium* medium = new Medium(sdevice->uniqueID(), driveUDIFromDeviceUID(sdevice->uniqueID()), "");
-
setFloppyProperties(medium);
-
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- medium->setHidden(true);
- }
- else {
- medium->setHidden(false);
- }
- }
-
m_mediaList.addMedium(medium, allowDialogNotification);
kdDebug(1219) << "TDEBackend::AddDevice inserted floppy medium for " << sdevice->uniqueID() << endl;
@@ -359,24 +345,28 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
Medium* m = new Medium(sdevice->uniqueID(), driveUDIFromDeviceUID(sdevice->uniqueID()), "");
// Keep these conditions in sync with ::AddDevice above, OR ELSE!!!
- // BEGIN
if (sdevice->isDiskOfType(TDEDiskDeviceType::HDD)) {
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ /* We only list volumes that...
+ * - are encrypted or
+ * - have a filesystem or
+ * - have an audio track
+ */
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
+ //
+ }
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ //
}
else {
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- m->setHidden(true);
- }
- else {
- m->setHidden(false);
- }
- }
setVolumeProperties(m);
}
}
@@ -416,25 +406,27 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
(sdevice->isDiskOfType(TDEDiskDeviceType::Zip)) ||
(sdevice->isDiskOfType(TDEDiskDeviceType::Jaz))
) {
-
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::Floppy))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ /* We only list volumes that...
+ * - are encrypted or
+ * - have a filesystem or
+ * - have an audio track
+ */
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
//
}
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ //
+ }
else {
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- m->setHidden(true);
- }
- else {
- m->setHidden(false);
- }
- }
-
setFloppyProperties(m);
}
}
@@ -443,8 +435,6 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
setCameraProperties(m);
}
- // END
-
if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) && (!(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Inserted)))) {
kdDebug(1219) << "TDEBackend::ResetProperties for " << sdevice->uniqueID() << " device was removed from system" << endl;
RemoveDevice(sdevice);
@@ -468,7 +458,7 @@ void TDEBackend::setVolumeProperties(Medium* medium)
}
medium->setName(generateName(sdevice->deviceNode()));
- if ((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) || (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt))) {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) {
medium->setEncrypted(true);
}
else {
@@ -782,15 +772,6 @@ void TDEBackend::setVolumeProperties(Medium* medium)
}
}
- if (!medium->needMounting()) {
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)) {
- // Encrypted base devices must be set to this mimetype or they won't open when the base device node is passed to the tdeioslave
- mimeType = "media/removable_mounted";
- }
- }
- }
-
medium->setLabel(diskLabel);
medium->setMimeType(mimeType);
}
@@ -813,7 +794,7 @@ bool TDEBackend::setFloppyProperties(Medium* medium)
// Any more?
if ((sdevice->isDiskOfType(TDEDiskDeviceType::Zip)) || (sdevice->isDiskOfType(TDEDiskDeviceType::Jaz))) {
medium->setName(generateName(sdevice->deviceNode()));
- if ((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) || (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt))) {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) {
medium->setEncrypted(true);
}
else {
@@ -1173,16 +1154,6 @@ bool TDEBackend::setMountoptions(const TQString &name, const TQStringList &optio
return true;
}
-void TDEBackend::slotPasswordReady() {
- m_decryptionPassword = m_unlockDialog->getPassword();
- m_decryptPasswordValid = true;
-}
-
-void TDEBackend::slotPasswordCancel() {
- m_decryptionPassword = TQString::null;
- m_decryptPasswordValid = true;
-}
-
TQStringVariantMap TDEBackend::mount(const Medium *medium)
{
kdDebug(1219) << "TDEBackend::mount for medium " << medium->name() << endl;
@@ -1255,87 +1226,7 @@ TQStringVariantMap TDEBackend::mount(const Medium *medium)
}
}
else {
- TQString iconName = medium->iconName();
- if (iconName.isEmpty())
- {
- TQString mime = medium->mimeType();
- iconName = KMimeType::mimeType(mime)->icon(mime, false);
- }
-
- bool continue_trying_to_decrypt = true;
- while (continue_trying_to_decrypt == true) {
- m_decryptPasswordValid = false;
-
- m_unlockDialog = new Dialog(sdevice->deviceNode(), iconName);
- m_unlockDialog->show();
-
- connect(m_unlockDialog, TQT_SIGNAL (user1Clicked()), this, TQT_SLOT (slotPasswordReady()));
- connect(m_unlockDialog, TQT_SIGNAL (cancelClicked()), this, TQT_SLOT (slotPasswordCancel()));
- connect(this, TQT_SIGNAL (signalDecryptionPasswordError(TQString)), m_unlockDialog, TQT_SLOT (slotDialogError(TQString)));
-
- while (m_decryptPasswordValid == false) {
- tqApp->processEvents();
- }
-
- m_unlockDialog->setEnabled(false);
- tqApp->processEvents();
-
- if (m_decryptionPassword.isNull()) {
- delete m_unlockDialog;
- result["errStr"] = i18n("Decryption aborted");
- result["result"] = false;
- return result;
- }
- else {
- // Just for some added fun, if udev emits a medium change event, which I then forward, with mounted==0, it stops the MediaProtocol::listDir method dead in its tracks,
- // and therefore the media:/ tdeioslave won't refresh after the encrypted device mount
- // Therefore, I need to ignore all change events on this device during the mount process and hope nothing bad happens as a result!
- if (!m_ignoreDeviceChangeEvents.contains(sdevice->uniqueID())) {
- m_ignoreDeviceChangeEvents.append(sdevice->uniqueID());
- }
-
- // mount encrypted volume with password
- TQStringVariantMap mountResult = sdevice->mountEncryptedDevice(m_decryptionPassword, diskLabel, valids);
- TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
- if (mountedPath.isEmpty()) {
- if (mountResult.contains("retCode") && mountResult["retCode"].toInt() == 0) {
- // Mounting was successful
- // Because the TDE hardware backend is event driven it might take a little while for the new enlock mapped device to show up
- // Wait up to 30 seconds for it to appear...
- for (int i=0;i<300;i++) {
- mountedPath = sdevice->mountPath();
- if (!mountedPath.isEmpty()) {
- break;
- }
- tqApp->processEvents(50);
- usleep(50000);
- }
- }
- }
- if (mountedPath.isEmpty()) {
- if (mountResult.contains("retCode") && mountResult["retCode"].toInt() == 25600) {
- // Probable LUKS failure
- // Retry
- m_unlockDialog->setEnabled(true);
- continue_trying_to_decrypt = true;
- }
- else {
- qerror = i18n("Cannot mount encrypted locked drives!");
- qerror = i18n("Unable to mount this device.");
- TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
- if (!errStr.isEmpty()) {
- qerror.append(i18n("<p>Technical details:<br>").append(errStr));
- }
- continue_trying_to_decrypt = false;
- }
- }
- else {
- continue_trying_to_decrypt = false;
- }
-
- delete m_unlockDialog;
- }
- }
+ qerror = i18n("Unable to mount an encrypted device.");
}
if (!qerror.isEmpty()) {
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.h b/tdeioslave/media/mediamanager/tdehardwarebackend.h
index fd81e9a3e..449d6369d 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.h
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.h
@@ -103,9 +103,6 @@ private slots:
void RemoveDeviceHandler(TDEGenericDevice* device);
void ModifyDeviceHandler(TDEGenericDevice* device);
- void slotPasswordReady();
- void slotPasswordCancel();
-
signals:
void signalDecryptionPasswordError(TQString);
@@ -137,11 +134,6 @@ private:
TQString driveUDIFromDeviceUID(TQString uuid);
- // Decryption
- Dialog* m_unlockDialog;
- TQString m_decryptionPassword;
- bool m_decryptPasswordValid;
-
private slots:
void slotResult(TDEIO::Job *job);
diff --git a/tdeioslave/media/services/media_eject.desktop b/tdeioslave/media/services/media_eject.desktop
index ad289fd33..7ed561f9d 100644
--- a/tdeioslave/media/services/media_eject.desktop
+++ b/tdeioslave/media/services/media_eject.desktop
@@ -1,5 +1,5 @@
[Desktop Entry]
-X-TDE-ServiceTypes=media/bluray_mounted,media/bluray_unmounted,media/bluray_encrypted_unlocked,media/bluray_encrypted_locked,media/cdrom_mounted,media/cdrom_unmounted,media/cdrom_encrypted_unlocked,media/cdrom_encrypted_locked,media/cd-r_mounted,media/cd-r_unmounted,media/cd-r_encrypted_unlocked,media/cd-r_encrypted_locked,media/cd-rw_mounted,media/cd-rw_unmounted,media/cd-rw_encrypted_unlocked,media/cd-rw_encrypted_locked,media/dvd_mounted,media/dvd_unmounted,media/dvd_encrypted_unlocked,media/dvd_encrypted_locked,media/audiocd,media/blankbluray,media/blankcd,media/blankdvd,media/blurayvideo,media/dvdvideo,media/svcd,media/vcd
+X-TDE-ServiceTypes=media/bluray_mounted,media/bluray_unmounted,media/bluray_encrypted_locked,media/cdrom_mounted,media/cdrom_unmounted,media/cdrom_encrypted_locked,media/cd-r_mounted,media/cd-r_unmounted,media/cd-r_encrypted_locked,media/cd-rw_mounted,media/cd-rw_unmounted,media/cd-rw_encrypted_locked,media/dvd_mounted,media/dvd_unmounted,media/dvd_encrypted_locked,media/audiocd,media/blankcd,media/blankdvd,media/dvdvideo,media/svcd,media/vcd
Actions=MediaEject;
X-TDE-Priority=TopLevel
X-TDE-MediaNotifierHide=true
diff --git a/tdeioslave/media/services/media_mount.desktop b/tdeioslave/media/services/media_mount.desktop
index d0f164bb9..6ccca7736 100644
--- a/tdeioslave/media/services/media_mount.desktop
+++ b/tdeioslave/media/services/media_mount.desktop
@@ -1,5 +1,5 @@
[Desktop Entry]
-X-TDE-ServiceTypes=media/bluray_unmounted,media/bluray_encrypted_unlocked,media/cdrom_unmounted,media/cdrom_encrypted_unlocked,media/cd-r_unmounted,media/cd-r_encrypted_unlocked,media/cd-rw_unmounted,media/cd-rw_encrypted_unlocked,media/dvd_unmounted,media/dvd_encrypted_unlocked,media/floppy5_unmounted,media/floppy_unmounted,media/hdd_unmounted,media/hdd_encrypted_unlocked,media/nfs_unmounted,media/removable_unmounted,media/removable_encrypted_unlocked,media/smb_unmounted,media/zip_unmounted,media/camera_unmounted
+X-TDE-ServiceTypes=media/bluray_unmounted,media/cdrom_unmounted,media/cd-r_unmounted,media/cd-rw_unmounted,media/dvd_unmounted,media/floppy5_unmounted,media/floppy_unmounted,media/hdd_unmounted,media/nfs_unmounted,media/removable_unmounted,media/smb_unmounted,media/zip_unmounted,media/camera_unmounted
Actions=MediaMount;
X-TDE-Priority=TopLevel
X-TDE-MediaNotifierHide=true
diff --git a/tdeioslave/media/services/media_safelyremove.desktop b/tdeioslave/media/services/media_safelyremove.desktop
index 5abfdcd85..184fc2391 100644
--- a/tdeioslave/media/services/media_safelyremove.desktop
+++ b/tdeioslave/media/services/media_safelyremove.desktop
@@ -1,5 +1,5 @@
[Desktop Entry]
-X-TDE-ServiceTypes=media/removable_mounted,media/removable_unmounted,media/removable_encrypted_unlocked,media/camera_mounted,media/camera_unmounted
+X-TDE-ServiceTypes=media/removable_mounted,media/removable_unmounted,media/camera_mounted,media/camera_unmounted
Actions=MediaSafelyRemove;
X-TDE-Priority=TopLevel
X-TDE-MediaNotifierHide=true