PERFORCE change 22683 for review
Robert Watson
rwatson at freebsd.org
Tue Dec 24 02:42:40 GMT 2002
http://perforce.freebsd.org/chv.cgi?CH=22683
Change 22683 by rwatson at rwatson_paprika on 2002/12/23 18:42:03
Teach these tools about a "-h" argument congruent to -h on
chmod, chown, ... This flag indicates the operation shall
be performed on the symbol link itself, rather than on the
target of the symbolic link.
Affected files ...
.. //depot/projects/trustedbsd/acl/bin/getfacl/getfacl.1#2 edit
.. //depot/projects/trustedbsd/acl/bin/getfacl/getfacl.c#2 edit
.. //depot/projects/trustedbsd/acl/bin/setfacl/setfacl.1#2 edit
.. //depot/projects/trustedbsd/acl/bin/setfacl/setfacl.c#2 edit
.. //depot/projects/trustedbsd/acl/bin/setfacl/setfacl.h#2 edit
Differences ...
==== //depot/projects/trustedbsd/acl/bin/getfacl/getfacl.1#2 (text+ko) ====
@@ -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 @@
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:
==== //depot/projects/trustedbsd/acl/bin/getfacl/getfacl.c#2 (text+ko) ====
@@ -147,7 +147,7 @@
}
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;
@@ -167,7 +167,10 @@
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(path, type);
+ else
+ acl = acl_get_file(path, type);
if (!acl) {
if (errno != EOPNOTSUPP) {
warn("%s", path);
@@ -198,7 +201,7 @@
}
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 +209,7 @@
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 +223,17 @@
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 +242,17 @@
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;
}
==== //depot/projects/trustedbsd/acl/bin/setfacl/setfacl.1#2 (text+ko) ====
@@ -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 @@
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
==== //depot/projects/trustedbsd/acl/bin/setfacl/setfacl.c#2 (text+ko) ====
@@ -71,11 +71,19 @@
}
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(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(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
@@ -104,12 +112,12 @@
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 @@
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;
==== //depot/projects/trustedbsd/acl/bin/setfacl/setfacl.h#2 (text+ko) ====
@@ -75,6 +75,7 @@
uint have_mask;
uint need_mask;
uint have_stdin;
+uint h_flag;
uint n_flag;
#endif /* _SETFACL_H */
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list