141 lines
5.4 KiB
Diff
141 lines
5.4 KiB
Diff
diff -r -U5 kdelibs-4.3.75svn1048496/solid/solid/backends/hal/halstorageaccess.cpp kdelibs-4.3.75svn1048496.polkit/solid/solid/backends/hal/halstorageaccess.cpp
|
|
--- kdelibs-4.3.75svn1048496/solid/solid/backends/hal/halstorageaccess.cpp 2009-08-12 06:00:18.000000000 -0400
|
|
+++ kdelibs-4.3.75svn1048496.polkit/solid/solid/backends/hal/halstorageaccess.cpp 2009-11-20 14:39:44.000000000 -0500
|
|
@@ -15,10 +15,12 @@
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
+#include <config-prefix.h> // for LIBEXEC_INSTALL_DIR
|
|
+
|
|
#include "halstorageaccess.h"
|
|
|
|
#include "halfstabhandling.h"
|
|
|
|
#include <QtCore/QLocale>
|
|
@@ -170,15 +172,25 @@
|
|
|
|
void StorageAccess::slotDBusError(const QDBusError &error)
|
|
{
|
|
// TODO: Better error reporting here
|
|
if (m_setupInProgress) {
|
|
+ if (error.name() == "org.freedesktop.Hal.Device.PermissionDeniedByPolicy") {
|
|
+ if (callPrivilegedMount())
|
|
+ return;
|
|
+ // if we fail to run kdesu, fall through and emit the original PermissionDeniedByPolicy error
|
|
+ }
|
|
m_setupInProgress = false;
|
|
emit setupDone(Solid::UnauthorizedOperation,
|
|
QString(error.name()+": "+error.message()),
|
|
m_device->udi());
|
|
} else if (m_teardownInProgress) {
|
|
+ if (error.name() == "org.freedesktop.Hal.Device.PermissionDeniedByPolicy") {
|
|
+ if (callPrivilegedUnmount())
|
|
+ return;
|
|
+ // if we fail to run kdesu, fall through and emit the original PermissionDeniedByPolicy error
|
|
+ }
|
|
m_teardownInProgress = false;
|
|
emit teardownDone(Solid::UnauthorizedOperation,
|
|
QString(error.name()+": "+error.message()),
|
|
m_device->udi());
|
|
}
|
|
@@ -292,12 +304,13 @@
|
|
#ifdef Q_OS_FREEBSD
|
|
QString uid="-u=";
|
|
#else
|
|
QString uid="uid=";
|
|
#endif
|
|
- if (halOptions.contains(uid)) {
|
|
- options << uid+QString::number(::getuid());
|
|
+ if (halOptions.contains(uid) &&
|
|
+ (fstype == "vfat" || fstype == "iso9660" || fstype == "hfs" || fstype == "udf")) {
|
|
+ options << uid+QString::number(::getuid());
|
|
}
|
|
|
|
#ifdef Q_OS_FREEBSD
|
|
char *cType;
|
|
if ( fstype=="vfat" && halOptions.contains("-L=")) {
|
|
@@ -335,10 +348,63 @@
|
|
return c.callWithCallback(msg, this,
|
|
SLOT(slotDBusReply(const QDBusMessage &)),
|
|
SLOT(slotDBusError(const QDBusError &)));
|
|
}
|
|
|
|
+bool Solid::Backends::Hal::StorageAccess::callPrivilegedMount()
|
|
+{
|
|
+ QString udi = m_device->udi();
|
|
+ QString options;
|
|
+ QStringList halOptions = m_device->property("volume.mount.valid_options").toStringList();
|
|
+ QString fstype = m_device->property("volume.fstype").toString();
|
|
+
|
|
+ if (halOptions.contains("uid=")
|
|
+ && (fstype == "vfat" || fstype == "iso9660" || fstype == "hfs" || fstype == "udf")) {
|
|
+ options = "uid="+QString::number(::getuid());
|
|
+ }
|
|
+
|
|
+ m_process = new QProcess(this);
|
|
+
|
|
+ connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
|
|
+ this, SLOT(slotProcessFinished(int, QProcess::ExitStatus)));
|
|
+
|
|
+ m_process->start(LIBEXEC_INSTALL_DIR "/kdesu", QStringList() << "-d" << "-t"
|
|
+ << "--noignorebutton" << "-c"
|
|
+ << QString::fromLatin1("dbus-send --system --print-reply --dest=org.freedesktop.Hal %1 "
|
|
+ "org.freedesktop.Hal.Device.Volume.Mount string: string: "
|
|
+ "array:string:%2").arg(udi).arg(options));
|
|
+
|
|
+ if (m_process->waitForStarted()) {
|
|
+ return true;
|
|
+ } else {
|
|
+ delete m_process;
|
|
+ return false;
|
|
+ }
|
|
+}
|
|
+
|
|
+bool Solid::Backends::Hal::StorageAccess::callPrivilegedUnmount()
|
|
+{
|
|
+ QString udi = m_device->udi();
|
|
+
|
|
+ m_process = new QProcess(this);
|
|
+
|
|
+ connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
|
|
+ this, SLOT(slotProcessFinished(int, QProcess::ExitStatus)));
|
|
+
|
|
+ m_process->start(LIBEXEC_INSTALL_DIR "/kdesu", QStringList() << "-d" << "-t"
|
|
+ << "--noignorebutton" << "-c"
|
|
+ << QString::fromLatin1("dbus-send --system --print-reply --dest=org.freedesktop.Hal %1 "
|
|
+ "org.freedesktop.Hal.Device.Volume.Unmount array:string:").arg(udi));
|
|
+
|
|
+ if (m_process->waitForStarted()) {
|
|
+ return true;
|
|
+ } else {
|
|
+ delete m_process;
|
|
+ return false;
|
|
+ }
|
|
+}
|
|
+
|
|
bool StorageAccess::callHalVolumeUnmount()
|
|
{
|
|
QDBusConnection c = QDBusConnection::systemBus();
|
|
QString udi = m_device->udi();
|
|
QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Hal", udi,
|
|
Only in kdelibs-4.3.75svn1048496.polkit/solid/solid/backends/hal: halstorageaccess.cpp.orig
|
|
diff -r -U5 kdelibs-4.3.75svn1048496/solid/solid/backends/hal/halstorageaccess.h kdelibs-4.3.75svn1048496.polkit/solid/solid/backends/hal/halstorageaccess.h
|
|
--- kdelibs-4.3.75svn1048496/solid/solid/backends/hal/halstorageaccess.h 2008-05-21 07:07:38.000000000 -0400
|
|
+++ kdelibs-4.3.75svn1048496.polkit/solid/solid/backends/hal/halstorageaccess.h 2009-11-20 14:38:17.000000000 -0500
|
|
@@ -67,10 +67,13 @@
|
|
bool callHalVolumeUnmount();
|
|
|
|
bool callSystemMount();
|
|
bool callSystemUnmount();
|
|
|
|
+ bool callPrivilegedMount();
|
|
+ bool callPrivilegedUnmount();
|
|
+
|
|
bool requestPassphrase();
|
|
void callCryptoSetup(const QString &passphrase);
|
|
bool callCryptoTeardown();
|
|
|
|
private:
|