Skip to content

Commit

Permalink
[libsignon-qt] Always use P2P DBus if enabled. Contributes to JB#42126
Browse files Browse the repository at this point in the history
This commit ensures that if the enable-p2p config is set, we don't
ever allow falling back to the session bus to service signon requests,
as that could result in leaking sensitive information.
  • Loading branch information
Chris Adams committed Jun 21, 2018
1 parent b00ded9 commit 8a09ade
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
21 changes: 18 additions & 3 deletions libsignon/lib/SignOn/connection-manager.cpp
Expand Up @@ -40,7 +40,8 @@ static QPointer<ConnectionManager> connectionInstance = 0;
ConnectionManager::ConnectionManager(QObject *parent):
QObject(parent),
m_connection(QLatin1String("libsignon-qt-invalid")),
m_serviceStatus(ServiceStatusUnknown)
m_serviceStatus(ServiceStatusUnknown),
m_retryCount(0)
{
if (connectionInstance == 0) {
init();
Expand Down Expand Up @@ -128,6 +129,21 @@ void ConnectionManager::init()

SocketConnectionStatus status = setupSocketConnection();

if (status == SocketConnectionUnavailable) {
#ifdef ENABLE_P2P
if (m_retryCount >= 15) {
BLAME() << "Unable to activate p2p signond service!";
return;
}
TRACE() << "Unable to activate p2p signond service, trying again";
status = SocketConnectionNoService;
m_retryCount += 1;
#else
TRACE() << "Unable to activate p2p signond service, falling back to session bus";
m_connection = SIGNOND_BUS;
#endif
}

if (status == SocketConnectionNoService) {
TRACE() << "Peer connection unavailable, activating service";
QDBusConnectionInterface *interface =
Expand All @@ -142,11 +158,10 @@ void ConnectionManager::init()
SIGNAL(finished(QDBusPendingCallWatcher*)),
this,
SLOT(onActivationDone(QDBusPendingCallWatcher*)));
} else if (status == SocketConnectionUnavailable) {
m_connection = SIGNOND_BUS;
}

if (m_connection.isConnected()) {
m_retryCount = 0;
TRACE() << "Connected to" << m_connection.name();
Q_EMIT connected(m_connection);
}
Expand Down
1 change: 1 addition & 0 deletions libsignon/lib/SignOn/connection-manager.h
Expand Up @@ -74,6 +74,7 @@ private Q_SLOTS:
private:
QDBusConnection m_connection;
ServiceStatus m_serviceStatus;
int m_retryCount;
};

}
Expand Down
4 changes: 4 additions & 0 deletions libsignon/lib/SignOn/libsignon-qt.pri
Expand Up @@ -57,6 +57,10 @@ DEFINES += \
QT_NO_CAST_FROM_ASCII \
LIBSIGNON_TRACE

CONFIG(enable-p2p) {
DEFINES += ENABLE_P2P
}

include( $$TOP_SRC_DIR/common-installs-config.pri )

headers.files = $$public_headers \
Expand Down

0 comments on commit 8a09ade

Please sign in to comment.