Commit b45af9e6 authored by Shawn Webb's avatar Shawn Webb
Browse files

HBSD: Fix libarchive's handling of extattr_set_fd



On FreeBSD, extattr_set_fd does not return the same as extattr_set_file.
It returns zero on success, non-zero on failure.

We can detect the failure by manually setting errno prior to the call
and checking after.

If errno remains zero, fake the return value by setting e to size.

This is a hack for now until I (Shawn Webb) get FreeBSD to fix the
issue, if that's even possible.

Signed-off-by: Shawn Webb's avatarShawn Webb <shawn.webb@hardenedbsd.org>
issue:		#1
MFC-to:		12-STABLE
parent aae1e4a9
......@@ -4411,6 +4411,8 @@ set_xattrs(struct archive_write_disk *a)
ssize_t e;
int namespace;
namespace = EXTATTR_NAMESPACE_USER;
if (strncmp(name, "user.", 5) == 0) {
/* "user." attributes go to user namespace */
name += 5;
......@@ -4428,8 +4430,29 @@ set_xattrs(struct archive_write_disk *a)
}
if (a->fd >= 0) {
/*
* On FreeBSD, extattr_set_fd does not
* return the same as
* extattr_set_file. It returns zero
* on success, non-zero on failure.
*
* We can detect the failure by
* manually setting errno prior to the
* call and checking after.
*
* If errno remains zero, fake the
* return value by setting e to size.
*
* This is a hack for now until I
* (Shawn Webb) get FreeBSD to fix the
* issue, if that's even possible.
*/
errno = 0;
e = extattr_set_fd(a->fd, namespace, name,
value, size);
if (e == 0 && errno == 0) {
e = size;
}
} else {
e = extattr_set_link(
archive_entry_pathname(entry), namespace,
......@@ -4442,6 +4465,7 @@ set_xattrs(struct archive_write_disk *a)
if (errno != ENOTSUP && errno != ENOSYS)
fail = 1;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment