Skip to content

Commit ddbdce9

Browse files
committed
safety: show (superuser) in title if started as root
1 parent dc4f70a commit ddbdce9

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Future
2+
* Improved context menu (copy, confirmations)
3+
* Show if running as root in title
4+
15
# 1.0.1
26

37
* New color scheme dialog allowing users to override colors

‎src/configuration.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <QSettings>
2525
#include <QVariantList>
2626

27+
#include <unistd.h>
28+
2729
Configuration *Configuration::s_instance = nullptr;
2830

2931
Configuration *Configuration::instance()
@@ -49,6 +51,7 @@ void Configuration::Load()
4951
this->RefreshRateMs = s.value("General/RefreshRateMs", this->RefreshRateMs).toInt();
5052
this->UseCustomColorScheme = s.value("General/UseCustomColorScheme", this->UseCustomColorScheme).toBool();
5153
this->CustomColorScheme = s.value("General/CustomColorScheme", this->CustomColorScheme).toMap();
54+
this->IsSuperuser = (::geteuid() == 0);
5255

5356
// Processes
5457
this->ShowKernelTasks = s.value("Processes/ShowKernelTasks", this->ShowKernelTasks).toBool();

‎src/configuration.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class Configuration : public QObject
4949
int RefreshRateMs { 1000 }; ///< How often live data is refreshed (ms)
5050
bool UseCustomColorScheme { false };
5151
QVariantMap CustomColorScheme;
52+
bool IsSuperuser { false }; ///< True when effective UID is 0 (runtime-only).
5253
//! Intervals (in ms) available in menus for refresh rate (250ms, 1s, 5s etc.)
5354
QVector<int> RefreshRateAvailableIntervals;
5455

‎src/mainwindow.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
2929
{
3030
this->ui->setupUi(this);
3131

32+
if (CFG->IsSuperuser)
33+
{
34+
// Make user aware of this
35+
this->setWindowTitle(this->windowTitle() + " (superuser)");
36+
}
37+
3238
this->ui->processesLayout->addWidget(this->m_processesWidget);
3339
this->ui->performanceLayout->addWidget(this->m_performanceWidget);
3440
this->ui->usersLayout->addWidget(this->m_usersWidget);

0 commit comments

Comments
 (0)