Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- src/ls.c 2012-10-23 18:14:12.000000000 +0400
- +++ src/ls.c.acl 2013-03-19 01:02:09.611176368 +0400
- @@ -49,6 +49,8 @@
- # include <sys/ptem.h>
- #endif
- +#include <sys/acl.h>
- +
- #include <stdio.h>
- #include <assert.h>
- #include <setjmp.h>
- @@ -182,7 +184,7 @@
- C_LINK, C_SOCK, C_FILE, C_DIR \
- }
- -enum acl_type
- +enum ls_acl_type
- {
- ACL_T_NONE,
- ACL_T_SELINUX_ONLY,
- @@ -216,7 +218,7 @@
- /* For long listings, true if the file has an access control list,
- or an SELinux security context. */
- - enum acl_type acl_type;
- + enum ls_acl_type ls_acl_type;
- /* For color listings, true if a regular file has capability info. */
- bool has_capability;
- @@ -268,6 +270,7 @@
- static int format_user_width (uid_t u);
- static int format_group_width (gid_t g);
- static void print_long_format (const struct fileinfo *f);
- +static void do_print_acl (const struct fileinfo *f);
- static void print_many_per_line (void);
- static size_t print_name_with_quoting (const struct fileinfo *f,
- bool symlink_target,
- @@ -351,6 +354,7 @@
- static struct timespec current_time;
- static bool print_scontext;
- +static bool print_acl;
- static char UNKNOWN_SECURITY_CONTEXT[] = "?";
- /* Whether any of the files has an ACL. This affects the width of the
- @@ -794,7 +798,8 @@
- SI_OPTION,
- SORT_OPTION,
- TIME_OPTION,
- - TIME_STYLE_OPTION
- + TIME_STYLE_OPTION,
- + ACL_OPTION,
- };
- static struct option const long_options[] =
- @@ -840,6 +845,7 @@
- {"color", optional_argument, NULL, COLOR_OPTION},
- {"block-size", required_argument, NULL, BLOCK_SIZE_OPTION},
- {"context", no_argument, 0, 'Z'},
- + {"acl", no_argument, 0, ACL_OPTION},
- {"author", no_argument, NULL, AUTHOR_OPTION},
- {GETOPT_HELP_OPTION_DECL},
- {GETOPT_VERSION_OPTION_DECL},
- @@ -1566,6 +1572,7 @@
- ignore_patterns = NULL;
- hide_patterns = NULL;
- print_scontext = false;
- + print_acl = false;
- /* FIXME: put this in a function. */
- {
- @@ -1944,6 +1951,11 @@
- print_scontext = true;
- break;
- + case ACL_OPTION:
- + print_acl = true;
- + format = long_format;
- + break;
- +
- case_GETOPT_HELP_CHAR;
- case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
- @@ -3023,12 +3035,12 @@
- have_acl = (0 < n);
- }
- - f->acl_type = (!have_selinux && !have_acl
- + f->ls_acl_type = (!have_selinux && !have_acl
- ? ACL_T_NONE
- : (have_selinux && !have_acl
- ? ACL_T_SELINUX_ONLY
- : ACL_T_YES));
- - any_has_acl |= f->acl_type != ACL_T_NONE;
- + any_has_acl |= f->ls_acl_type != ACL_T_NONE;
- if (err)
- error (0, errno, "%s", quotearg_colon (absolute_name));
- @@ -3753,6 +3765,19 @@
- : (char *) "?");
- }
- +/* Print ACL fo F. */
- +static void
- +do_print_acl (const struct fileinfo *f)
- +{
- + acl_t *aclp;
- + if (0 == acl_get(f->name, 0, &aclp) && NULL != aclp) {
- + putchar('\n');
- + acl_printacl(aclp, 80, 0);
- + acl_free(aclp);
- + }
- +
- +}
- +
- /* Print information about F in long format. */
- static void
- print_long_format (const struct fileinfo *f)
- @@ -3784,9 +3809,9 @@
- }
- if (! any_has_acl)
- modebuf[10] = '\0';
- - else if (f->acl_type == ACL_T_SELINUX_ONLY)
- + else if (f->ls_acl_type == ACL_T_SELINUX_ONLY)
- modebuf[10] = '.';
- - else if (f->acl_type == ACL_T_YES)
- + else if (f->ls_acl_type == ACL_T_YES)
- modebuf[10] = '+';
- switch (time_type)
- @@ -3972,6 +3997,9 @@
- }
- else if (indicator_style != none)
- print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
- +
- + if (f->filetype != symbolic_link && print_acl)
- + do_print_acl(f);
- }
- /* Output to OUT a quoted representation of the file name NAME,
Advertisement
Add Comment
Please, Sign In to add comment