mirror of
https://github.com/containers/skopeo.git
synced 2025-09-22 02:18:41 +00:00
Add option to preserve digests on copy
When enabled, if digests can't be preserved an error will be raised. Signed-off-by: James Hewitt <james.hewitt@uk.ibm.com>
This commit is contained in:
45
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
45
vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
generated
vendored
@@ -316,8 +316,9 @@ func classIndex(class string) (int, error) {
|
||||
return index, nil
|
||||
}
|
||||
|
||||
// setFileLabel sets the SELinux label for this path or returns an error.
|
||||
func setFileLabel(fpath string, label string) error {
|
||||
// lSetFileLabel sets the SELinux label for this path, not following symlinks,
|
||||
// or returns an error.
|
||||
func lSetFileLabel(fpath string, label string) error {
|
||||
if fpath == "" {
|
||||
return ErrEmptyPath
|
||||
}
|
||||
@@ -334,12 +335,50 @@ func setFileLabel(fpath string, label string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// fileLabel returns the SELinux label for this path or returns an error.
|
||||
// setFileLabel sets the SELinux label for this path, following symlinks,
|
||||
// or returns an error.
|
||||
func setFileLabel(fpath string, label string) error {
|
||||
if fpath == "" {
|
||||
return ErrEmptyPath
|
||||
}
|
||||
for {
|
||||
err := unix.Setxattr(fpath, xattrNameSelinux, []byte(label), 0)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
if err != unix.EINTR { //nolint:errorlint // unix errors are bare
|
||||
return &os.PathError{Op: "setxattr", Path: fpath, Err: err}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// fileLabel returns the SELinux label for this path, following symlinks,
|
||||
// or returns an error.
|
||||
func fileLabel(fpath string) (string, error) {
|
||||
if fpath == "" {
|
||||
return "", ErrEmptyPath
|
||||
}
|
||||
|
||||
label, err := getxattr(fpath, xattrNameSelinux)
|
||||
if err != nil {
|
||||
return "", &os.PathError{Op: "getxattr", Path: fpath, Err: err}
|
||||
}
|
||||
// Trim the NUL byte at the end of the byte buffer, if present.
|
||||
if len(label) > 0 && label[len(label)-1] == '\x00' {
|
||||
label = label[:len(label)-1]
|
||||
}
|
||||
return string(label), nil
|
||||
}
|
||||
|
||||
// lFileLabel returns the SELinux label for this path, not following symlinks,
|
||||
// or returns an error.
|
||||
func lFileLabel(fpath string) (string, error) {
|
||||
if fpath == "" {
|
||||
return "", ErrEmptyPath
|
||||
}
|
||||
|
||||
label, err := lgetxattr(fpath, xattrNameSelinux)
|
||||
if err != nil {
|
||||
return "", &os.PathError{Op: "lgetxattr", Path: fpath, Err: err}
|
||||
|
Reference in New Issue
Block a user