Index: bin/ls/Makefile =================================================================== RCS file: /home/ncvs/src/bin/ls/Makefile,v retrieving revision 1.23 diff -u -r1.23 Makefile --- bin/ls/Makefile 4 Feb 2002 03:06:50 -0000 1.23 +++ bin/ls/Makefile 19 Feb 2002 19:37:20 -0000 @@ -9,7 +9,7 @@ LDADD= -lm .if !defined(RELEASE_CRUNCH) -CFLAGS+= -DCOLORLS +CFLAGS+= -DCOLORLS -DWANT_ACL DPADD+= ${LIBTERMCAP} LDADD+= -ltermcap .endif Index: bin/ls/ls.1 =================================================================== RCS file: /home/ncvs/src/bin/ls/ls.1,v retrieving revision 1.62 diff -u -r1.62 ls.1 --- bin/ls/ls.1 9 Jan 2002 13:29:39 -0000 1.62 +++ bin/ls/ls.1 19 Feb 2002 19:37:20 -0000 @@ -400,6 +400,9 @@ .Xr sticky 8 . ) .El .El +.Pp +If the file has any extended ACLs set, the last field will contain a +.Sy \+ . .Sh EXAMPLES The following is how to do an .Nm @@ -611,6 +614,7 @@ .Xr chmod 1 , .Xr sort 1 , .Xr xterm 1 , +.Xr acl 3 , .Xr lomac 4 , .Xr termcap 5 , .Xr symlink 7 , Index: bin/ls/print.c =================================================================== RCS file: /home/ncvs/src/bin/ls/print.c,v retrieving revision 1.52 diff -u -r1.52 print.c --- bin/ls/print.c 3 Feb 2002 20:55:54 -0000 1.52 +++ bin/ls/print.c 19 Feb 2002 19:37:20 -0000 @@ -46,6 +46,9 @@ #include #include +#ifdef WANT_ACL +#include +#endif #include #include @@ -67,6 +70,9 @@ #include "ls.h" #include "extern.h" +#ifdef WANT_ACL +static int count_acl (FTSENT *); +#endif static int printaname(FTSENT *, u_long, u_long); static void printlink(FTSENT *); static void printtime(time_t); @@ -155,6 +161,46 @@ return printf("%s", name); } +/* + * return the number of acl entries + */ +#ifdef WANT_ACL +static int +count_acl(p) + FTSENT *p; +{ + acl_entry_t entry; + acl_t acl; + char *file; + int count, entry_id; + + if (p->fts_level > 0) + asprintf(&file, "%s/%s", p->fts_path, p->fts_name); + else + asprintf(&file, "%s", p->fts_name); + if (file == NULL) + err(1, "asprintf"); + acl = acl_get_file(file, ACL_TYPE_ACCESS); + if (acl == NULL) { + if (errno != EOPNOTSUPP) + warn("acl_get_file: %s", file); + free(file); + return (0); + } + free(file); + + count = 0; + entry_id = ACL_FIRST_ENTRY; + while (acl_get_entry(acl, entry_id, &entry) == 1) { + entry_id = ACL_NEXT_ENTRY; + count++; + } + acl_free(acl); + + return (count); +} +#endif + void printlong(DISPLAY *dp) { @@ -179,6 +225,14 @@ (void)printf("%*lld ", dp->s_block, howmany(sp->st_blocks, blocksize)); strmode(sp->st_mode, buf); +#ifdef WANT_ACL + /* + * manually determine and indicate if a file has extended + * ACLs set until stat(2)/strmode(3) contain proper support + */ + if (count_acl(p) > 3) + buf[strlen(buf) - 1] = '+'; +#endif np = p->fts_pointer; (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink, sp->st_nlink, dp->s_user, np->user, dp->s_group,