Add -h flags to each of the *extattr(8) commands, indicating that
the command should not follow the symlink if the target file is a symlink. Invoke the extattr_*_link(2) version of the system call in that situation, instead of extattr_*_file(2). This is consistent with other attribute management tools in the system. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
This commit is contained in:
parent
16de69e956
commit
6c3fb1121a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=104798
@ -42,21 +42,21 @@
|
||||
.Nd manipulated extended attributes
|
||||
.Sh SYNOPSIS
|
||||
.Nm getextattr
|
||||
.Op Fl fqsx
|
||||
.Op Fl fhqsx
|
||||
.Ar attrnamespace
|
||||
.Ar attrname
|
||||
.Ar filename ...
|
||||
.Nm lsextattr
|
||||
.Op Fl fq
|
||||
.Op Fl fhq
|
||||
.Ar attrnamespace
|
||||
.Ar filename ...
|
||||
.Nm rmextattr
|
||||
.Op Fl fq
|
||||
.Op Fl fhq
|
||||
.Ar attrnamespace
|
||||
.Ar attrname
|
||||
.Ar filename ...
|
||||
.Nm setextattr
|
||||
.Op Fl fq
|
||||
.Op Fl fhq
|
||||
.Ar attrnamespace
|
||||
.Ar attrname
|
||||
.Ar attrvalue
|
||||
@ -83,6 +83,9 @@ The following options are available:
|
||||
.It Fl -f
|
||||
(Force) Ignore errors on individual filenames and continue with
|
||||
the remaining arguments.
|
||||
.It Fl -h
|
||||
(No follow) If the file is a symbolic link, perform the operation on the
|
||||
link itself rather than the file that the link points to.
|
||||
.It Fl -q
|
||||
(Quiet) Do not print out the pathname and suppress error messages.
|
||||
.It Fl -s
|
||||
|
@ -58,19 +58,19 @@ usage(void)
|
||||
|
||||
switch (what) {
|
||||
case EAGET:
|
||||
fprintf(stderr, "usage: getextattr [-fqsx] attrnamespace");
|
||||
fprintf(stderr, "usage: getextattr [-fhqsx] attrnamespace");
|
||||
fprintf(stderr, " attrname filename ...\n");
|
||||
exit(-1);
|
||||
case EASET:
|
||||
fprintf(stderr, "usage: setextattr [-fq] attrnamespace");
|
||||
fprintf(stderr, "usage: setextattr [-fhq] attrnamespace");
|
||||
fprintf(stderr, " attrname attrvalue filename ...\n");
|
||||
exit(-1);
|
||||
case EARM:
|
||||
fprintf(stderr, "usage: rmextattr [-fq] attrnamespace");
|
||||
fprintf(stderr, "usage: rmextattr [-fhq] attrnamespace");
|
||||
fprintf(stderr, " attrname filename ...\n");
|
||||
exit(-1);
|
||||
case EALS:
|
||||
fprintf(stderr, "usage: lsextattr [-fq] attrnamespace");
|
||||
fprintf(stderr, "usage: lsextattr [-fhq] attrnamespace");
|
||||
fprintf(stderr, " filename ...\n");
|
||||
exit(-1);
|
||||
case EADUNNO:
|
||||
@ -105,6 +105,7 @@ main(int argc, char *argv[])
|
||||
int buflen, visbuflen, ch, error, i, arg_counter, attrnamespace;
|
||||
|
||||
int flag_force = 0;
|
||||
int flag_nofollow = 0;
|
||||
int flag_quiet = 0;
|
||||
int flag_string = 0;
|
||||
int flag_hex = 0;
|
||||
@ -117,16 +118,16 @@ main(int argc, char *argv[])
|
||||
p = argv[0];
|
||||
if (!strcmp(p, "getextattr")) {
|
||||
what = EAGET;
|
||||
options = "fqsx";
|
||||
options = "fhqsx";
|
||||
} else if (!strcmp(p, "setextattr")) {
|
||||
what = EASET;
|
||||
options = "fq";
|
||||
options = "fhq";
|
||||
} else if (!strcmp(p, "rmextattr")) {
|
||||
what = EARM;
|
||||
options = "fq";
|
||||
options = "fhq";
|
||||
} else if (!strcmp(p, "lsextattr")) {
|
||||
what = EALS;
|
||||
options = "fq";
|
||||
options = "fhq";
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
@ -136,6 +137,9 @@ main(int argc, char *argv[])
|
||||
case 'f':
|
||||
flag_force = 1;
|
||||
break;
|
||||
case 'h':
|
||||
flag_nofollow = 1;
|
||||
break;
|
||||
case 'q':
|
||||
flag_quiet = 1;
|
||||
break;
|
||||
@ -178,12 +182,20 @@ main(int argc, char *argv[])
|
||||
for (arg_counter = 0; arg_counter < argc; arg_counter++) {
|
||||
switch (what) {
|
||||
case EARM:
|
||||
if (flag_nofollow)
|
||||
error = extattr_delete_link(argv[arg_counter],
|
||||
attrnamespace, attrname);
|
||||
else
|
||||
error = extattr_delete_file(argv[arg_counter],
|
||||
attrnamespace, attrname);
|
||||
if (error >= 0)
|
||||
continue;
|
||||
break;
|
||||
case EASET:
|
||||
if (flag_nofollow)
|
||||
error = extattr_set_link(argv[arg_counter],
|
||||
attrnamespace, attrname, buf, strlen(buf));
|
||||
else
|
||||
error = extattr_set_file(argv[arg_counter],
|
||||
attrnamespace, attrname, buf, strlen(buf));
|
||||
if (error >= 0)
|
||||
@ -191,11 +203,19 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case EALS:
|
||||
case EAGET:
|
||||
if (flag_nofollow)
|
||||
error = extattr_get_link(argv[arg_counter],
|
||||
attrnamespace, attrname, NULL, 0);
|
||||
else
|
||||
error = extattr_get_file(argv[arg_counter],
|
||||
attrnamespace, attrname, NULL, 0);
|
||||
if (error < 0)
|
||||
break;
|
||||
mkbuf(&buf, &buflen, error);
|
||||
if (flag_nofollow)
|
||||
error = extattr_get_link(argv[arg_counter],
|
||||
attrnamespace, attrname, buf, buflen);
|
||||
else
|
||||
error = extattr_get_file(argv[arg_counter],
|
||||
attrnamespace, attrname, buf, buflen);
|
||||
if (error < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user