[Toybox] [PATCH] ls: add flag-Z Smack support.

Alejandro Joya alejandro.joya.cruz at intel.com
Mon Feb 8 16:45:18 PST 2016


The current state only print question mark for all the cases, this would
let in case of LSM Smack to show the labels.

Signed-off-by: Alejandro Joya <alejandro.joya.cruz at intel.com>
---
 toys/posix/ls.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 08ae695..982bc9f 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -187,7 +187,6 @@ static int filter(struct dirtree *new)
 
   if (flags & FLAG_Z) {
     if (!CFG_TOYBOX_LSM_NONE) {
-
       // (Wouldn't it be nice if the lsm functions worked like openat(),
       // fchmodat(), mknodat(), readlinkat() so we could do this without
       // even O_PATH? But no, this is 1990's tech.)
@@ -207,6 +206,9 @@ static int filter(struct dirtree *new)
 
           sprintf(hack, "/proc/self/fd/%d", fd);
           lsm_lget_context(hack, (char **)&new->extra);
+          if(CFG_TOYBOX_SMACK){
+            lsm_lget_context(new->name, (char **)&new->extra);
+          }
         }
         close(fd);
       }
-- 
1.9.1


 1454978718.0


More information about the Toybox mailing list