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