From 201a1558c6c27bf7ff35ddb2bdfa3537b0b122d1 Mon Sep 17 00:00:00 2001 From: rwatson Date: Mon, 13 Mar 2006 11:45:29 +0000 Subject: 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 --- bin/getfacl/getfacl.1 | 5 ++++- bin/getfacl/getfacl.c | 26 ++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/getfacl/getfacl.1 b/bin/getfacl/getfacl.1 index d74f77a..b688a4e 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 297b412..b023cb4 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; } -- cgit v1.1