summaryrefslogtreecommitdiffstats
path: root/usr.sbin/extattr
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2002-10-10 17:16:00 +0000
committergreen <green@FreeBSD.org>2002-10-10 17:16:00 +0000
commit22299c98475bd852c8dca621d95e815cd48a4668 (patch)
tree87ac113a38ab0bc334e07e9bd047f3a06e349f09 /usr.sbin/extattr
parent8d1b432ebca11727add6494b7b74e57979cf4a44 (diff)
downloadFreeBSD-src-22299c98475bd852c8dca621d95e815cd48a4668.zip
FreeBSD-src-22299c98475bd852c8dca621d95e815cd48a4668.tar.gz
Add an -n option to write the trailing nul byte to the extattr when
using setextattr(8) to write a string. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'usr.sbin/extattr')
-rw-r--r--usr.sbin/extattr/rmextattr.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/extattr/rmextattr.c b/usr.sbin/extattr/rmextattr.c
index 13bebc6..a86eb62 100644
--- a/usr.sbin/extattr/rmextattr.c
+++ b/usr.sbin/extattr/rmextattr.c
@@ -62,7 +62,7 @@ usage(void)
fprintf(stderr, " attrname filename ...\n");
exit(-1);
case EASET:
- fprintf(stderr, "usage: setextattr [-fhq] attrnamespace");
+ fprintf(stderr, "usage: setextattr [-fhnq] attrnamespace");
fprintf(stderr, " attrname attrvalue filename ...\n");
exit(-1);
case EARM:
@@ -107,6 +107,7 @@ main(int argc, char *argv[])
int flag_force = 0;
int flag_nofollow = 0;
+ int flag_null = 0;
int flag_quiet = 0;
int flag_string = 0;
int flag_hex = 0;
@@ -123,7 +124,7 @@ main(int argc, char *argv[])
minargc = 3;
} else if (!strcmp(p, "setextattr")) {
what = EASET;
- options = "fhq";
+ options = "fhnq";
minargc = 4;
} else if (!strcmp(p, "rmextattr")) {
what = EARM;
@@ -145,6 +146,9 @@ main(int argc, char *argv[])
case 'h':
flag_nofollow = 1;
break;
+ case 'n':
+ flag_null = 1;
+ break;
case 'q':
flag_quiet = 1;
break;
@@ -199,10 +203,12 @@ main(int argc, char *argv[])
case EASET:
if (flag_nofollow)
error = extattr_set_link(argv[arg_counter],
- attrnamespace, attrname, buf, strlen(buf));
+ attrnamespace, attrname, buf,
+ strlen(buf) + flag_null);
else
error = extattr_set_file(argv[arg_counter],
- attrnamespace, attrname, buf, strlen(buf));
+ attrnamespace, attrname, buf,
+ strlen(buf) + flag_null);
if (error >= 0)
continue;
break;
OpenPOWER on IntegriCloud