diff options
author | rwatson <rwatson@FreeBSD.org> | 2002-12-30 15:36:29 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2002-12-30 15:36:29 +0000 |
commit | 635446ba11e2a1a17dfab3a542618140301439d7 (patch) | |
tree | 1714c56775a1e6ff9a8dab17683f2e906d4b829e /bin/setfacl | |
parent | 059407e4d960a3ca304d62b719437fcbcca73704 (diff) | |
download | FreeBSD-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/setfacl')
-rw-r--r-- | bin/setfacl/setfacl.1 | 5 | ||||
-rw-r--r-- | bin/setfacl/setfacl.c | 21 | ||||
-rw-r--r-- | bin/setfacl/setfacl.h | 1 |
3 files changed, 21 insertions, 6 deletions
diff --git a/bin/setfacl/setfacl.1 b/bin/setfacl/setfacl.1 index ce27f58..43eba96 100644 --- a/bin/setfacl/setfacl.1 +++ b/bin/setfacl/setfacl.1 @@ -33,7 +33,7 @@ .Nd set ACL information .Sh SYNOPSIS .Nm -.Op Fl bdkn +.Op Fl bdhkn .Op Fl m Ar entries .Op Fl M Ar file1 .Op Fl x Ar entries @@ -63,6 +63,9 @@ entries of the current ACL. The operations apply to the default ACL entries instead of access ACL entries. Currently only directories may have default ACL's. +.It Fl h +If the target of the operation is a symbolic link, perform the operation +on the symbolic link itself, rather than following the link. .It Fl k Delete any default ACL entries on the specified files. It is not considered an error if the specified files do not have diff --git a/bin/setfacl/setfacl.c b/bin/setfacl/setfacl.c index 367909b..d27285c 100644 --- a/bin/setfacl/setfacl.c +++ b/bin/setfacl/setfacl.c @@ -71,11 +71,19 @@ get_file_acls(const char *filename) } acl = zmalloc(sizeof(acl_t) * 2); - acl[ACCESS_ACL] = acl_get_file(filename, ACL_TYPE_ACCESS); + if (h_flag) + acl[ACCESS_ACL] = acl_get_link_np(filename, ACL_TYPE_ACCESS); + else + acl[ACCESS_ACL] = acl_get_file(filename, ACL_TYPE_ACCESS); if (acl[ACCESS_ACL] == NULL) err(1, "acl_get_file() failed"); if (S_ISDIR(sb.st_mode)) { - acl[DEFAULT_ACL] = acl_get_file(filename, ACL_TYPE_DEFAULT); + if (h_flag) + acl[DEFAULT_ACL] = acl_get_link_np(filename, + ACL_TYPE_DEFAULT); + else + acl[DEFAULT_ACL] = acl_get_file(filename, + ACL_TYPE_DEFAULT); if (acl[DEFAULT_ACL] == NULL) err(1, "acl_get_file() failed"); } else @@ -88,7 +96,7 @@ static void usage(void) { - fprintf(stderr, "usage: setfacl [-bdknv] [-m entries] [-M file1] " + fprintf(stderr, "usage: setfacl [-bdhknv] [-m entries] [-M file1] " "[-x entries] [-X file2] [file ...]\n"); exit(1); } @@ -104,12 +112,12 @@ main(int argc, char *argv[]) acl_type = ACL_TYPE_ACCESS; carried_error = local_error = 0; - have_mask = have_stdin = n_flag = need_mask = 0; + h_flag = have_mask = have_stdin = n_flag = need_mask = 0; TAILQ_INIT(&entrylist); TAILQ_INIT(&filelist); - while ((ch = getopt(argc, argv, "M:X:bdkm:nx:")) != -1) + while ((ch = getopt(argc, argv, "M:X:bdhkm:nx:")) != -1) switch(ch) { case 'M': entry = zmalloc(sizeof(struct sf_entry)); @@ -133,6 +141,9 @@ main(int argc, char *argv[]) case 'd': acl_type = ACL_TYPE_DEFAULT; break; + case 'h': + h_flag = 1; + break; case 'k': entry = zmalloc(sizeof(struct sf_entry)); entry->op = OP_REMOVE_DEF; diff --git a/bin/setfacl/setfacl.h b/bin/setfacl/setfacl.h index 022a4a34..91b4f00 100644 --- a/bin/setfacl/setfacl.h +++ b/bin/setfacl/setfacl.h @@ -75,6 +75,7 @@ acl_type_t acl_type; uint have_mask; uint need_mask; uint have_stdin; +uint h_flag; uint n_flag; #endif /* _SETFACL_H */ |