Fixed displaying of encrypted disks.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/111/head
Michele Calgaro 4 years ago
parent fe08361f7e
commit 33794c4ec3
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -2626,6 +2626,15 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
device = classifyUnknownDeviceByExternalRules(dev, device, true); // Check external rules for possible subtype overrides device = classifyUnknownDeviceByExternalRules(dev, device, true); // Check external rules for possible subtype overrides
disktype = sdevice->diskType(); // The type can be overridden by an external rule disktype = sdevice->diskType(); // The type can be overridden by an external rule
// Set unlocked crypt flag is device has any holders
if ((filesystemtype.upper() == "CRYPTO_LUKS" || filesystemtype.upper() == "CRYPTO") &&
holdingDeviceNodes.count() > 0) {
disktype = disktype | TDEDiskDeviceType::UnlockedCrypt;
}
else {
disktype = disktype & ~TDEDiskDeviceType::UnlockedCrypt;
}
if (TQString(udev_device_get_property_value(dev, "UDISKS_IGNORE")) == "1") { if (TQString(udev_device_get_property_value(dev, "UDISKS_IGNORE")) == "1") {
diskstatus = diskstatus | TDEDiskDeviceStatus::Hidden; diskstatus = diskstatus | TDEDiskDeviceStatus::Hidden;
} }
@ -2796,17 +2805,6 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
} }
// See if any slaves were crypted // See if any slaves were crypted
for ( TQStringList::Iterator slaveit = slaveDeviceNodes.begin(); slaveit != slaveDeviceNodes.end(); ++slaveit ) {
struct udev_device *slavedev;
slavedev = udev_device_new_from_syspath(m_udevStruct, (*slaveit).ascii());
TQString slavediskfstype(udev_device_get_property_value(slavedev, "ID_FS_TYPE"));
if ((slavediskfstype.upper() == "CRYPTO_LUKS") || (slavediskfstype.upper() == "CRYPTO")) {
disktype = disktype | TDEDiskDeviceType::UnlockedCrypt;
// Set disk type based on parent device
disktype = disktype | classifyDiskType(slavedev, devicenode, TQString(udev_device_get_property_value(dev, "ID_BUS")), TQString(udev_device_get_property_value(dev, "ID_TYPE")), (*slaveit), TQString(udev_device_get_property_value(dev, "ID_VENDOR")), TQString(udev_device_get_property_value(dev, "ID_MODEL")), TQString(udev_device_get_property_value(dev, "ID_FS_TYPE")), TQString(udev_device_get_driver(dev)));
}
udev_device_unref(slavedev);
}
sdevice->internalSetDiskType(disktype); sdevice->internalSetDiskType(disktype);
sdevice->internalSetDiskUUID(diskuuid); sdevice->internalSetDiskUUID(diskuuid);

@ -789,6 +789,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
mountResult = udisks2MountDrive(devNode, fileSystemType, optionString); mountResult = udisks2MountDrive(devNode, fileSystemType, optionString);
if (mountResult["result"].toBool()) { if (mountResult["result"].toBool()) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["mountPath"] = mountPath(); result["mountPath"] = mountPath();
result["result"] = true; result["result"] = true;
@ -796,6 +797,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
} }
else if (mountResult["retcode"].toInt() == -1) { else if (mountResult["retcode"].toInt() == -1) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = mountResult["errStr"]; result["errStr"] = mountResult["errStr"];
result["result"] = false; result["result"] = false;
@ -809,6 +811,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
mountResult = udisksMountDrive(devNode, fileSystemType, udisksOptions); mountResult = udisksMountDrive(devNode, fileSystemType, udisksOptions);
if (mountResult["result"].toBool()) { if (mountResult["result"].toBool()) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["mountPath"] = mountPath(); result["mountPath"] = mountPath();
result["result"] = true; result["result"] = true;
@ -816,6 +819,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
} }
else if (mountResult["retcode"].toInt() == -1) { else if (mountResult["retcode"].toInt() == -1) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = mountResult["errStr"]; result["errStr"] = mountResult["errStr"];
result["result"] = false; result["result"] = false;
@ -911,81 +915,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
} }
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
result["mountPath"] = mountPath();
result["result"] = !mountPath().isEmpty();
return result;
}
TQStringVariantMap TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString mediaName,
TDEStorageMountOptions mountOptions) {
TQStringVariantMap result;
// Check if device is already mounted
TQString mountpath = mountPath();
if (!mountpath.isEmpty()) {
result["mountPath"] = mountpath;
result["result"] = true;
return result;
}
// Create dummy password file
KTempFile passwordFile(TQString::null, "tmp", 0600);
passwordFile.setAutoDelete(true);
TQFile* pwFile = passwordFile.file();
if (!pwFile) {
result["errStr"] = i18n("Cannot create temporary password file");
result["result"] = false;
return result;
}
pwFile->writeBlock(passphrase.ascii(), passphrase.length());
pwFile->flush();
TQString optionString;
if (mountOptions["ro"] == "true") {
optionString.append(" -r");
}
if (mountOptions["atime"] != "true") {
optionString.append(" -A");
}
if (mountOptions["utf8"] == "true") {
optionString.append(" -c utf8");
}
if (mountOptions["sync"] == "true") {
optionString.append(" -s");
}
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"]));
}
if (mountOptions.contains("locale")) {
optionString.append(TQString(" -c %1").arg(mountOptions["locale"]));
}
TQString passFileName = passwordFile.name();
TQString devNode = deviceNode();
passFileName.replace("'", "'\\''");
devNode.replace("'", "'\\''");
mediaName.replace("'", "'\\''");
TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1")
.arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
FILE *exepipe = popen(command.local8Bit(), "r");
if (exepipe) {
TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
TQString mount_output = ts->read();
delete ts;
int retcode = pclose(exepipe);
result["errStr"] = mount_output;
result["retCode"] = retcode;
}
// Update internal mount data
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["mountPath"] = mountPath(); result["mountPath"] = mountPath();
result["result"] = !mountPath().isEmpty(); result["result"] = !mountPath().isEmpty();
@ -1012,12 +942,14 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
unmountResult = udisks2UnmountDrive(devNode, TQString::null); unmountResult = udisks2UnmountDrive(devNode, TQString::null);
if (unmountResult["result"].toBool()) { if (unmountResult["result"].toBool()) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true; result["result"] = true;
return result; return result;
} }
else if (unmountResult["retcode"].toInt() == -1) { else if (unmountResult["retcode"].toInt() == -1) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = unmountResult["errStr"]; result["errStr"] = unmountResult["errStr"];
result["result"] = false; result["result"] = false;
@ -1031,12 +963,14 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
unmountResult = udisksUnmountDrive(devNode, TQStringList()); unmountResult = udisksUnmountDrive(devNode, TQStringList());
if (unmountResult["result"].toBool()) { if (unmountResult["result"].toBool()) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true; result["result"] = true;
return result; return result;
} }
else if (unmountResult["retcode"].toInt() == -1) { else if (unmountResult["retcode"].toInt() == -1) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = unmountResult["errStr"]; result["errStr"] = unmountResult["errStr"];
result["result"] = false; result["result"] = false;
@ -1071,6 +1005,7 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
int retcode = pclose(exepipe); int retcode = pclose(exepipe);
if (retcode == 0) { if (retcode == 0) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true; result["result"] = true;
return result; return result;
@ -1082,6 +1017,7 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
} }
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = false; result["result"] = false;
return result; return result;
@ -1109,6 +1045,7 @@ TQStringVariantMap TDEStorageDevice::unlockDevice(const TQString &passphrase)
unlockResult = udisks2UnlockDrive(devNode, passphrase); unlockResult = udisks2UnlockDrive(devNode, passphrase);
if (unlockResult["result"].toBool()) { if (unlockResult["result"].toBool()) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["unlockedDevice"] = unlockResult["unlockedDevice"]; result["unlockedDevice"] = unlockResult["unlockedDevice"];
result["result"] = true; result["result"] = true;
@ -1116,6 +1053,7 @@ TQStringVariantMap TDEStorageDevice::unlockDevice(const TQString &passphrase)
} }
else if (unlockResult["retcode"].toInt() == -1) { else if (unlockResult["retcode"].toInt() == -1) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = unlockResult["errStr"]; result["errStr"] = unlockResult["errStr"];
result["result"] = false; result["result"] = false;
@ -1151,12 +1089,14 @@ TQStringVariantMap TDEStorageDevice::lockDevice()
lockResult = udisks2LockDrive(devNode); lockResult = udisks2LockDrive(devNode);
if (lockResult["result"].toBool()) { if (lockResult["result"].toBool()) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true; result["result"] = true;
return result; return result;
} }
else if (lockResult["retcode"].toInt() == -1) { else if (lockResult["retcode"].toInt() == -1) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = lockResult["errStr"]; result["errStr"] = lockResult["errStr"];
result["result"] = false; result["result"] = false;

@ -239,18 +239,6 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
TQStringVariantMap mountDevice(TQString mediaName = TQString::null, TQStringVariantMap mountDevice(TQString mediaName = TQString::null,
TDEStorageMountOptions mountOptions = TDEStorageMountOptions()); TDEStorageMountOptions mountOptions = TDEStorageMountOptions());
/**
* Mounts the encrypted device if the correct passphrase is given
*
* @param a TQString containing the passphrase
* @param a TQString containing a requested mount name under /media, if desired
* @param a TDEStorageMountOptions containing any mount options for pmount, if desired
*
* @return a TQStringVariantMap object containing information about the operation outcome
*/
TQStringVariantMap mountEncryptedDevice(TQString passphrase, TQString mediaName = TQString::null,
TDEStorageMountOptions mountOptions = TDEStorageMountOptions());
/** /**
* Unmounts the device * Unmounts the device
* *

Loading…
Cancel
Save