Index: bin/ls/ls.1 =================================================================== RCS file: /home/ncvs/src/bin/ls/ls.1,v retrieving revision 1.70 diff -u -r1.70 ls.1 --- bin/ls/ls.1 24 Oct 2002 00:07:30 -0000 1.70 +++ bin/ls/ls.1 1 Nov 2002 16:43:00 -0000 @@ -417,6 +417,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 @@ -625,6 +628,7 @@ .Xr chmod 1 , .Xr sort 1 , .Xr xterm 1 , +.Xr acl 3 , .Xr termcap 5 , .Xr symlink 7 , .Xr sticky 8 Index: bin/ls/print.c =================================================================== RCS file: /home/ncvs/src/bin/ls/print.c,v retrieving revision 1.61 diff -u -r1.61 print.c --- bin/ls/print.c 24 Oct 2002 00:07:30 -0000 1.61 +++ bin/ls/print.c 1 Nov 2002 16:43:00 -0000 @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -64,6 +65,7 @@ #include "ls.h" #include "extern.h" +static int count_acl(FTSENT *); static int printaname(FTSENT *, u_long, u_long); static void printlink(const FTSENT *); static void printtime(time_t); @@ -176,6 +178,12 @@ (void)printf("%*lld ", dp->s_block, howmany(sp->st_blocks, blocksize)); strmode(sp->st_mode, buf); + /* + * 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] = '+'; 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, @@ -331,6 +339,44 @@ } (void)putchar('\n'); } +} + +/* + * return the number of acl entries + */ +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); } /*