Skip to contentSkip to conversation

kernel-shark: Fix simple typo in the "File" menu.

PATCH Superseded Yordan Karadzhov (VMware) 2 participants 6 messages Oct 18, 2019 – Oct 23, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 kernel-shark: Fix simple typo in the "File" menu.

---
 kernel-shark/src/KsMainWindow.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shark/src/KsMainWindow.cpp +1 -1
index a583f5f..3402764 100644
@@ -45,7 +45,7 @@ KsMainWindow::KsMainWindow(QWidget *parent)
   _openAction("Open", this),
   _restoreSessionAction("Restore Last Session", this),
   _importSessionAction("Import Session", this),
-  _exportSessionAction("Export Sassion", this),
+  _exportSessionAction("Export Session", this),
   _quitAction("Quit", this),
   _importFilterAction("Import Filter", this),
   _exportFilterAction("Export Filter", this),
Signature · 1 line
2.20.1
#1 lore raw

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

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.

---
 kernel-shark/src/KsMainWindow.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
kernel-shark/src/KsMainWindow.cpp +9 -3
index 3402764..6da8670 100644
@@ -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();
 
Signature · 1 line
2.20.1
#2 lore raw

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

Quoted 3 lines · On Fri, 18 Oct 2019 10:47:21 +0300 "Yordan Karadzhov (VMware)"…

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?

-- Steve

Quoted 29 lines
---
 kernel-shark/src/KsMainWindow.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
kernel-shark/src/KsMainWindow.cpp +9 -3
index 3402764..6da8670 100644
@@ -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();
 
#3 lore raw

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

Quoted 7 lines · Steven Rostedt
Quoted 3 lines · On Fri, 18 Oct 2019 10:47:21 +0300 "Yordan Karadzhov (VMware)"…

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.

Quoted 8 lines

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

Quoted 32 lines

-- Steve

Quoted 29 lines
---
  kernel-shark/src/KsMainWindow.cpp | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)
kernel-shark/src/KsMainWindow.cpp +9 -3
index 3402764..6da8670 100644
@@ -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();
 
#4 lore raw

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

Quoted 2 lines · On Wed, 23 Oct 2019 13:49:25 +0300 "Yordan Karadzhov (VMware)"…

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

Send them all again.

Thanks!

-- Steve

#5 lore raw

PATCH 3/3 kernel-shark: Fix potential memory leak in libkshark-collection

In reply to Yordan Karadzhov (VMware)

When searching for the entry, do not loop over the original list of requests. Use a copy instead. If we loop over the original list and no entry is found in the first element of the list, later the memory used for this first element will leak.

---
 kernel-shark/src/libkshark-collection.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
kernel-shark/src/libkshark-collection.c +6 -8
index 02a014e..95fdbab 100644
@@ -622,6 +622,7 @@ kshark_get_collection_entry_front(struct kshark_entry_request **req,
 				  ssize_t *index)
 {
 	const struct kshark_entry *entry = NULL;
+	struct kshark_entry_request *list;
 	int req_count;
 
 	/*
@@ -638,12 +639,10 @@ kshark_get_collection_entry_front(struct kshark_entry_request **req,
 	 * Loop over the list of redefined requests and search until you find
 	 * the first matching entry.
 	 */
-	while (*req) {
-		entry = kshark_get_entry_front(*req, data, index);
+	for (list = *req; list; list = list->next) {
+		entry = kshark_get_entry_front(list, data, index);
 		if (entry)
 			break;
-
-		*req = (*req)->next;
 	}
 
 	return entry;
@@ -680,6 +679,7 @@ kshark_get_collection_entry_back(struct kshark_entry_request **req,
 				 ssize_t *index)
 {
 	const struct kshark_entry *entry = NULL;
+	struct kshark_entry_request *list;
 	int req_count;
 
 	/*
@@ -695,12 +695,10 @@ kshark_get_collection_entry_back(struct kshark_entry_request **req,
 	 * Loop over the list of redefined requests and search until you find
 	 * the first matching entry.
 	 */
-	while (*req) {
-		entry = kshark_get_entry_back(*req, data, index);
+	for (list = *req; list; list = list->next) {
+		entry = kshark_get_entry_back(list, data, index);
 		if (entry)
 			break;
-
-		*req = (*req)->next;
 	}
 
 	return entry;
Signature · 1 line
2.20.1