linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 2/3] kernel-shark: Do not save the settings when running as Root
Date: Fri, 18 Oct 2019 10:47:21 +0300	[thread overview]
Message-ID: <20191018074722.6976-2-y.karadz@gmail.com> (raw)
In-Reply-To: <20191018074722.6976-1-y.karadz@gmail.com>

Do not save the settings if KernelShark is running with Root privileges.
Otherwise the configuration file will be owned by Root and later the
normal user will have no access to it.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsMainWindow.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 3402764..6da8670 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -152,9 +152,15 @@ KsMainWindow::~KsMainWindow()
 					_session.getConfDocPtr());
 	}
 
-	_settings.setValue("dataPath", _lastDataFilePath);
-	_settings.setValue("confPath", _lastConfFilePath);
-	_settings.setValue("pluginPath", _lastPluginFilePath);
+	/*
+	 * Do not save the settings if KernelShark is running with Root
+	 * privileges. Otherwise the configuration file will be owned by Root.
+	 */
+	if (geteuid() != 0) {
+		_settings.setValue("dataPath", _lastDataFilePath);
+		_settings.setValue("confPath", _lastConfFilePath);
+		_settings.setValue("pluginPath", _lastPluginFilePath);
+	}
 
 	_data.clear();
 
-- 
2.20.1


  reply	other threads:[~2019-10-18  7:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18  7:47 [PATCH 1/3] kernel-shark: Fix simple typo in the "File" menu Yordan Karadzhov (VMware)
2019-10-18  7:47 ` Yordan Karadzhov (VMware) [this message]
2019-10-18 14:32   ` [PATCH 2/3] kernel-shark: Do not save the settings when running as Root Steven Rostedt
2019-10-23 10:49     ` Yordan Karadzhov (VMware)
2019-10-23 11:59       ` Steven Rostedt
2019-10-18  7:47 ` [PATCH 3/3] kernel-shark: Fix potential memory leak in libkshark-collection Yordan Karadzhov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191018074722.6976-2-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).