Skip to content

Commit

Permalink
[libsignon-qt] Use p2p dbus for signon-ui flows. Contributes to JB#42126
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Adams committed Jun 21, 2018
1 parent 8a09ade commit ddc271b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
26 changes: 24 additions & 2 deletions libsignon/src/signond/signonidentity.cpp
Expand Up @@ -26,6 +26,9 @@

#include <iostream>
#include <QVariantMap>
#ifdef ENABLE_P2P
#include <QStandardPaths>
#endif

#include "signond-common.h"
#include "signonidentity.h"
Expand Down Expand Up @@ -85,10 +88,11 @@ class PendingCallWatcherWithContext: public QDBusPendingCallWatcher
SignonIdentity::SignonIdentity(quint32 id, int timeout,
SignonDaemon *parent):
SignonDisposable(timeout, parent),
m_id(id),
m_p2pc(QStringLiteral("identity.dbus.connection")),
m_signonui(NULL),
m_pInfo(NULL)
{
m_id = id;

(void)new SignonIdentityAdaptor(this);

/*
Expand All @@ -99,10 +103,28 @@ SignonIdentity::SignonIdentity(quint32 id, int timeout,
+ QString::number(incr++, 16);
setObjectName(objectName);

#ifdef ENABLE_P2P
m_p2pc = QDBusConnection::connectToPeer(
QStringLiteral("unix:path=%1/signonui-socket")
.arg(QStandardPaths::writableLocation(
QStandardPaths::RuntimeLocation)),
objectName);
if (!m_p2pc.isConnected()) {
BLAME() << "Identity unable to connect to signonui socket:"
<< m_p2pc.lastError()
<< m_p2pc.lastError().type()
<< m_p2pc.lastError().name();
}
m_signonui = new SignonUiAdaptor(SIGNON_UI_SERVICE,
SIGNON_UI_DAEMON_OBJECTPATH,
m_p2pc,
this);
#else
m_signonui = new SignonUiAdaptor(SIGNON_UI_SERVICE,
SIGNON_UI_DAEMON_OBJECTPATH,
QDBusConnection::sessionBus(),
this);
#endif

/* Watch for credential updates happening outside of this object (this can
* happen on request of authentication plugins) */
Expand Down
1 change: 1 addition & 0 deletions libsignon/src/signond/signonidentity.h
Expand Up @@ -95,6 +95,7 @@ private Q_SLOTS:

private:
quint32 m_id;
QDBusConnection m_p2pc;
SignonUiAdaptor *m_signonui;
SignonIdentityInfo *m_pInfo;
}; //class SignonDaemon
Expand Down
36 changes: 34 additions & 2 deletions libsignon/src/signond/signonsessioncore.cpp
Expand Up @@ -33,6 +33,10 @@
#include "SignOn/authpluginif.h"
#include "SignOn/signonerror.h"

#ifdef ENABLE_P2P
#include <QStandardPaths>
#endif

#define MAX_IDLE_TIME SIGNOND_MAX_IDLE_TIME
/*
* the watchdog searches for idle sessions with period of half of idle timeout
Expand Down Expand Up @@ -76,6 +80,7 @@ SignonSessionCore::SignonSessionCore(quint32 id,
int timeout,
QObject *parent):
SignonDisposable(timeout, parent),
m_p2pc(QStringLiteral("session.dbus.connection")),
m_signonui(0),
m_watcher(0),
m_requestIsActive(false),
Expand All @@ -84,10 +89,26 @@ SignonSessionCore::SignonSessionCore(quint32 id,
m_method(method),
m_queryCredsUiDisplayed(false)
{
#ifdef ENABLE_P2P
m_p2pc = QDBusConnection::connectToPeer(
QStringLiteral("unix:path=%1/signonui-socket")
.arg(QStandardPaths::writableLocation(
QStandardPaths::RuntimeLocation)),
QStringLiteral("signon-session-core-%1").arg(id));
if (!m_p2pc.isConnected()) {
BLAME() << "Session unable to connect to signonui socket:"
<< m_p2pc.lastError()
<< m_p2pc.lastError().type()
<< m_p2pc.lastError().name();
}
m_signonui = new SignonUiAdaptor(SIGNON_UI_SERVICE,
SIGNON_UI_DAEMON_OBJECTPATH,
m_p2pc);
#else
m_signonui = new SignonUiAdaptor(SIGNON_UI_SERVICE,
SIGNON_UI_DAEMON_OBJECTPATH,
QDBusConnection::sessionBus());

#endif

connect(CredentialsAccessManager::instance(),
SIGNAL(credentialsSystemReady()),
Expand Down Expand Up @@ -326,13 +347,24 @@ void SignonSessionCore::setId(quint32 id)

void SignonSessionCore::startProcess()
{

TRACE() << "the number of requests is" << m_listOfRequests.length();

m_requestIsActive = true;
RequestData data = m_listOfRequests.head();
QVariantMap parameters = data.m_params;

#ifdef ENABLE_P2P
/* inject the in-process signon ui bus address */
pid_t clientPid = AccessControlManagerHelper::pidOfPeer(
data.m_conn, data.m_msg);
parameters.insert(
QStringLiteral("InProcessBusAddress"),
QStringLiteral("unix:path=%1/signonui-%2-socket")
.arg(QStandardPaths::writableLocation(
QStandardPaths::RuntimeLocation))
.arg(clientPid));
#endif

/* save the client data; this should not be modified during the processing
* of this request */
m_clientData = parameters;
Expand Down
1 change: 1 addition & 0 deletions libsignon/src/signond/signonsessioncore.h
Expand Up @@ -126,6 +126,7 @@ private Q_SLOTS:
private:
PluginProxy *m_plugin;
QQueue<RequestData> m_listOfRequests;
QDBusConnection m_p2pc;
SignonUiAdaptor *m_signonui;

QDBusPendingCallWatcher *m_watcher;
Expand Down

0 comments on commit ddc271b

Please sign in to comment.