lib/commit: Copy user.ostreemeta only for bare-user
When falling back to copying objects when importing them into a bare-user repo, we only actually need to transfer over the `user.ostreemeta` xattr. This allows the destination repo to be on a separate filesystem that might not even support `security.selinux`. (I hit this while importing over virtio-9p). Closes: #1771 Approved by: cgwalters
This commit is contained in:
parent
8eac5be030
commit
244d9a7ec1
|
|
@ -4261,15 +4261,29 @@ import_one_object_direct (OstreeRepo *dest_repo,
|
||||||
G_IN_SET (src_repo->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER);
|
G_IN_SET (src_repo->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER);
|
||||||
if (src_is_bare_or_bare_user && !OSTREE_OBJECT_TYPE_IS_META(objtype))
|
if (src_is_bare_or_bare_user && !OSTREE_OBJECT_TYPE_IS_META(objtype))
|
||||||
{
|
{
|
||||||
g_autoptr(GVariant) xattrs = NULL;
|
if (src_repo == OSTREE_REPO_MODE_BARE)
|
||||||
|
{
|
||||||
|
g_autoptr(GVariant) xattrs = NULL;
|
||||||
|
if (!glnx_fd_get_all_xattrs (src_fd, &xattrs,
|
||||||
|
cancellable, error))
|
||||||
|
return FALSE;
|
||||||
|
if (!glnx_fd_set_all_xattrs (tmp_dest.fd, xattrs,
|
||||||
|
cancellable, error))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* bare-user; we just want ostree.usermeta */
|
||||||
|
g_autoptr(GBytes) bytes =
|
||||||
|
glnx_fgetxattr_bytes (src_fd, "user.ostreemeta", error);
|
||||||
|
if (bytes == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (!glnx_fd_get_all_xattrs (src_fd, &xattrs,
|
if (TEMP_FAILURE_RETRY (fsetxattr (src_fd, "user.ostreemeta",
|
||||||
cancellable, error))
|
(char*)g_bytes_get_data (bytes, NULL),
|
||||||
return FALSE;
|
g_bytes_get_size (bytes), 0)) != 0)
|
||||||
|
return glnx_throw_errno_prefix (error, "fsetxattr");
|
||||||
if (!glnx_fd_set_all_xattrs (tmp_dest.fd, xattrs,
|
}
|
||||||
cancellable, error))
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fchmod (tmp_dest.fd, stbuf.st_mode & ~S_IFMT) != 0)
|
if (fchmod (tmp_dest.fd, stbuf.st_mode & ~S_IFMT) != 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue