[2/3] kernel-shark: Do not save the settings when running as Root
diff mbox series

Message ID 20191018074722.6976-2-y.karadz@gmail.com
State New
Headers show
Series
  • [1/3] kernel-shark: Fix simple typo in the "File" menu.
Related show

Commit Message

Yordan Karadzhov (VMware) Oct. 18, 2019, 7:47 a.m. UTC
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(-)

Comments

Steven Rostedt Oct. 18, 2019, 2:32 p.m. UTC | #1
On Fri, 18 Oct 2019 10:47:21 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> 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?

-- Steve

> 
> 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();
>
Yordan Karadzhov (VMware) Oct. 23, 2019, 10:49 a.m. UTC | #2
On 18.10.19 г. 17:32 ч., Steven Rostedt wrote:
> On Fri, 18 Oct 2019 10:47:21 +0300
> "Yordan Karadzhov (VMware)" <y.karadz@gmail.com> 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@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();
>>   
>
Steven Rostedt Oct. 23, 2019, 11:59 a.m. UTC | #3
On Wed, 23 Oct 2019 13:49:25 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> 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

Patch
diff mbox series

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();