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 v2 3/3] kernel-shark: When running as Root save all config settings in /root/
Date: Wed, 23 Oct 2019 15:21:45 +0300 [thread overview]
Message-ID: <20191023122145.14314-3-y.karadz@gmail.com> (raw)
In-Reply-To: <20191023122145.14314-1-y.karadz@gmail.com>
If KernelShark is running with Root privileges, do not save the settings
in the standard location. Otherwise the configuration files will be owned
by Root and later the normal user will have no access to those files.
The patch seems to do the right thing in all cases that I tested, however
there is definitely something that I do not understand. QDir::homePath()
always returns the path to the home of the normal user, even if I build
and run kernelshark as root (sudo -s).
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
kernel-shark/src/KsMainWindow.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 3402764..bd6c338 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -69,7 +69,7 @@ KsMainWindow::KsMainWindow(QWidget *parent)
_contentsAction("Contents", this),
_bugReportAction("Report a bug", this),
_deselectShortcut(this),
- _settings("kernelshark.org", "Kernel Shark") // organization , application
+ _settings(_getCacheDir() + "/setting.ini", QSettings::IniFormat)
{
setWindowTitle("Kernel Shark");
_createActions();
@@ -431,6 +431,9 @@ QString KsMainWindow::_getCacheDir()
dir = QStandardPaths::writableLocation(appCachePath);
dir += "/kernelshark";
+ if (geteuid() == 0)
+ dir.replace(QDir::homePath(), "/root");
+
if (!QDir(dir).exists())
lamMakePath(false);
}
--
2.20.1
next prev parent reply other threads:[~2019-10-23 12:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-23 12:21 [PATCH v2 1/3] kernel-shark: Fix simple typo in the "File" menu Yordan Karadzhov (VMware)
2019-10-23 12:21 ` [PATCH v2 2/3] kernel-shark: Fix potential memory leak in libkshark-collection Yordan Karadzhov (VMware)
2019-11-27 18:54 ` Steven Rostedt
2019-11-28 9:25 ` Yordan Karadzhov (VMware)
2019-10-23 12:21 ` Yordan Karadzhov (VMware) [this message]
2019-11-27 20:13 ` [PATCH v2 3/3] kernel-shark: When running as Root save all config settings in /root/ Steven Rostedt
2019-11-28 11:29 ` 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=20191023122145.14314-3-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).