summaryrefslogtreecommitdiffstats
path: root/bin/getfacl
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-12-30 15:36:29 +0000
committerrwatson <rwatson@FreeBSD.org>2002-12-30 15:36:29 +0000
commit635446ba11e2a1a17dfab3a542618140301439d7 (patch)
tree1714c56775a1e6ff9a8dab17683f2e906d4b829e /bin/getfacl
parent059407e4d960a3ca304d62b719437fcbcca73704 (diff)
downloadFreeBSD-src-635446ba11e2a1a17dfab3a542618140301439d7.zip
FreeBSD-src-635446ba11e2a1a17dfab3a542618140301439d7.tar.gz
Add "-h" arguments to getfacl and setfacl, which behave in a manner
similar to "-h" on chown, chmod, etc, causing the operation to occur on a final symlink in the provided path, rather than its target. Obtained from: TrustedBSD Project
Diffstat (limited to 'bin/getfacl')
-rw-r--r--bin/getfacl/getfacl.19
-rw-r--r--bin/getfacl/getfacl.c33
2 files changed, 28 insertions, 14 deletions
diff --git a/bin/getfacl/getfacl.1 b/bin/getfacl/getfacl.1
index 291999a..16faf77 100644
--- a/bin/getfacl/getfacl.1
+++ b/bin/getfacl/getfacl.1
@@ -1,5 +1,5 @@
.\"-
-.\" Copyright (c) 2000-2001 Robert N. M. Watson
+.\" Copyright (c) 2000, 2001, 2002 Robert N. M. Watson
.\" All rights reserved.
.\"
.\" This software was developed by Robert Watson for the TrustedBSD Project.
@@ -30,7 +30,7 @@
.\" Developed by the TrustedBSD Project.
.\" Support for POSIX.1e access control lists.
.\"
-.Dd March 30, 2000
+.Dd Decemer 30, 2002
.Dt GETFACL 1
.Os
.Sh NAME
@@ -38,7 +38,7 @@
.Nd get ACL information
.Sh SYNOPSIS
.Nm
-.Op Fl d
+.Op Fl dh
.Op Ar
.Sh DESCRIPTION
The
@@ -61,6 +61,9 @@ The operation applies to the default ACL of a directory instead of the
access ACL.
An error is generated if a default ACL cannot be associated with
.Ar file .
+.It Fl h
+If the target of the operation is a symbolic link, return the ACL from
+the symbol link itself rather than following the link.
.El
.Pp
The following operand is available:
diff --git a/bin/getfacl/getfacl.c b/bin/getfacl/getfacl.c
index 22406d5..75ad1da 100644
--- a/bin/getfacl/getfacl.c
+++ b/bin/getfacl/getfacl.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1999-2001 Robert N M Watson
+ * Copyright (c) 1999, 2001, 2002 Robert N M Watson
* All rights reserved.
*
* This software was developed by Robert Watson for the TrustedBSD Project.
@@ -52,7 +52,7 @@ static void
usage(void)
{
- fprintf(stderr, "getfacl [-d] [files ...]\n");
+ fprintf(stderr, "getfacl [-dh] [files ...]\n");
}
/*
@@ -147,14 +147,17 @@ acl_from_stat(struct stat sb)
}
static int
-print_acl(char *path, acl_type_t type)
+print_acl(char *path, acl_type_t type, int hflag)
{
struct stat sb;
acl_t acl;
char *acl_text;
int error;
- error = stat(path, &sb);
+ if (hflag)
+ error = lstat(path, &sb);
+ else
+ error = stat(path, &sb);
if (error == -1) {
warn("%s", path);
return(-1);
@@ -167,7 +170,10 @@ print_acl(char *path, acl_type_t type)
printf("#file:%s\n#owner:%d\n#group:%d\n", path, sb.st_uid, sb.st_gid);
- acl = acl_get_file(path, type);
+ if (hflag)
+ acl = acl_get_link_np(path, type);
+ else
+ acl = acl_get_file(path, type);
if (!acl) {
if (errno != EOPNOTSUPP) {
warn("%s", path);
@@ -198,7 +204,7 @@ print_acl(char *path, acl_type_t type)
}
static int
-print_acl_from_stdin(acl_type_t type)
+print_acl_from_stdin(acl_type_t type, int hflag)
{
char *p, pathname[PATH_MAX];
int carried_error = 0;
@@ -206,7 +212,7 @@ print_acl_from_stdin(acl_type_t type)
while (fgets(pathname, (int)sizeof(pathname), stdin)) {
if ((p = strchr(pathname, '\n')) != NULL)
*p = '\0';
- if (print_acl(pathname, type) == -1) {
+ if (print_acl(pathname, type, hflag) == -1) {
carried_error = -1;
}
}
@@ -220,12 +226,17 @@ main(int argc, char *argv[])
acl_type_t type = ACL_TYPE_ACCESS;
int carried_error = 0;
int ch, error, i;
+ int hflag;
- while ((ch = getopt(argc, argv, "d")) != -1)
+ hflag = 0;
+ while ((ch = getopt(argc, argv, "dh")) != -1)
switch(ch) {
case 'd':
type = ACL_TYPE_DEFAULT;
break;
+ case 'h':
+ hflag = 1;
+ break;
default:
usage();
return(-1);
@@ -234,17 +245,17 @@ main(int argc, char *argv[])
argv += optind;
if (argc == 0) {
- error = print_acl_from_stdin(type);
+ error = print_acl_from_stdin(type, hflag);
return(error ? 1 : 0);
}
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-")) {
- error = print_acl_from_stdin(type);
+ error = print_acl_from_stdin(type, hflag);
if (error == -1)
carried_error = -1;
} else {
- error = print_acl(argv[i], type);
+ error = print_acl(argv[i], type, hflag);
if (error == -1)
carried_error = -1;
}
OpenPOWER on IntegriCloud