summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/config.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-08-20 10:39:12 -0700
committerDavid S. Miller <davem@davemloft.net>2011-08-20 10:39:12 -0700
commit823dcd2506fa369aeb8cbd26da5663efe2fda9a9 (patch)
tree853b3e3c05f0b9ee1b5df8464db19b7acc57150c /tools/perf/util/config.c
parenteaa36660de7e174498618d69d7277d44a2f24c3d (diff)
parent98e77438aed3cd3343cbb86825127b1d9d2bea33 (diff)
downloadblackbird-op-linux-823dcd2506fa369aeb8cbd26da5663efe2fda9a9.tar.gz
blackbird-op-linux-823dcd2506fa369aeb8cbd26da5663efe2fda9a9.zip
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'tools/perf/util/config.c')
-rw-r--r--tools/perf/util/config.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index e02d78cae70f..fe02903f7d0f 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -399,7 +399,6 @@ static int perf_config_global(void)
int perf_config(config_fn_t fn, void *data)
{
int ret = 0, found = 0;
- char *repo_config = NULL;
const char *home = NULL;
/* Setting $PERF_CONFIG makes perf read _only_ the given config file. */
@@ -414,19 +413,32 @@ int perf_config(config_fn_t fn, void *data)
home = getenv("HOME");
if (perf_config_global() && home) {
char *user_config = strdup(mkpath("%s/.perfconfig", home));
- if (!access(user_config, R_OK)) {
- ret += perf_config_from_file(fn, user_config, data);
- found += 1;
+ struct stat st;
+
+ if (user_config == NULL) {
+ warning("Not enough memory to process %s/.perfconfig, "
+ "ignoring it.", home);
+ goto out;
}
- free(user_config);
- }
- repo_config = perf_pathdup("config");
- if (!access(repo_config, R_OK)) {
- ret += perf_config_from_file(fn, repo_config, data);
+ if (stat(user_config, &st) < 0)
+ goto out_free;
+
+ if (st.st_uid && (st.st_uid != geteuid())) {
+ warning("File %s not owned by current user or root, "
+ "ignoring it.", user_config);
+ goto out_free;
+ }
+
+ if (!st.st_size)
+ goto out_free;
+
+ ret += perf_config_from_file(fn, user_config, data);
found += 1;
+out_free:
+ free(user_config);
}
- free(repo_config);
+out:
if (found == 0)
return -1;
return ret;
OpenPOWER on IntegriCloud