Add "-q" argument to getfacl(1), which suppresses the per-file header
comment listing the file name, owner, and group. MFC after: 1 week Submitted by: Jan Srzednicki <w at expro dot pl>
This commit is contained in:
parent
28e989e9ca
commit
f9a86e379c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=156681
@ -38,7 +38,7 @@
|
|||||||
.Nd get ACL information
|
.Nd get ACL information
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl dh
|
.Op Fl dhq
|
||||||
.Op Ar
|
.Op Ar
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
@ -64,6 +64,9 @@ An error is generated if a default ACL cannot be associated with
|
|||||||
.It Fl h
|
.It Fl h
|
||||||
If the target of the operation is a symbolic link, return the ACL from
|
If the target of the operation is a symbolic link, return the ACL from
|
||||||
the symbolic link itself rather than following the link.
|
the symbolic link itself rather than following the link.
|
||||||
|
.It Fl q
|
||||||
|
Don't write commented information about file name and ownership. This is
|
||||||
|
useful when dealing with filenames with unprintable characters.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The following operand is available:
|
The following operand is available:
|
||||||
|
@ -52,7 +52,7 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr, "getfacl [-dh] [file ...]\n");
|
fprintf(stderr, "getfacl [-dhq] [file ...]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -147,7 +147,7 @@ acl_from_stat(struct stat sb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
print_acl(char *path, acl_type_t type, int hflag)
|
print_acl(char *path, acl_type_t type, int hflag, int qflag)
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
acl_t acl;
|
acl_t acl;
|
||||||
@ -168,7 +168,9 @@ print_acl(char *path, acl_type_t type, int hflag)
|
|||||||
else
|
else
|
||||||
more_than_one++;
|
more_than_one++;
|
||||||
|
|
||||||
printf("#file:%s\n#owner:%d\n#group:%d\n", path, sb.st_uid, sb.st_gid);
|
if (!qflag)
|
||||||
|
printf("#file:%s\n#owner:%d\n#group:%d\n", path, sb.st_uid,
|
||||||
|
sb.st_gid);
|
||||||
|
|
||||||
if (hflag)
|
if (hflag)
|
||||||
acl = acl_get_link_np(path, type);
|
acl = acl_get_link_np(path, type);
|
||||||
@ -204,7 +206,7 @@ print_acl(char *path, acl_type_t type, int hflag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
print_acl_from_stdin(acl_type_t type, int hflag)
|
print_acl_from_stdin(acl_type_t type, int hflag, int qflag)
|
||||||
{
|
{
|
||||||
char *p, pathname[PATH_MAX];
|
char *p, pathname[PATH_MAX];
|
||||||
int carried_error = 0;
|
int carried_error = 0;
|
||||||
@ -212,7 +214,7 @@ print_acl_from_stdin(acl_type_t type, int hflag)
|
|||||||
while (fgets(pathname, (int)sizeof(pathname), stdin)) {
|
while (fgets(pathname, (int)sizeof(pathname), stdin)) {
|
||||||
if ((p = strchr(pathname, '\n')) != NULL)
|
if ((p = strchr(pathname, '\n')) != NULL)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if (print_acl(pathname, type, hflag) == -1) {
|
if (print_acl(pathname, type, hflag, qflag) == -1) {
|
||||||
carried_error = -1;
|
carried_error = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,10 +228,11 @@ main(int argc, char *argv[])
|
|||||||
acl_type_t type = ACL_TYPE_ACCESS;
|
acl_type_t type = ACL_TYPE_ACCESS;
|
||||||
int carried_error = 0;
|
int carried_error = 0;
|
||||||
int ch, error, i;
|
int ch, error, i;
|
||||||
int hflag;
|
int hflag, qflag;
|
||||||
|
|
||||||
hflag = 0;
|
hflag = 0;
|
||||||
while ((ch = getopt(argc, argv, "dh")) != -1)
|
qflag = 0;
|
||||||
|
while ((ch = getopt(argc, argv, "dhq")) != -1)
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'd':
|
case 'd':
|
||||||
type = ACL_TYPE_DEFAULT;
|
type = ACL_TYPE_DEFAULT;
|
||||||
@ -237,6 +240,9 @@ main(int argc, char *argv[])
|
|||||||
case 'h':
|
case 'h':
|
||||||
hflag = 1;
|
hflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
qflag = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -245,17 +251,17 @@ main(int argc, char *argv[])
|
|||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
error = print_acl_from_stdin(type, hflag);
|
error = print_acl_from_stdin(type, hflag, qflag);
|
||||||
return(error ? 1 : 0);
|
return(error ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if (!strcmp(argv[i], "-")) {
|
if (!strcmp(argv[i], "-")) {
|
||||||
error = print_acl_from_stdin(type, hflag);
|
error = print_acl_from_stdin(type, hflag, qflag);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
carried_error = -1;
|
carried_error = -1;
|
||||||
} else {
|
} else {
|
||||||
error = print_acl(argv[i], type, hflag);
|
error = print_acl(argv[i], type, hflag, qflag);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
carried_error = -1;
|
carried_error = -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user