diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-08-09 11:42:13 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-08-09 11:42:13 -0400 |
commit | 069e3725dd9be3b759a98e8c80ac5fc38b392b23 (patch) | |
tree | 0696e18fcf5eb6f2908876b1a09647c82af5b31a /tools/perf/util/config.c | |
parent | 9941c96ad869d10f7e34e03990ce450ab8fcb83d (diff) |
perf tools: Check $HOME/.perfconfig ownership
Just like we do already for perf.data files.
Requested-by: Ingo Molnar <mingo@elte.hu>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Christian Ohm <chr.ohm@gmx.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-qgokmxsmvppwpc5404qhyk7e@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/config.c')
-rw-r--r-- | tools/perf/util/config.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 6c86eca8b1b7..fe02903f7d0f 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c | |||
@@ -413,13 +413,32 @@ int perf_config(config_fn_t fn, void *data) | |||
413 | home = getenv("HOME"); | 413 | home = getenv("HOME"); |
414 | if (perf_config_global() && home) { | 414 | if (perf_config_global() && home) { |
415 | char *user_config = strdup(mkpath("%s/.perfconfig", home)); | 415 | char *user_config = strdup(mkpath("%s/.perfconfig", home)); |
416 | if (!access(user_config, R_OK)) { | 416 | struct stat st; |
417 | ret += perf_config_from_file(fn, user_config, data); | 417 | |
418 | found += 1; | 418 | if (user_config == NULL) { |
419 | warning("Not enough memory to process %s/.perfconfig, " | ||
420 | "ignoring it.", home); | ||
421 | goto out; | ||
422 | } | ||
423 | |||
424 | if (stat(user_config, &st) < 0) | ||
425 | goto out_free; | ||
426 | |||
427 | if (st.st_uid && (st.st_uid != geteuid())) { | ||
428 | warning("File %s not owned by current user or root, " | ||
429 | "ignoring it.", user_config); | ||
430 | goto out_free; | ||
419 | } | 431 | } |
432 | |||
433 | if (!st.st_size) | ||
434 | goto out_free; | ||
435 | |||
436 | ret += perf_config_from_file(fn, user_config, data); | ||
437 | found += 1; | ||
438 | out_free: | ||
420 | free(user_config); | 439 | free(user_config); |
421 | } | 440 | } |
422 | 441 | out: | |
423 | if (found == 0) | 442 | if (found == 0) |
424 | return -1; | 443 | return -1; |
425 | return ret; | 444 | return ret; |