SELinux on Android is unhappy if you try to read "/":

  avc: denied { read } for name="/" dev="dm-3" ino=2
scontext=u:r:hal_dumpstate_impl:s0 tcontext=u:object_r:rootfs:s0
tclass=dir permissive=0

O_PATH seems more intention-revealing anyway.
---
 lib/xwrap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
From 0f5ab54d0720eb82c542c47fc1371f0e6a8b38fe Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Tue, 26 Mar 2019 14:54:59 -0700
Subject: [PATCH] xabspath: use O_PATH.

SELinux on Android is unhappy if you try to read "/":

  avc: denied { read } for name="/" dev="dm-3" ino=2 scontext=u:r:hal_dumpstate_impl:s0 tcontext=u:object_r:rootfs:s0 tclass=dir permissive=0

O_PATH seems more intention-revealing anyway.
---
 lib/xwrap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/xwrap.c b/lib/xwrap.c
index a8214e57..2e2ccbc1 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -521,7 +521,7 @@ void xstat(char *path, struct stat *st)
 char *xabspath(char *path, int exact)
 {
   struct string_list *todo, *done = 0;
-  int try = 9999, dirfd = open("/", 0), missing = 0;
+  int try = 9999, dirfd = open("/", O_PATH), missing = 0;
   char *ret;
 
   // If this isn't an absolute path, start with cwd.
-- 
2.21.0.392.gf8f6787159e-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to