summaryrefslogtreecommitdiff
path: root/meta-openembedded/meta-oe/recipes-core/dbus/dbus-broker/0001-launch-improve-error-handling-for-opendir.patch
blob: ccc175bb804762f465e52b1148a23324f470a758 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From f42d5e38859c65a186acd0da94bbeeca12faf7a2 Mon Sep 17 00:00:00 2001
From: David Rheinsberg <david.rheinsberg@gmail.com>
Date: Thu, 2 May 2019 17:33:34 +0200
Subject: [PATCH] launch: improve error handling for opendir()

This improves the error-handling of opendir() by always printing
diagnostics. Furthermore, it aligns the behavior with dbus-deamon and
ignores EACCES.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
Upstream-Status: dbus-broker@f42d5e38859c65a186acd0da94bbeeca12faf7a2
---
 src/launch/launcher.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/launch/launcher.c b/src/launch/launcher.c
index 31a5364..2ec4bda 100644
--- a/src/launch/launcher.c
+++ b/src/launch/launcher.c
@@ -749,10 +749,23 @@ static int launcher_load_service_dir(Launcher *launcher, const char *dirpath, NS
 
         dir = opendir(dirpath);
         if (!dir) {
-                if (errno == ENOENT || errno == ENOTDIR)
+                if (errno == ENOENT || errno == ENOTDIR) {
                         return 0;
-                else
+                } else if (errno == EACCES) {
+                        log_append_here(&launcher->log, LOG_ERR, 0, NULL);
+                        r = log_commitf(&launcher->log, "Access denied to service directory '%s'\n", dirpath);
+                        if (r)
+                                return error_fold(r);
+
+                        return 0;
+                } else {
+                        log_append_here(&launcher->log, LOG_ERR, errno, NULL);
+                        r = log_commitf(&launcher->log, "Unable to open service directory '%s': %m\n", dirpath);
+                        if (r)
+                                return error_fold(r);
+
                         return error_origin(-errno);
+                }
         }
 
         r = dirwatch_add(launcher->dirwatch, dirpath);
-- 
2.20.1