summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/shadow/files/commonio.c-fix-unexpected-open-failure-in-chroot-env.patch
blob: 4fa3d184edf73f4d7811e6762d0de11ddf4d83dd (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
Upstream-Status: Inappropriate [OE specific]

commonio.c: fix unexpected open failure in chroot environment

When using commands with '-R <newroot>' option in our pseudo environment,
we would usually get the 'Pemission Denied' error. This patch serves as
a workaround to this problem.

Note that this patch doesn't change the logic in the code, it just expands
the codes.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 lib/commonio.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/commonio.c b/lib/commonio.c
index cc536bf..51cafd9 100644
--- a/lib/commonio.c
+++ b/lib/commonio.c
@@ -613,10 +613,18 @@ int commonio_open (struct commonio_db *db, int mode)
 	db->cursor = NULL;
 	db->changed = false;
 
-	fd = open (db->filename,
-	             (db->readonly ? O_RDONLY : O_RDWR)
-	           | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
-	saved_errno = errno;
+	if (db->readonly) {
+		fd = open (db->filename,
+			   (true ? O_RDONLY : O_RDWR)
+			   | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
+		saved_errno = errno;
+	} else {
+		fd = open (db->filename,
+			   (false ? O_RDONLY : O_RDWR)
+			   | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
+		saved_errno = errno;
+	}
+
 	db->fp = NULL;
 	if (fd >= 0) {
 #ifdef WITH_TCB
-- 
1.7.9.5