Project

General

Profile

Feature #106 » dyson-acl-dirty.patch

Igor Pashev, 2015-07-04 05:55 PM

View differences:

coreutils/src/ls.c
49 49
# include <sys/ptem.h>
50 50
#endif
51 51

  
52
#include <sys/acl.h>
53

  
52 54
#include <stdio.h>
53 55
#include <assert.h>
54 56
#include <setjmp.h>
......
185 187
    C_LINK, C_SOCK, C_FILE, C_DIR			\
186 188
  }
187 189

  
188
enum acl_type
190
enum ls_acl_type
189 191
  {
190 192
    ACL_T_NONE,
191 193
    ACL_T_LSM_CONTEXT_ONLY,
......
219 221

  
220 222
    /* For long listings, true if the file has an access control list,
221 223
       or a security context.  */
222
    enum acl_type acl_type;
224
    enum ls_acl_type ls_acl_type;
223 225

  
224 226
    /* For color listings, true if a regular file has capability info.  */
225 227
    bool has_capability;
......
271 273
static int format_user_width (uid_t u);
272 274
static int format_group_width (gid_t g);
273 275
static void print_long_format (const struct fileinfo *f);
276
static void do_print_acl (const struct fileinfo *f);
274 277
static void print_many_per_line (void);
275 278
static size_t print_name_with_quoting (const struct fileinfo *f,
276 279
                                       bool symlink_target,
......
356 359
static struct timespec current_time;
357 360

  
358 361
static bool print_scontext;
362
static bool print_acl;
359 363
static char UNKNOWN_SECURITY_CONTEXT[] = "?";
360 364

  
361 365
/* Whether any of the files has an ACL.  This affects the width of the
......
799 803
  SI_OPTION,
800 804
  SORT_OPTION,
801 805
  TIME_OPTION,
802
  TIME_STYLE_OPTION
806
  TIME_STYLE_OPTION,
807
  ACL_OPTION,
803 808
};
804 809

  
805 810
static struct option const long_options[] =
......
845 850
  {"color", optional_argument, NULL, COLOR_OPTION},
846 851
  {"block-size", required_argument, NULL, BLOCK_SIZE_OPTION},
847 852
  {"context", no_argument, 0, 'Z'},
853
  {"acl", no_argument, 0, ACL_OPTION},
848 854
  {"author", no_argument, NULL, AUTHOR_OPTION},
849 855
  {GETOPT_HELP_OPTION_DECL},
850 856
  {GETOPT_VERSION_OPTION_DECL},
......
1579 1585
  ignore_patterns = NULL;
1580 1586
  hide_patterns = NULL;
1581 1587
  print_scontext = false;
1588
  print_acl = false;
1582 1589

  
1583 1590
  getenv_quoting_style ();
1584 1591

  
......
1932 1939
          print_scontext = true;
1933 1940
          break;
1934 1941

  
1942
        case ACL_OPTION:
1943
          print_acl = true;
1944
          format = long_format;
1945
          break;
1946

  
1935 1947
        case_GETOPT_HELP_CHAR;
1936 1948

  
1937 1949
        case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
......
3076 3088
              have_acl = (0 < n);
3077 3089
            }
3078 3090

  
3079
          f->acl_type = (!have_scontext && !have_acl
3091
          f->ls_acl_type = (!have_scontext && !have_acl
3080 3092
                         ? ACL_T_NONE
3081 3093
                         : (have_scontext && !have_acl
3082 3094
                            ? ACL_T_LSM_CONTEXT_ONLY
3083 3095
                            : ACL_T_YES));
3084
          any_has_acl |= f->acl_type != ACL_T_NONE;
3096
          any_has_acl |= f->ls_acl_type != ACL_T_NONE;
3085 3097

  
3086 3098
          if (err)
3087 3099
            error (0, errno, "%s", quotearg_colon (absolute_name));
......
3807 3819
          : (char *) "?");
3808 3820
}
3809 3821

  
3822
/* Print ACL for F.  */
3823
static void
3824
do_print_acl (const struct fileinfo *f)
3825
{
3826
    acl_t *aclp;
3827
    if (0 == acl_get(f->name, 0, &aclp) && NULL != aclp) {
3828
        putchar('\n');
3829
        acl_printacl(aclp, 80, 0);
3830
        acl_free(aclp);
3831
    }
3832

  
3833
}
3834

  
3810 3835
/* Print information about F in long format.  */
3811 3836
static void
3812 3837
print_long_format (const struct fileinfo *f)
......
3838 3863
    }
3839 3864
  if (! any_has_acl)
3840 3865
    modebuf[10] = '\0';
3841
  else if (f->acl_type == ACL_T_LSM_CONTEXT_ONLY)
3866
  else if (f->ls_acl_type == ACL_T_LSM_CONTEXT_ONLY)
3842 3867
    modebuf[10] = '.';
3843
  else if (f->acl_type == ACL_T_YES)
3868
  else if (f->ls_acl_type == ACL_T_YES)
3844 3869
    modebuf[10] = '+';
3845 3870

  
3846 3871
  switch (time_type)
......
4026 4051
    }
4027 4052
  else if (indicator_style != none)
4028 4053
    print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
4054

  
4055
  if (f->filetype != symbolic_link && print_acl)
4056
      do_print_acl(f);
4029 4057
}
4030 4058

  
4031 4059
/* Output to OUT a quoted representation of the file name NAME,
    (1-1/1)