-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tar xattr
support
#707
base: main
Are you sure you want to change the base?
Conversation
ba6e562
to
027f82d
Compare
Can you start a bug about this so we can get the requirements right first. |
I want to make something like FROM ubuntu:22.04
...
COPY app /usr/local/bin/app
RUN setcap cap_sys_resource+ep /usr/local/bin/app In load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
...
pkg_tar(
name = "app-tar",
extension = "tar",
files = {
":app": "/usr/local/bin/app",
},
xattr = [
"security.capability=0x0100000200000001000000000000000000000000",
],
)
container_image(
name = "app-image",
...
tars = [
":app-tar",
],
) In this example xattrs = {
"usr/local/bin/app": [
"security.capability=0x0100000200000001000000000000000000000000",
]
}, |
Can you think about how this should be in pkg_files. Adding it only to pkg_tar is sort of a dead end. |
key = item[:idx] | ||
raw = item[idx+1:] | ||
if raw.startswith("0x"): | ||
xattrs[key] = bytes.fromhex(raw[2:]).decode('latin-1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to use .decode('utf-8', "surrogateescape")
here as certain xattrs
will be re-encoded incorrectly otherwise. On re-encoding the tarfile
module uses surrogateescape
to restore any values that don't cleanly decode to UTF-8.
Motivation
I need tool to set "max locked memory" ulimit for
mongos
inside Kubernetes environment.This tool need
etcap cap_sys_resource+ep
xattr on file.This PR allows set
xattr
on files inside .tar artchives.Example
Allow set
xattr
inside tar archives, for example: