diff mbox series

[v2,1/5] kernel-shark: Show warning message when running as Root

Message ID 20190826155811.32021-2-y.karadz@gmail.com (mailing list archive)
State Superseded
Headers show
Series Handle the case when KernelShark is started as Root | expand

Commit Message

Yordan Karadzhov Aug. 26, 2019, 3:58 p.m. UTC
Running the KernelShark GUI with Root privileges is not recommended due
to security reasons. The user will be allowed to continue on its own risk.

Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204475
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsMainWindow.cpp | 28 ++++++++++++++++++++++++++++
 kernel-shark/src/KsMainWindow.hpp |  2 ++
 2 files changed, 30 insertions(+)

Comments

Steven Rostedt Aug. 27, 2019, 10:22 p.m. UTC | #1
On Mon, 26 Aug 2019 18:58:07 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> +	warn.setText("KernelShark will have Root privileges.");
> +	warn.setInformativeText("Continue on your own risk.");

This wasn't updated.

 From: https://lore.kernel.org/linux-trace-devel/20190809091914.75f553b2@gandalf.local.home/

> > +	QMessageBox warn;
> > +	warn.setText("KernelShark will have Root privileges.");
> > +	warn.setInformativeText("Continue on your one risk.");  
> 
> Probably better to say:
> 
>   "KernelShark is running with Root privileges."
>   "Continue at your own risk."

I could update the patch if you like, instead of sending out another
series. Let me finish the rest of the series.

-- Steve
Steven Rostedt Sept. 19, 2019, 8:32 p.m. UTC | #2
On Tue, 27 Aug 2019 18:22:53 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Mon, 26 Aug 2019 18:58:07 +0300
> "Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
> 
> > +	warn.setText("KernelShark will have Root privileges.");
> > +	warn.setInformativeText("Continue on your own risk.");  
> 
> This wasn't updated.
> 
>  From: https://lore.kernel.org/linux-trace-devel/20190809091914.75f553b2@gandalf.local.home/
> 
> > > +	QMessageBox warn;
> > > +	warn.setText("KernelShark will have Root privileges.");
> > > +	warn.setInformativeText("Continue on your one risk.");    
> > 
> > Probably better to say:
> > 
> >   "KernelShark is running with Root privileges."
> >   "Continue at your own risk."  
> 
> I could update the patch if you like, instead of sending out another
> series. Let me finish the rest of the series.
> 

We decided in our meeting that you were going to send a v3, right? Just
want to make sure (too many things to keep track of ;-)

Thanks!

-- Steve
Yordan Karadzhov Sept. 20, 2019, 10:27 a.m. UTC | #3
On 19.09.19 г. 23:32 ч., Steven Rostedt wrote:
> On Tue, 27 Aug 2019 18:22:53 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
>> On Mon, 26 Aug 2019 18:58:07 +0300
>> "Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
>>
>>> +	warn.setText("KernelShark will have Root privileges.");
>>> +	warn.setInformativeText("Continue on your own risk.");
>>
>> This wasn't updated.
>>
>>   From: https://lore.kernel.org/linux-trace-devel/20190809091914.75f553b2@gandalf.local.home/
>>
>>>> +	QMessageBox warn;
>>>> +	warn.setText("KernelShark will have Root privileges.");
>>>> +	warn.setInformativeText("Continue on your one risk.");
>>>
>>> Probably better to say:
>>>
>>>    "KernelShark is running with Root privileges."
>>>    "Continue at your own risk."
>>
>> I could update the patch if you like, instead of sending out another
>> series. Let me finish the rest of the series.
>>
> 
> We decided in our meeting that you were going to send a v3, right? Just
> want to make sure (too many things to keep track of ;-)

Yes, I am sending v3 right now.
Y.

> 
> Thanks!
> 
> -- Steve
>
diff mbox series

Patch

diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 6439265..2f86517 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -76,6 +76,9 @@  KsMainWindow::KsMainWindow(QWidget *parent)
 	_createMenus();
 	_initCapture();
 
+	if (geteuid() == 0)
+		_rootWarning();
+
 	_splitter.addWidget(&_graph);
 	_splitter.addWidget(&_view);
 	setCentralWidget(&_splitter);
@@ -1271,3 +1274,28 @@  void KsMainWindow::_deselectB()
 	_mState.updateLabels();
 	_graph.glPtr()->model()->update();
 }
+
+void KsMainWindow::_rootWarning()
+{
+	QString cbFlag("noRootWarn");
+
+	if (_settings.value(cbFlag).toBool())
+		return;
+
+	QMessageBox warn;
+	warn.setText("KernelShark will have Root privileges.");
+	warn.setInformativeText("Continue on your own risk.");
+	warn.setIcon(QMessageBox::Warning);
+	warn.setStandardButtons(QMessageBox::Close);
+
+	QCheckBox cb("Don't show this message again.");
+
+	auto lamCbChec = [&] (int state) {
+		if (state)
+			_settings.setValue(cbFlag, true);
+	};
+
+	connect(&cb, &QCheckBox::stateChanged, lamCbChec);
+	warn.setCheckBox(&cb);
+	warn.exec();
+}
diff --git a/kernel-shark/src/KsMainWindow.hpp b/kernel-shark/src/KsMainWindow.hpp
index 62e66a0..4a7b8ab 100644
--- a/kernel-shark/src/KsMainWindow.hpp
+++ b/kernel-shark/src/KsMainWindow.hpp
@@ -238,6 +238,8 @@  private:
 
 	void _deselectB();
 
+	void _rootWarning();
+
 	void _updateFilterMenu();
 
 	void _filterSyncCBoxUpdate(kshark_context *kshark_ctx);