Compare commits

...

1 Commits
f38 ... epel7

Author SHA1 Message Date
Rex Dieter 286c87c0f8 sync latest goodies from fedora polkit-qt module
9 years ago

3
.gitignore vendored

@ -1 +1,2 @@
/polkit-qt5-1.tar.gz
/polkit-qt-1-0.112.0.tar.bz2
/Doxyfile

@ -0,0 +1,84 @@
From 88c6e9334c8440721189ef7d020fa94d47f30f8b Mon Sep 17 00:00:00 2001
From: Harald Sitter <sitter@kde.org>
Date: Fri, 1 Aug 2014 16:34:03 +0200
Subject: [PATCH 1/8] do not use global static systembus instance
global static destruction order cannot be controlled and we need our bus
to disconnect from the consolekit signals, so use our own bus instance
to connect to systembus signals
REVIEW: 119545
---
core/polkitqt1-authority.cpp | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/core/polkitqt1-authority.cpp b/core/polkitqt1-authority.cpp
index dd014cf..f25354d 100644
--- a/core/polkitqt1-authority.cpp
+++ b/core/polkitqt1-authority.cpp
@@ -83,7 +83,10 @@ public:
// Polkit will return NULL on failures, hence we use it instead of 0
Private(Authority *qq) : q(qq)
, pkAuthority(NULL)
- , m_hasError(false) {}
+ , m_hasError(false)
+ , m_systemBus(0)
+ {
+ }
~Private();
@@ -103,6 +106,13 @@ public:
bool m_hasError;
Authority::ErrorCode m_lastError;
QString m_errorDetails;
+ // Local system bus. QDBusConnection::systemBus() may only be savely used
+ // inside a QCoreApplication scope as for example destruction of connected
+ // objects need to happen before the bus disappears. Since this class however
+ // is a global static and systemBus() internally is a global static we
+ // cannot assure destruction order. Instead we create a local copy of the
+ // global systemBus instance so we can make life time to our needs.
+ // This prevents crashes when cleaning up the global statics.
QDBusConnection *m_systemBus;
GCancellable *m_checkAuthorizationCancellable,
*m_enumerateActionsCancellable,
@@ -127,6 +137,7 @@ public:
Authority::Private::~Private()
{
+ delete m_systemBus;
g_object_unref(m_checkAuthorizationCancellable);
g_object_unref(m_enumerateActionsCancellable);
g_object_unref(m_registerAuthenticationAgentCancellable);
@@ -170,6 +181,9 @@ void Authority::Private::init()
g_type_init();
+ m_systemBus = new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SystemBus,
+ QStringLiteral("polkit_qt_system_bus")));
+
m_checkAuthorizationCancellable = g_cancellable_new();
m_enumerateActionsCancellable = g_cancellable_new();
m_registerAuthenticationAgentCancellable = g_cancellable_new();
@@ -219,7 +233,7 @@ void Authority::Private::init()
// then we need to extract all seats from ConsoleKit
QDBusMessage msg = QDBusMessage::createMethodCall(consoleKitService, consoleKitManagerPath, consoleKitManagerInterface, "GetSeats");
- msg = QDBusConnection::systemBus().call(msg);
+ msg = m_systemBus->call(msg);
if (!msg.arguments().isEmpty()) {
// this method returns a list with present seats
QList<QString> seats;
@@ -256,8 +270,7 @@ void Authority::Private::seatSignalsConnect(const QString &seat)
void Authority::Private::dbusSignalAdd(const QString &service, const QString &path, const QString &interface, const QString &name)
{
// FIXME: This code seems to be nonfunctional - it needs to be fixed somewhere (is it Qt BUG?)
- QDBusConnection::systemBus().connect(service, path, interface, name,
- q, SLOT(dbusFilter(QDBusMessage)));
+ m_systemBus->connect(service, path, interface, name, q, SLOT(dbusFilter(QDBusMessage)));
}
void Authority::Private::dbusFilter(const QDBusMessage &message)
--
2.5.0

@ -0,0 +1,26 @@
From 3882e11e29f5d56b03d7b84dc14a358ad2477e8d Mon Sep 17 00:00:00 2001
From: Allen Winter <winter@kde.org>
Date: Sat, 2 Aug 2014 10:32:53 -0400
Subject: [PATCH 2/8] fix build with Qt4, which doesn't have QStringLiteral. so
use QString instead.
---
core/polkitqt1-authority.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/polkitqt1-authority.cpp b/core/polkitqt1-authority.cpp
index f25354d..155493e 100644
--- a/core/polkitqt1-authority.cpp
+++ b/core/polkitqt1-authority.cpp
@@ -182,7 +182,7 @@ void Authority::Private::init()
g_type_init();
m_systemBus = new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SystemBus,
- QStringLiteral("polkit_qt_system_bus")));
+ QString("polkit_qt_system_bus")));
m_checkAuthorizationCancellable = g_cancellable_new();
m_enumerateActionsCancellable = g_cancellable_new();
--
2.5.0

@ -0,0 +1,40 @@
From fb1667ac9a5437b4784d2806a3e816cbdbe404a5 Mon Sep 17 00:00:00 2001
From: Alex Richardson <arichardson.kde@gmail.com>
Date: Thu, 7 Jan 2016 13:37:42 +0000
Subject: [PATCH 3/8] Fix QDBusArgument assertion
On my system kded5 crashes with the assertion
"QDBusArgument: read from a write-only object" otherwise
---
core/polkitqt1-authority.cpp | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/core/polkitqt1-authority.cpp b/core/polkitqt1-authority.cpp
index 155493e..efa8271 100644
--- a/core/polkitqt1-authority.cpp
+++ b/core/polkitqt1-authority.cpp
@@ -233,11 +233,17 @@ void Authority::Private::init()
// then we need to extract all seats from ConsoleKit
QDBusMessage msg = QDBusMessage::createMethodCall(consoleKitService, consoleKitManagerPath, consoleKitManagerInterface, "GetSeats");
- msg = m_systemBus->call(msg);
- if (!msg.arguments().isEmpty()) {
+ const QDBusMessage reply = m_systemBus->call(msg);
+
+ if (reply.type() != QDBusMessage::ErrorMessage && !reply.arguments().isEmpty()) {
// this method returns a list with present seats
- QList<QString> seats;
- qVariantValue<QDBusArgument> (msg.arguments()[0]) >> seats;
+ QStringList seats;
+ QVariant arg = reply.arguments()[0];
+ if (arg.type() == qMetaTypeId<QDBusArgument>()) {
+ arg.value<QDBusArgument>() >> seats;
+ } else {
+ seats = arg.toStringList();
+ }
// it can be multiple seats present so connect all their signals
Q_FOREACH(const QString &seat, seats) {
seatSignalsConnect(seat);
--
2.5.0

@ -0,0 +1,74 @@
From d1bcbbe315dab07bef1ddb9c6f7335f88e0ebdbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= <mgraesslin@kde.org>
Date: Tue, 12 Jan 2016 10:01:38 +0100
Subject: [PATCH 5/8] Add wrapper for polkit_system_bus_name_get_user_sync
This adds a new method to SystemBusNameSubject to get to the
UnixUserIdentity for the subject.
This feature depends on new functionality added in polkit 0.113, the
dependency is nevertheless not raised as the new API is backported in
distribution packages and we don't want to disrupt developer workflows
by depending on a version which is not available yet.
REVIEW: 126723
---
core/polkitqt1-subject.cpp | 6 ++++++
core/polkitqt1-subject.h | 10 ++++++++++
2 files changed, 16 insertions(+)
diff --git a/core/polkitqt1-subject.cpp b/core/polkitqt1-subject.cpp
index f0d69c6..ecb4c0e 100644
--- a/core/polkitqt1-subject.cpp
+++ b/core/polkitqt1-subject.cpp
@@ -19,6 +19,7 @@
*/
#include "polkitqt1-subject.h"
+#include "polkitqt1-identity.h"
#include <QtCore/QDebug>
#include <polkit/polkit.h>
@@ -180,6 +181,11 @@ void SystemBusNameSubject::setName(const QString &name)
polkit_system_bus_name_set_name((PolkitSystemBusName *) subject(), name.toUtf8().data());
}
+UnixUserIdentity SystemBusNameSubject::user()
+{
+ return UnixUserIdentity(polkit_system_bus_name_get_user_sync((PolkitSystemBusName *) subject(), NULL, NULL));
+}
+
// ----- SystemSession
UnixSessionSubject::UnixSessionSubject(const QString &sessionId)
: Subject()
diff --git a/core/polkitqt1-subject.h b/core/polkitqt1-subject.h
index 4c7a22b..03028f6 100644
--- a/core/polkitqt1-subject.h
+++ b/core/polkitqt1-subject.h
@@ -40,6 +40,8 @@ typedef struct _PolkitSystemBusName PolkitSystemBusName;
namespace PolkitQt1
{
+class UnixUserIdentity;
+
/**
* \class Subject polkitqt1-subject.h Subject
* \author Jaroslav Reznik <jreznik@redhat.com>
@@ -208,6 +210,14 @@ public:
* \param name System bus name.
*/
void setName(const QString &name);
+
+ /**
+ * Returns the UnixUserIdentity for this subject.
+ *
+ * The ownership of the returned pointer is passed to the caller.
+ * \since 0.113
+ **/
+ UnixUserIdentity user();
};
/**
--
2.5.0

@ -0,0 +1,92 @@
From d2b6703be5c01a26a384d33f88314801c8a27932 Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Thu, 14 Jan 2016 17:38:39 +0000
Subject: [PATCH 6/8] Drop use of deprecated Qt functions REVIEW: 126747
---
CMakeLists.txt | 1 -
agent/polkitqt1-agent-listener.cpp | 2 +-
core/polkitqt1-authority.cpp | 14 +++++++-------
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb91bde..8daeb01 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,7 +35,6 @@ if(USE_QT5)
set(REQUIRED_QT_VERSION 5.1.0)
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core DBus Widgets)
- add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
set(POLKITQT-1_PCNAME "polkit-qt5-1")
set(POLKITQT-1_CORE_PCNAME "polkit-qt5-core-1")
diff --git a/agent/polkitqt1-agent-listener.cpp b/agent/polkitqt1-agent-listener.cpp
index 38744ec..5efc091 100644
--- a/agent/polkitqt1-agent-listener.cpp
+++ b/agent/polkitqt1-agent-listener.cpp
@@ -94,7 +94,7 @@ bool Listener::registerListener(const PolkitQt1::Subject &subject, const QString
bool r = polkit_agent_register_listener(d->listener,
#endif
subject.subject(),
- objectPath.toAscii().data(),
+ objectPath.toLatin1().data(),
#ifndef POLKIT_QT_1_COMPATIBILITY_MODE
NULL,
#endif
diff --git a/core/polkitqt1-authority.cpp b/core/polkitqt1-authority.cpp
index efa8271..886fb41 100644
--- a/core/polkitqt1-authority.cpp
+++ b/core/polkitqt1-authority.cpp
@@ -286,7 +286,7 @@ void Authority::Private::dbusFilter(const QDBusMessage &message)
// TODO: Test this with the multiseat support
if (message.member() == "SeatAdded") {
- seatSignalsConnect(qVariantValue<QDBusObjectPath> (message.arguments()[0]).path());
+ seatSignalsConnect(message.arguments()[0].value<QDBusObjectPath>().path());
}
}
}
@@ -342,7 +342,7 @@ Authority::Result Authority::checkAuthorizationSync(const QString &actionId, con
pk_result = polkit_authority_check_authorization_sync(d->pkAuthority,
subject.subject(),
- actionId.toAscii().data(),
+ actionId.toLatin1().data(),
NULL,
(PolkitCheckAuthorizationFlags)(int)flags,
NULL,
@@ -377,7 +377,7 @@ void Authority::checkAuthorization(const QString &actionId, const Subject &subje
polkit_authority_check_authorization(d->pkAuthority,
subject.subject(),
- actionId.toAscii().data(),
+ actionId.toLatin1().data(),
NULL,
(PolkitCheckAuthorizationFlags)(int)flags,
d->m_checkAuthorizationCancellable,
@@ -489,8 +489,8 @@ bool Authority::registerAuthenticationAgentSync(const Subject &subject, const QS
}
result = polkit_authority_register_authentication_agent_sync(d->pkAuthority,
- subject.subject(), locale.toAscii().data(),
- objectPath.toAscii().data(), NULL, &error);
+ subject.subject(), locale.toLatin1().data(),
+ objectPath.toLatin1().data(), NULL, &error);
if (error) {
d->setError(E_RegisterFailed, error->message);
@@ -514,8 +514,8 @@ void Authority::registerAuthenticationAgent(const Subject &subject, const QStrin
polkit_authority_register_authentication_agent(d->pkAuthority,
subject.subject(),
- locale.toAscii().data(),
- objectPath.toAscii().data(),
+ locale.toLatin1().data(),
+ objectPath.toLatin1().data(),
d->m_registerAuthenticationAgentCancellable,
d->registerAuthenticationAgentCallback,
this);
--
2.5.0

@ -0,0 +1,27 @@
From 4528ea9f808f7f9de56dee70626040bed2b4b67c Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Thu, 14 Jan 2016 17:37:09 +0000
Subject: [PATCH 7/8] Fix compilation with Qt5.6
Qt5.6 has c++11x in code in the headers, so it needs including
REVIEW: 126746
---
CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8daeb01..a60dfa2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,7 @@ if(USE_QT5)
message(STATUS "Using Qt 5")
set(REQUIRED_QT_VERSION 5.1.0)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core DBus Widgets)
--
2.5.0

@ -0,0 +1,94 @@
From 15c7867e88c5278f61896b5531ac2b544add8220 Mon Sep 17 00:00:00 2001
From: Alex Richardson <arichardson.kde@gmail.com>
Date: Fri, 26 Feb 2016 15:59:21 +0000
Subject: [PATCH 8/8] Allow compilation with older polkit versions
Return an invalid user from SystemBusNameSubject::user() if
polkit_system_bus_name_get_user_sync is missing
REVIEW: 126813
---
CMakeLists.txt | 3 +++
core/polkitqt1-subject.cpp | 6 ++++++
core/polkitqt1-subject.h | 3 ++-
polkitqt1-config.h.cmake | 1 +
4 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 polkitqt1-config.h.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a60dfa2..13d9dbd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,6 +101,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/core
${CMAKE_CURRENT_SOURCE_DIR}/includes
+ ${CMAKE_CURRENT_BINARY_DIR}
)
if(NOT USE_QT5)
include_directories(
@@ -113,6 +114,7 @@ set(CMAKE_REQUIRED_INCLUDES ${POLKIT_INCLUDE_DIR} ${POLKIT_AGENT_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${POLKIT_LIBRARIES} ${POLKIT_AGENT_LIBRARY})
check_function_exists(polkit_agent_listener_register HAVE_POLKIT_AGENT_LISTENER_REGISTER)
check_function_exists(polkit_authority_get_sync HAVE_POLKIT_AUTHORITY_GET_SYNC)
+check_function_exists(polkit_system_bus_name_get_user_sync HAVE_POLKIT_SYSTEM_BUS_NAME_GET_USER_SYNC)
if (NOT HAVE_POLKIT_AGENT_LISTENER_REGISTER OR NOT HAVE_POLKIT_AUTHORITY_GET_SYNC)
message(STATUS "You have an older polkit-1 version: Polkit-Qt-1 will be built in compatibility mode")
@@ -134,6 +136,7 @@ set(POLKITQT-1_LIBRARY_VERSION "${POLKITQT-1_ABI_VERSION}.${POLKITQT-1_VERSION_M
set(POLKITQT-1_LIB_NAMESPACE ${POLKITQT-1_CAMEL_NAME})
configure_file(polkitqt1-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkitqt1-version.h)
+configure_file(polkitqt1-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/polkitqt1-config.h)
install(FILES
gui/polkitqt1-gui-action.h
diff --git a/core/polkitqt1-subject.cpp b/core/polkitqt1-subject.cpp
index ecb4c0e..ea10828 100644
--- a/core/polkitqt1-subject.cpp
+++ b/core/polkitqt1-subject.cpp
@@ -20,6 +20,7 @@
#include "polkitqt1-subject.h"
#include "polkitqt1-identity.h"
+#include "polkitqt1-config.h"
#include <QtCore/QDebug>
#include <polkit/polkit.h>
@@ -183,7 +184,12 @@ void SystemBusNameSubject::setName(const QString &name)
UnixUserIdentity SystemBusNameSubject::user()
{
+#if HAVE_POLKIT_SYSTEM_BUS_NAME_GET_USER_SYNC
return UnixUserIdentity(polkit_system_bus_name_get_user_sync((PolkitSystemBusName *) subject(), NULL, NULL));
+#else
+ qWarning("Polkit is too old, returning invalid user from SystemBusNameSubject::user()!");
+ return UnixUserIdentity();
+#endif
}
// ----- SystemSession
diff --git a/core/polkitqt1-subject.h b/core/polkitqt1-subject.h
index 03028f6..01323a2 100644
--- a/core/polkitqt1-subject.h
+++ b/core/polkitqt1-subject.h
@@ -214,7 +214,8 @@ public:
/**
* Returns the UnixUserIdentity for this subject.
*
- * The ownership of the returned pointer is passed to the caller.
+ * \note This can be an invalid UnixUserIdentity so be sure to check before using it
+ *
* \since 0.113
**/
UnixUserIdentity user();
diff --git a/polkitqt1-config.h.cmake b/polkitqt1-config.h.cmake
new file mode 100644
index 0000000..fed40a9
--- /dev/null
+++ b/polkitqt1-config.h.cmake
@@ -0,0 +1 @@
+#cmakedefine01 HAVE_POLKIT_SYSTEM_BUS_NAME_GET_USER_SYNC
--
2.5.0

@ -0,0 +1,2 @@
%_polkit_qt 1
%_polkit_qt_policydir %{_datadir}/polkit-1/actions

@ -1,19 +1,26 @@
Name: polkit-qt5-1
Version: 0.103.0
Release: 4.20130415gitbac771e%{?dist}
Version: 0.112.0
Release: 1%{?dist}
Summary: Qt5 bindings for PolicyKit
License: GPLv2+
URL: https://projects.kde.org/projects/kdesupport/polkit-qt-1
# git clone git://anongit.kde.org/polkit-qt-1
# cd polkit-qt-1
# git archive --prefix=polkit-qt5-1/ bac771e |gzip -9 >polkit-qt5-1.tar.gz
Source0: %{name}.tar.gz
Source0: http://download.kde.org/stable/apps/KDE4.x/admin/polkit-qt-1-%{version}.tar.bz2
Source1: Doxyfile
BuildRequires: automoc4
BuildRequires: cmake
## upstream patches
Patch1: 0001-do-not-use-global-static-systembus-instance.patch
Patch2: 0002-fix-build-with-Qt4-which-doesn-t-have-QStringLiteral.patch
Patch3: 0003-Fix-QDBusArgument-assertion.patch
Patch5: 0005-Add-wrapper-for-polkit_system_bus_name_get_user_sync.patch
Patch6: 0006-Drop-use-of-deprecated-Qt-functions.patch
Patch7: 0007-Fix-compilation-with-Qt5.6.patch
Patch8: 0008-Allow-compilation-with-older-polkit-versions.patch
Source10: macros.polkit-qt
BuildRequires: extra-cmake-modules
BuildRequires: kf5-rpm-macros
BuildRequires: pkgconfig(polkit-agent-1) pkgconfig(polkit-gobject-1)
BuildRequires: pkgconfig(Qt5DBus) pkgconfig(Qt5Gui) pkgconfig(Qt5Widgets) pkgconfig(Qt5Xml)
@ -32,29 +39,41 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
%prep
%setup -q -n %{name}
%autosetup -n polkit-qt-1-%{version} -p1
%build
%{cmake} .
make %{?_smp_mflags}
mkdir %{_target_platform}
pushd %{_target_platform}
%{cmake_kf5} .. \
-DUSE_QT4:BOOL=OFF -DUSE_QT5:BOOL=ON \
-DBUILD_EXAMPLES:BOOL=OFF \
-DDATA_INSTALL_DIR:PATH=%{_datadir}
popd
make %{?_smp_mflags} -C %{_target_platform}
%install
make install DESTDIR=%{buildroot}
make install/fast DESTDIR=%{buildroot} -C %{_target_platform}
## skip (for now, may conflicts with el core polkit-qt)
#install -p -m644 -D %{SOURCE10} %{buildroot}%{rpm_macros_dir}/macros.polkit-qt
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%doc AUTHORS COPYING README
%doc AUTHORS README
%license COPYING
%{_libdir}/libpolkit-qt5-core-1.so.1*
%{_libdir}/libpolkit-qt5-gui-1.so.1*
%{_libdir}/libpolkit-qt5-agent-1.so.1*
%files devel
#{rpm_macros_dir}/macros.polkit-qt
%{_includedir}/polkit-qt5-1/
%{_libdir}/libpolkit-qt5-core-1.so
%{_libdir}/libpolkit-qt5-gui-1.so
@ -63,10 +82,13 @@ make install DESTDIR=%{buildroot}
%{_libdir}/pkgconfig/polkit-qt5-core-1.pc
%{_libdir}/pkgconfig/polkit-qt5-gui-1.pc
%{_libdir}/pkgconfig/polkit-qt5-agent-1.pc
%{_libdir}/cmake/PolkitQt5-1
%{_libdir}/cmake/PolkitQt5-1/
%changelog
* Tue Apr 05 2016 Rex Dieter <rdieter@fedoraproject.org> - 0.112.0-1
- sync latest goodies from fedora polkit-qt module
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.103.0-4.20130415gitbac771e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

@ -1 +1,2 @@
35e28312d1e441eb35b5deabe51b3e90 polkit-qt5-1.tar.gz
bee71b71c12797e6fc498540a06c829b polkit-qt-1-0.112.0.tar.bz2
c961457165b36794674b97e9dced5fb8 Doxyfile

Loading…
Cancel
Save