Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(ipc): handle ipc failure gracefully
Browse files Browse the repository at this point in the history
Allows running qTox inside jails that block IPC.

Fix #5740
  • Loading branch information
anthonybilinski committed Aug 29, 2019
1 parent 64aa3ea commit 9dd0839
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,12 @@ int main(int argc, char* argv[])

uint32_t profileId = settings.getCurrentProfileId();
IPC ipc(profileId);
if (!ipc.isAttached()) {
qCritical() << "Can't init IPC";
return EXIT_FAILURE;
if (ipc.isAttached()) {
QObject::connect(&settings, &Settings::currentProfileIdChanged, &ipc, &IPC::setProfileId);
} else {
qWarning() << "Can't init IPC, maybe we're in a jail? Continuing with reduced multi-client functionality.";
}

QObject::connect(&settings, &Settings::currentProfileIdChanged, &ipc, &IPC::setProfileId);

// For the auto-updater
if (sodium_init() < 0) {
qCritical() << "Can't init libsodium";
Expand Down Expand Up @@ -278,7 +277,7 @@ int main(int argc, char* argv[])
bool autoLogin = settings.getAutoLogin();

uint32_t ipcDest = 0;
bool doIpc = true;
bool doIpc = ipc.isAttached();
QString eventType, firstParam;
if (parser.isSet("p")) {
profileName = parser.value("p");
Expand Down Expand Up @@ -359,10 +358,12 @@ int main(int argc, char* argv[])
}
}

// Start to accept Inter-process communication
ipc.registerEventHandler("uri", &toxURIEventHandler);
ipc.registerEventHandler("save", &toxSaveEventHandler);
ipc.registerEventHandler("activate", &toxActivateEventHandler);
if (ipc.isAttached()) {
// Start to accept Inter-process communication
ipc.registerEventHandler("uri", &toxURIEventHandler);
ipc.registerEventHandler("save", &toxSaveEventHandler);
ipc.registerEventHandler("activate", &toxActivateEventHandler);
}

// Event was not handled by already running instance therefore we handle it ourselves
if (eventType == "uri")
Expand Down

0 comments on commit 9dd0839

Please sign in to comment.