summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw
diff options
context:
space:
mode:
Diffstat (limited to 'tdecore/tdehw')
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp74
1 files changed, 65 insertions, 9 deletions
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index ef22ca239..ba88d6de1 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -858,10 +858,6 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
// If no other method was found, use 'pmount' command if available
if(command.isEmpty()) {
if (!TDEGlobal::dirs()->findExe("pmount").isEmpty()) {
- // Create dummy password file
- KTempFile passwordFile(TQString::null, "tmp", 0600);
- passwordFile.setAutoDelete(true);
-
TQString optionString;
if (mountOptions["ro"] == "true") {
optionString.append(" -r");
@@ -897,11 +893,9 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
mountpoint = mediaName;
}
- TQString passFileName = passwordFile.name();
- passFileName.replace("'", "'\\''");
-
- command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1")
- .arg(passFileName).arg(optionString).arg(devNode).arg(mountpoint);
+ // %1 (option string) without quotes, otherwise pmount fails
+ command = TQString("pmount %1 '%2' '%3' 2>&1")
+ .arg(optionString).arg(devNode).arg(mountpoint);
}
}
@@ -1068,6 +1062,44 @@ TQStringVariantMap TDEStorageDevice::unlockDevice(const TQString &passphrase)
}
#endif
+ // If no other method was found, use 'pmount' command if available
+ if (!TDEGlobal::dirs()->findExe("pmount").isEmpty()) {
+ // 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.local8Bit(), passphrase.length());
+ pwFile->flush();
+ TQString passFileName = passwordFile.name();
+ passFileName.replace("'", "'\\''");
+
+ TQString command = TQString("pmount -p '%1' '%2'").arg(passFileName).arg(devNode);
+ FILE *exepipe = popen(command.local8Bit(), "r");
+ if (exepipe) {
+ TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
+ TQString unlock_output = ts->read();
+ delete ts;
+ int retcode = pclose(exepipe);
+ if (retcode == 0) {
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+ result["result"] = true;
+ }
+ else {
+ result["errStr"] = unlock_output;
+ result["retCode"] = retcode;
+ result["result"] = false;
+ }
+ return result;
+ }
+ }
+
// No supported methods found for unlocking the device
result["errStr"] = i18n("No supported unlocking methods were detected on your system.");
result["result"] = false;
@@ -1111,6 +1143,30 @@ TQStringVariantMap TDEStorageDevice::lockDevice()
}
#endif
+ // If no other method was found, use 'pumount' command if available
+ if (!TDEGlobal::dirs()->findExe("pumount").isEmpty()) {
+ TQString command = TQString("pumount '%1'").arg(devNode);
+ FILE *exepipe = popen(command.local8Bit(), "r");
+ if (exepipe) {
+ TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
+ TQString lock_output = ts->read();
+ delete ts;
+ int retcode = pclose(exepipe);
+ if (retcode == 0) {
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+ result["result"] = true;
+ }
+ else {
+ result["errStr"] = lock_output;
+ result["retCode"] = retcode;
+ result["result"] = false;
+ }
+ return result;
+ }
+ }
+
// No supported methods found for locking the device
result["errStr"] = i18n("No supported locking methods were detected on your system.");
result["result"] = false;