Skip to content

Conversation

kimminss0
Copy link
Contributor

Closes #2168

This PR implements system call wrappers for extattr on FreeBSD, and adds support for unpacking layers with external attributes(xattr). The implementation mimics how FreeBSD's linux compatibility layer and BSD tar handles xattr using extattr system calls, while both has some limitations that only two of the namespaces user and system are supported among the four – the rest, trusted and security remain unsupported.

@rhatdan
Copy link
Member

rhatdan commented Nov 11, 2024

@dfr PTAL

@kimminss0 kimminss0 force-pushed the freebsd-xattr-support branch 3 times, most recently from 9e03882 to 6f059fa Compare November 12, 2024 04:05
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A drive-by comment without really reading or understanding the code:

Could this be done without the run-time string comparison of GOOS (for every file)? That seems rather expensive, and it is not the idiomatic Go way.

I’d expect this to rely on Go build tags — maybe to have the setPlatformSpecificXattr function have a Linux/FreeBSD/unsupported variant; and for that function to both set the attribute and to make the decision whether to ignore the error.

@kimminss0 kimminss0 force-pushed the freebsd-xattr-support branch 4 times, most recently from 573b448 to 6085ac5 Compare November 15, 2024 11:10
@dfr
Copy link
Contributor

dfr commented Nov 15, 2024

LGTM - thanks for working on this

@nalind
Copy link
Member

nalind commented Nov 15, 2024

/approve

Copy link
Contributor

openshift-ci bot commented Nov 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kimminss0, nalind

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally LGTM.

There are other calls to Lsetxattr; does that matter? At least SetContainersOverrideXattr seems to be reachable. Maybe that’s not directly related to this PR and shouldn’t block it.

Cc: @giuseppe

@kimminss0 kimminss0 force-pushed the freebsd-xattr-support branch from 6085ac5 to b08c63f Compare November 15, 2024 17:12
This commit introduces wrappers for FreeBSD’s `extattr` system calls,
enabling support for extended file attributes. Note that the `extattr`
functionality on FreeBSD is analogous to Linux’s `xattr`.

Signed-off-by: Minseo Kim <kimminss0@outlook.kr>
…npacking

This commit enables applying extended file attributes (xattr) to files
during the unpacking of layers.

The implementation mimics how FreeBSD's linux compatibility layer and
BSD tar handles xattr using extattr system calls.  Linux and FreeBSD
supports different namespaces for extended attributes:

- Linux: security, system, trusted, user
- FreeBSD: system, user

The `system` and `user` namespaces are directly mapped between the two
systems. For unsupported namespaces on FreeBSD, such as `security` and
`trusted`, the attributes are just dropped.

Signed-off-by: Minseo Kim <kimminss0@outlook.kr>
@kimminss0 kimminss0 force-pushed the freebsd-xattr-support branch from b08c63f to 28548e9 Compare November 16, 2024 05:01
@rhatdan
Copy link
Member

rhatdan commented Nov 17, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Nov 17, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 6803f17 into containers:main Nov 17, 2024
20 checks passed
@kimminss0 kimminss0 deleted the freebsd-xattr-support branch November 19, 2024 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unpacking layers fails on FreeBSD due to missing xattr support
5 participants