Skip to content

Commit

Permalink
(ckb) Simple guard to prevent the GUI from running as root
Browse files Browse the repository at this point in the history
(ckb) Session resume shouldn't cause the GUI to pop up anymore
  • Loading branch information
ccMSC committed Jan 15, 2016
1 parent c65b631 commit 000d7e6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ckb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ int main(int argc, char *argv[]){
QApplication a(argc, argv);
QCoreApplication::setOrganizationName("ckb");

// Although the daemon runs as root, the GUI needn't and shouldn't be, as it has the potential to corrupt settings data.
if(getuid() == 0){
printf("The ckb GUI should not be run as root.\n");
return 0;
}

// Seed the RNG for UsbIds
qsrand(QDateTime::currentMSecsSinceEpoch());
#ifdef Q_OS_MACX
Expand All @@ -105,8 +111,8 @@ int main(int argc, char *argv[]){
return 0;
}

// Launch in background if requested
bool background = qApp->arguments().contains("--background");
// Launch in background if requested, or if re-launching a previous session
bool background = qApp->arguments().contains("--background") || qApp->arguments().contains("-session") || qApp->arguments().contains("--session");
if(isRunning(background ? 0 : "Open")){
printf("ckb is already running. Exiting.\n");
return 0;
Expand Down

0 comments on commit 000d7e6

Please sign in to comment.