Re: [PATCH 2/3] kernel-shark: Do not save the settings when running as Root

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 18.10.19 г. 17:32 ч., Steven Rostedt wrote:
On Fri, 18 Oct 2019 10:47:21 +0300
"Yordan Karadzhov (VMware)" <y.karadz@xxxxxxxxx> wrote:

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.

Perhaps we should have the settings saved in the root home directory?

Reason being, I run kernelshark as root all the time (on my test boxes,
where I only log in as root).

And I would still like to have the settings saved. Maybe check if the
settings path is the same as $HOME variable?


OK I think I have a solution that does a better job. Do you prefer to resend all 3 patches or just this one?

Thanks!
Yordan


-- Steve


Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx>
---
  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();




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux