aboutsummaryrefslogtreecommitdiff
path: root/bin/getfacl
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2006-03-13 11:45:29 +0000
committerRobert Watson <rwatson@FreeBSD.org>2006-03-13 11:45:29 +0000
commitf9a86e379c73f6d719ab6210e766c0d9d276eb71 (patch)
treeab56dacff00208c610173a142d8fd405934391d9 /bin/getfacl
parent28e989e9ca5acfbb491a7005ad27444f6a9eb65e (diff)
downloadsrc-f9a86e379c73f6d719ab6210e766c0d9d276eb71.tar.gz
src-f9a86e379c73f6d719ab6210e766c0d9d276eb71.zip
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>
Notes
Notes: svn path=/head/; revision=156681
Diffstat (limited to 'bin/getfacl')
-rw-r--r--bin/getfacl/getfacl.15
-rw-r--r--bin/getfacl/getfacl.c26
2 files changed, 20 insertions, 11 deletions
diff --git a/bin/getfacl/getfacl.1 b/bin/getfacl/getfacl.1
index d74f77ac9229..b688a4ebfb8f 100644
--- a/bin/getfacl/getfacl.1
+++ b/bin/getfacl/getfacl.1
@@ -38,7 +38,7 @@
.Nd get ACL information
.Sh SYNOPSIS
.Nm
-.Op Fl dh
+.Op Fl dhq
.Op Ar
.Sh DESCRIPTION
The
@@ -64,6 +64,9 @@ An error is generated if a default ACL cannot be associated with
.It Fl h
If the target of the operation is a symbolic link, return the ACL from
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
.Pp
The following operand is available:
diff --git a/bin/getfacl/getfacl.c b/bin/getfacl/getfacl.c
index 297b41274c63..b023cb4090b4 100644
--- a/bin/getfacl/getfacl.c
+++ b/bin/getfacl/getfacl.c
@@ -52,7 +52,7 @@ static 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
-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;
acl_t acl;
@@ -168,7 +168,9 @@ print_acl(char *path, acl_type_t type, int hflag)
else
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)
acl = acl_get_link_np(path, type);
@@ -204,7 +206,7 @@ print_acl(char *path, acl_type_t type, int hflag)
}
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];
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)) {
if ((p = strchr(pathname, '\n')) != NULL)
*p = '\0';
- if (print_acl(pathname, type, hflag) == -1) {
+ if (print_acl(pathname, type, hflag, qflag) == -1) {
carried_error = -1;
}
}
@@ -226,10 +228,11 @@ main(int argc, char *argv[])
acl_type_t type = ACL_TYPE_ACCESS;
int carried_error = 0;
int ch, error, i;
- int hflag;
+ int hflag, qflag;
hflag = 0;
- while ((ch = getopt(argc, argv, "dh")) != -1)
+ qflag = 0;
+ while ((ch = getopt(argc, argv, "dhq")) != -1)
switch(ch) {
case 'd':
type = ACL_TYPE_DEFAULT;
@@ -237,6 +240,9 @@ main(int argc, char *argv[])
case 'h':
hflag = 1;
break;
+ case 'q':
+ qflag = 1;
+ break;
default:
usage();
return(-1);
@@ -245,17 +251,17 @@ main(int argc, char *argv[])
argv += optind;
if (argc == 0) {
- error = print_acl_from_stdin(type, hflag);
+ error = print_acl_from_stdin(type, hflag, qflag);
return(error ? 1 : 0);
}
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-")) {
- error = print_acl_from_stdin(type, hflag);
+ error = print_acl_from_stdin(type, hflag, qflag);
if (error == -1)
carried_error = -1;
} else {
- error = print_acl(argv[i], type, hflag);
+ error = print_acl(argv[i], type, hflag, qflag);
if (error == -1)
carried_error = -1;
}