|
|
47a88a |
From 5e288cf2d54f6b3e67745f71db836f37901d2ad5 Mon Sep 17 00:00:00 2001
|
|
|
47a88a |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
47a88a |
Date: Wed, 3 Jun 2015 05:40:41 +0200
|
|
|
47a88a |
Subject: [PATCH] cli: chown before reporting
|
|
|
47a88a |
|
|
|
47a88a |
User must have write access to the reported directory to be able to
|
|
|
47a88a |
report it but abrt-dbus allows the user to read data of problems that
|
|
|
47a88a |
belongs to him which may not be accessible in file system.
|
|
|
47a88a |
|
|
|
47a88a |
The GUI does the same and make sures the user can write to the reported
|
|
|
47a88a |
directory by chowning it before reporting.
|
|
|
47a88a |
|
|
|
47a88a |
Related: #1224984
|
|
|
47a88a |
|
|
|
47a88a |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
47a88a |
---
|
|
|
47a88a |
src/cli/abrt-cli-core.c | 5 +++++
|
|
|
47a88a |
src/cli/abrt-cli-core.h | 3 +++
|
|
|
47a88a |
src/cli/report.c | 24 +++++++++++++++---------
|
|
|
47a88a |
3 files changed, 23 insertions(+), 9 deletions(-)
|
|
|
47a88a |
|
|
|
47a88a |
diff --git a/src/cli/abrt-cli-core.c b/src/cli/abrt-cli-core.c
|
|
|
47a88a |
index 77a37f7..46acd01 100644
|
|
|
47a88a |
--- a/src/cli/abrt-cli-core.c
|
|
|
47a88a |
+++ b/src/cli/abrt-cli-core.c
|
|
|
47a88a |
@@ -107,3 +107,8 @@ char *hash2dirname(const char *hash)
|
|
|
47a88a |
|
|
|
47a88a |
return found_name;
|
|
|
47a88a |
}
|
|
|
47a88a |
+
|
|
|
47a88a |
+char *hash2dirname_if_necessary(const char *input)
|
|
|
47a88a |
+{
|
|
|
47a88a |
+ return isxdigit_str(input) ? hash2dirname(input) : xstrdup(input);
|
|
|
47a88a |
+}
|
|
|
47a88a |
diff --git a/src/cli/abrt-cli-core.h b/src/cli/abrt-cli-core.h
|
|
|
47a88a |
index 33b2ea6..d69d463 100644
|
|
|
47a88a |
--- a/src/cli/abrt-cli-core.h
|
|
|
47a88a |
+++ b/src/cli/abrt-cli-core.h
|
|
|
47a88a |
@@ -34,6 +34,9 @@ vector_of_problem_data_t *fetch_crash_infos(void);
|
|
|
47a88a |
char *find_problem_by_hash(const char *hash, GList *problems);
|
|
|
47a88a |
/* Returns malloced string, or NULL if not found: */
|
|
|
47a88a |
char *hash2dirname(const char *hash);
|
|
|
47a88a |
+/* If input looks like a hash, returns malloced string, or NULL if not found.
|
|
|
47a88a |
+ * Otherwise returns a copy of the input. */
|
|
|
47a88a |
+char *hash2dirname_if_necessary(const char *input);
|
|
|
47a88a |
|
|
|
47a88a |
|
|
|
47a88a |
#endif /* ABRT_CLI_CORE_H_ */
|
|
|
47a88a |
diff --git a/src/cli/report.c b/src/cli/report.c
|
|
|
47a88a |
index 33d8b44..6af9769 100644
|
|
|
47a88a |
--- a/src/cli/report.c
|
|
|
47a88a |
+++ b/src/cli/report.c
|
|
|
47a88a |
@@ -53,26 +53,32 @@ int cmd_report(int argc, const char **argv)
|
|
|
47a88a |
while (*argv)
|
|
|
47a88a |
{
|
|
|
47a88a |
const char *dir_name = *argv++;
|
|
|
47a88a |
+ char *const real_problem_id = hash2dirname_if_necessary(dir_name);
|
|
|
47a88a |
+ if (real_problem_id == NULL)
|
|
|
47a88a |
+ {
|
|
|
47a88a |
+ error_msg(_("Can't find problem '%s'"), dir_name);
|
|
|
47a88a |
+ continue;
|
|
|
47a88a |
+ }
|
|
|
47a88a |
|
|
|
47a88a |
- char *free_me = NULL;
|
|
|
47a88a |
- if (access(dir_name, F_OK) != 0 && errno == ENOENT)
|
|
|
47a88a |
+ const int res = chown_dir_over_dbus(real_problem_id);
|
|
|
47a88a |
+ if (res != 0)
|
|
|
47a88a |
{
|
|
|
47a88a |
- free_me = hash2dirname(dir_name);
|
|
|
47a88a |
- if (free_me)
|
|
|
47a88a |
- dir_name = free_me;
|
|
|
47a88a |
+ error_msg(_("Can't take ownership of '%s'"), real_problem_id);
|
|
|
47a88a |
+ free(real_problem_id);
|
|
|
47a88a |
+ continue;
|
|
|
47a88a |
}
|
|
|
47a88a |
- int status = report_problem_in_dir(dir_name,
|
|
|
47a88a |
+ int status = report_problem_in_dir(real_problem_id,
|
|
|
47a88a |
LIBREPORT_WAIT
|
|
|
47a88a |
| LIBREPORT_RUN_CLI);
|
|
|
47a88a |
|
|
|
47a88a |
/* the problem was successfully reported and option is -d */
|
|
|
47a88a |
if((opts & OPT_d) && (status == 0 || status == EXIT_STOP_EVENT_RUN))
|
|
|
47a88a |
{
|
|
|
47a88a |
- log(_("Deleting '%s'"), dir_name);
|
|
|
47a88a |
- delete_dump_dir_possibly_using_abrtd(dir_name);
|
|
|
47a88a |
+ log(_("Deleting '%s'"), real_problem_id);
|
|
|
47a88a |
+ delete_dump_dir_possibly_using_abrtd(real_problem_id);
|
|
|
47a88a |
}
|
|
|
47a88a |
|
|
|
47a88a |
- free(free_me);
|
|
|
47a88a |
+ free(real_problem_id);
|
|
|
47a88a |
|
|
|
47a88a |
if (status)
|
|
|
47a88a |
exit(status);
|
|
|
47a88a |
--
|
|
|
47a88a |
2.4.3
|
|
|
47a88a |
|