diff options
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; |