PERFORCE change 19032 for review
Robert Watson
rwatson at freebsd.org
Thu Oct 10 16:32:55 GMT 2002
http://perforce.freebsd.org/p4db/chv.cgi?CH=19032
Change 19032 by rwatson at rwatson_tislabs on 2002/10/10 09:32:28
Restore consistency with other base system security and
non-security attribute management tools. By default, follow
symlinks in EA operations; if the -h flag is specified, act
on the link instead of the target.
Discussed with: phk, others
Affected files ...
.. //depot/projects/trustedbsd/mac/usr.sbin/extattr/rmextattr.8#4 edit
.. //depot/projects/trustedbsd/mac/usr.sbin/extattr/rmextattr.c#6 edit
Differences ...
==== //depot/projects/trustedbsd/mac/usr.sbin/extattr/rmextattr.8#4 (text+ko) ====
@@ -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 fnq
+.Op Fl fhnq
.Ar attrnamespace
.Ar attrname
.Ar attrvalue
@@ -77,15 +77,15 @@
the name of the target file or directory,
.Ar attrvalue
a string to store in the attribute.
-Since it is not useful to operate on the target of a symbolic link, the given
-.Ar filename
-is not followed if it is one.
.Pp
The following options are available:
.Bl -tag -width flag
.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 -n
(Nul-terminate) Nul-terminate the extent content written out.
.It Fl -q
==== //depot/projects/trustedbsd/mac/usr.sbin/extattr/rmextattr.c#6 (text+ko) ====
@@ -58,19 +58,19 @@
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 [-fnq] attrnamespace");
+ fprintf(stderr, "usage: setextattr [-fhnq] 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:
@@ -106,6 +106,7 @@
minargc;
int flag_force = 0;
+ int flag_nofollow = 0;
int flag_null = 0;
int flag_quiet = 0;
int flag_string = 0;
@@ -119,19 +120,19 @@
p = argv[0];
if (!strcmp(p, "getextattr")) {
what = EAGET;
- options = "fqsx";
+ options = "fhqsx";
minargc = 3;
} else if (!strcmp(p, "setextattr")) {
what = EASET;
- options = "fnq";
+ options = "fhnq";
minargc = 4;
} else if (!strcmp(p, "rmextattr")) {
what = EARM;
- options = "fq";
+ options = "fhq";
minargc = 3;
} else if (!strcmp(p, "lsextattr")) {
what = EALS;
- options = "fq";
+ options = "fhq";
minargc = 2;
} else {
usage();
@@ -142,6 +143,9 @@
case 'f':
flag_force = 1;
break;
+ case 'h':
+ flag_nofollow = 1;
+ break;
case 'n':
flag_null = 1;
break;
@@ -187,27 +191,44 @@
for (arg_counter = 0; arg_counter < argc; arg_counter++) {
switch (what) {
case EARM:
- error = extattr_delete_link(argv[arg_counter],
- attrnamespace, attrname);
+ 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:
- error = extattr_set_link(argv[arg_counter],
- attrnamespace, attrname, buf,
- strlen(buf) + flag_null);
+ if (flag_nofollow)
+ error = extattr_set_link(argv[arg_counter],
+ attrnamespace, attrname, buf,
+ strlen(buf) + flag_null);
+ else
+ error = extattr_set_file(argv[arg_counter],
+ attrnamespace, attrname, buf,
+ strlen(buf) + flag_null);
if (error >= 0)
continue;
break;
case EALS:
case EAGET:
- error = extattr_get_link(argv[arg_counter],
- attrnamespace, attrname, NULL, 0);
+ 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);
- error = extattr_get_link(argv[arg_counter],
- attrnamespace, attrname, buf, buflen);
+ 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)
break;
if (!flag_quiet)
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