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
|
.Nd manipulated extended attributes
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm getextattr
|
.Nm getextattr
|
||||||
.Op Fl fqsx
|
.Op Fl fhqsx
|
||||||
.Ar attrnamespace
|
.Ar attrnamespace
|
||||||
.Ar attrname
|
.Ar attrname
|
||||||
.Ar filename ...
|
.Ar filename ...
|
||||||
.Nm lsextattr
|
.Nm lsextattr
|
||||||
.Op Fl fq
|
.Op Fl fhq
|
||||||
.Ar attrnamespace
|
.Ar attrnamespace
|
||||||
.Ar filename ...
|
.Ar filename ...
|
||||||
.Nm rmextattr
|
.Nm rmextattr
|
||||||
.Op Fl fq
|
.Op Fl fhq
|
||||||
.Ar attrnamespace
|
.Ar attrnamespace
|
||||||
.Ar attrname
|
.Ar attrname
|
||||||
.Ar filename ...
|
.Ar filename ...
|
||||||
.Nm setextattr
|
.Nm setextattr
|
||||||
.Op Fl fq
|
.Op Fl fhq
|
||||||
.Ar attrnamespace
|
.Ar attrnamespace
|
||||||
.Ar attrname
|
.Ar attrname
|
||||||
.Ar attrvalue
|
.Ar attrvalue
|
||||||
@ -83,6 +83,9 @@ The following options are available:
|
|||||||
.It Fl -f
|
.It Fl -f
|
||||||
(Force) Ignore errors on individual filenames and continue with
|
(Force) Ignore errors on individual filenames and continue with
|
||||||
the remaining arguments.
|
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
|
.It Fl -q
|
||||||
(Quiet) Do not print out the pathname and suppress error messages.
|
(Quiet) Do not print out the pathname and suppress error messages.
|
||||||
.It Fl -s
|
.It Fl -s
|
||||||
|
@ -58,19 +58,19 @@ usage(void)
|
|||||||
|
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case EAGET:
|
case EAGET:
|
||||||
fprintf(stderr, "usage: getextattr [-fqsx] attrnamespace");
|
fprintf(stderr, "usage: getextattr [-fhqsx] attrnamespace");
|
||||||
fprintf(stderr, " attrname filename ...\n");
|
fprintf(stderr, " attrname filename ...\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
case EASET:
|
case EASET:
|
||||||
fprintf(stderr, "usage: setextattr [-fq] attrnamespace");
|
fprintf(stderr, "usage: setextattr [-fhq] attrnamespace");
|
||||||
fprintf(stderr, " attrname attrvalue filename ...\n");
|
fprintf(stderr, " attrname attrvalue filename ...\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
case EARM:
|
case EARM:
|
||||||
fprintf(stderr, "usage: rmextattr [-fq] attrnamespace");
|
fprintf(stderr, "usage: rmextattr [-fhq] attrnamespace");
|
||||||
fprintf(stderr, " attrname filename ...\n");
|
fprintf(stderr, " attrname filename ...\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
case EALS:
|
case EALS:
|
||||||
fprintf(stderr, "usage: lsextattr [-fq] attrnamespace");
|
fprintf(stderr, "usage: lsextattr [-fhq] attrnamespace");
|
||||||
fprintf(stderr, " filename ...\n");
|
fprintf(stderr, " filename ...\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
case EADUNNO:
|
case EADUNNO:
|
||||||
@ -105,6 +105,7 @@ main(int argc, char *argv[])
|
|||||||
int buflen, visbuflen, ch, error, i, arg_counter, attrnamespace;
|
int buflen, visbuflen, ch, error, i, arg_counter, attrnamespace;
|
||||||
|
|
||||||
int flag_force = 0;
|
int flag_force = 0;
|
||||||
|
int flag_nofollow = 0;
|
||||||
int flag_quiet = 0;
|
int flag_quiet = 0;
|
||||||
int flag_string = 0;
|
int flag_string = 0;
|
||||||
int flag_hex = 0;
|
int flag_hex = 0;
|
||||||
@ -117,16 +118,16 @@ main(int argc, char *argv[])
|
|||||||
p = argv[0];
|
p = argv[0];
|
||||||
if (!strcmp(p, "getextattr")) {
|
if (!strcmp(p, "getextattr")) {
|
||||||
what = EAGET;
|
what = EAGET;
|
||||||
options = "fqsx";
|
options = "fhqsx";
|
||||||
} else if (!strcmp(p, "setextattr")) {
|
} else if (!strcmp(p, "setextattr")) {
|
||||||
what = EASET;
|
what = EASET;
|
||||||
options = "fq";
|
options = "fhq";
|
||||||
} else if (!strcmp(p, "rmextattr")) {
|
} else if (!strcmp(p, "rmextattr")) {
|
||||||
what = EARM;
|
what = EARM;
|
||||||
options = "fq";
|
options = "fhq";
|
||||||
} else if (!strcmp(p, "lsextattr")) {
|
} else if (!strcmp(p, "lsextattr")) {
|
||||||
what = EALS;
|
what = EALS;
|
||||||
options = "fq";
|
options = "fhq";
|
||||||
} else {
|
} else {
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@ -136,6 +137,9 @@ main(int argc, char *argv[])
|
|||||||
case 'f':
|
case 'f':
|
||||||
flag_force = 1;
|
flag_force = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
flag_nofollow = 1;
|
||||||
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
flag_quiet = 1;
|
flag_quiet = 1;
|
||||||
break;
|
break;
|
||||||
@ -178,26 +182,42 @@ main(int argc, char *argv[])
|
|||||||
for (arg_counter = 0; arg_counter < argc; arg_counter++) {
|
for (arg_counter = 0; arg_counter < argc; arg_counter++) {
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case EARM:
|
case EARM:
|
||||||
error = extattr_delete_file(argv[arg_counter],
|
if (flag_nofollow)
|
||||||
attrnamespace, attrname);
|
error = extattr_delete_link(argv[arg_counter],
|
||||||
|
attrnamespace, attrname);
|
||||||
|
else
|
||||||
|
error = extattr_delete_file(argv[arg_counter],
|
||||||
|
attrnamespace, attrname);
|
||||||
if (error >= 0)
|
if (error >= 0)
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
case EASET:
|
case EASET:
|
||||||
error = extattr_set_file(argv[arg_counter],
|
if (flag_nofollow)
|
||||||
attrnamespace, attrname, buf, strlen(buf));
|
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)
|
if (error >= 0)
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
case EALS:
|
case EALS:
|
||||||
case EAGET:
|
case EAGET:
|
||||||
error = extattr_get_file(argv[arg_counter],
|
if (flag_nofollow)
|
||||||
attrnamespace, attrname, NULL, 0);
|
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)
|
if (error < 0)
|
||||||
break;
|
break;
|
||||||
mkbuf(&buf, &buflen, error);
|
mkbuf(&buf, &buflen, error);
|
||||||
error = extattr_get_file(argv[arg_counter],
|
if (flag_nofollow)
|
||||||
attrnamespace, attrname, buf, buflen);
|
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)
|
if (error < 0)
|
||||||
break;
|
break;
|
||||||
if (!flag_quiet)
|
if (!flag_quiet)
|
||||||
|
Loading…
Reference in New Issue
Block a user