On 03/26/2013 09:30 AM, Jakub Filak wrote:
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/dbus/abrt-dbus.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/dbus/abrt-dbus.c b/src/dbus/abrt-dbus.c
index e3be4ce..9d7f1ff 100644
--- a/src/dbus/abrt-dbus.c
+++ b/src/dbus/abrt-dbus.c
@@ -523,7 +523,7 @@ static void handle_method_call(GDBusConnection *connection,
return;
}
- if (errno == ENOENT)
+ if (errno == ENOTDIR)
{
VERB1 log("Requested directory does not exist '%s'",
problem_dir);
return_InvalidProblemDir_error(invocation, problem_dir);
@@ -575,7 +575,7 @@ static void handle_method_call(GDBusConnection *connection,
if (!dump_dir_accessible_by_uid(problem_dir, caller_uid))
{
- if (errno == ENOENT)
+ if (errno == ENOTDIR)
{
VERB1 log("Requested directory does not exist '%s'",
problem_dir);
return_InvalidProblemDir_error(invocation, problem_dir);
@@ -755,7 +755,7 @@ static void handle_method_call(GDBusConnection *connection,
const char *dir_name = (const char*)l->data;
if (!dump_dir_accessible_by_uid(dir_name, caller_uid))
{
- if (errno == ENOENT)
+ if (errno == ENOTDIR)
{
VERB1 log("Requested directory does not exist
'%s'", dir_name);
continue;
We have a problem here.
Imagine that two "DeleteProblem" calls come one after another:
First one tries to delete nonexistent dir,
errno gets set to ENOTDIR, we emit correct message, all is good.
The second one tries to delete an existing directory,
but one which is inaccessible to the caller's UID.
What will dump_dir_accessible_by_uid() do to errno?
int dump_dir_accessible_by_uid(const char *dirname, uid_t uid)
{
struct stat statbuf;
if (stat(dirname, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))
errno = ENOTDIR;
else
{
#if DUMP_DIR_OWNED_BY_USER > 0
if (uid == 0 || (statbuf.st_mode & S_IROTH) || uid == statbuf.st_uid)
#else
if (uid == 0 || (statbuf.st_mode & S_IROTH) || uid_in_group(uid,
statbuf.st_gid))
#endif
{
VERB1 log("directory '%s' is accessible by %ld uid",
dirname, (long)uid);
return 1;
}
}
return 0;
}
*Nothing*!
It will return 0 ("not accessible") but errno will retain its current value!
And then this code in abrt_dbus.c
if (!dump_dir_accessible_by_uid(dir_name, caller_uid))
{
if (errno == ENOTDIR)
{
VERB1 log("Requested directory does not exist '%s'",
dir_name);
continue;
}
will erroneously conclude that directory doesn't exist.
--
vda