Feature #106 » dyson-acl-dirty.patch
| coreutils/src/ls.c | ||
|---|---|---|
|
# include <sys/ptem.h>
|
||
|
#endif
|
||
|
#include <sys/acl.h>
|
||
|
#include <stdio.h>
|
||
|
#include <assert.h>
|
||
|
#include <setjmp.h>
|
||
| ... | ... | |
|
C_LINK, C_SOCK, C_FILE, C_DIR \
|
||
|
}
|
||
|
enum acl_type
|
||
|
enum ls_acl_type
|
||
|
{
|
||
|
ACL_T_NONE,
|
||
|
ACL_T_LSM_CONTEXT_ONLY,
|
||
| ... | ... | |
|
/* For long listings, true if the file has an access control list,
|
||
|
or a 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;
|
||
| ... | ... | |
|
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,
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
SI_OPTION,
|
||
|
SORT_OPTION,
|
||
|
TIME_OPTION,
|
||
|
TIME_STYLE_OPTION
|
||
|
TIME_STYLE_OPTION,
|
||
|
ACL_OPTION,
|
||
|
};
|
||
|
static struct option const long_options[] =
|
||
| ... | ... | |
|
{"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},
|
||
| ... | ... | |
|
ignore_patterns = NULL;
|
||
|
hide_patterns = NULL;
|
||
|
print_scontext = false;
|
||
|
print_acl = false;
|
||
|
getenv_quoting_style ();
|
||
| ... | ... | |
|
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);
|
||
| ... | ... | |
|
have_acl = (0 < n);
|
||
|
}
|
||
|
f->acl_type = (!have_scontext && !have_acl
|
||
|
f->ls_acl_type = (!have_scontext && !have_acl
|
||
|
? ACL_T_NONE
|
||
|
: (have_scontext && !have_acl
|
||
|
? ACL_T_LSM_CONTEXT_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));
|
||
| ... | ... | |
|
: (char *) "?");
|
||
|
}
|
||
|
/* Print ACL for 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)
|
||
| ... | ... | |
|
}
|
||
|
if (! any_has_acl)
|
||
|
modebuf[10] = '\0';
|
||
|
else if (f->acl_type == ACL_T_LSM_CONTEXT_ONLY)
|
||
|
else if (f->ls_acl_type == ACL_T_LSM_CONTEXT_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)
|
||
| ... | ... | |
|
}
|
||
|
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,
|
||