[Toybox] [PATCH] ls: add flag-Z Smack support.
Rob Landley
rob at landley.net
Wed Feb 10 15:28:20 PST 2016
On 02/08/2016 06:45 PM, Alejandro Joya wrote:
> 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);
> + }
new->name is relative to the openat() dirfd. Try ls -ZR and see if you
get -Z in subdirectories? (That's what the hack was about, see the
comment in the first hunk...)
Rob
1455146900.0
More information about the Toybox
mailing list