From 4f5e8214362e9f130f4764f87421e991a69aeb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 5 Apr 2023 21:10:07 +0200 Subject: [PATCH] Avoid use of a deprecated capability.NewPid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is reported by golangci-lint. (Absolutely untested.) Signed-off-by: Miloslav Trmač --- cmd/skopeo/unshare_linux.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/skopeo/unshare_linux.go b/cmd/skopeo/unshare_linux.go index 4b005c2b9c..6778a02938 100644 --- a/cmd/skopeo/unshare_linux.go +++ b/cmd/skopeo/unshare_linux.go @@ -22,10 +22,13 @@ func maybeReexec() error { // With Skopeo we need only the subset of the root capabilities necessary // for pulling an image to the storage. Do not attempt to create a namespace // if we already have the capabilities we need. - capabilities, err := capability.NewPid(0) + capabilities, err := capability.NewPid2(0) if err != nil { return fmt.Errorf("error reading the current capabilities sets: %w", err) } + if err := capabilities.Load(); err != nil { + return fmt.Errorf("error loading the current capabilities sets: %w", err) + } if slices.ContainsFunc(neededCapabilities, func(cap capability.Cap) bool { return !capabilities.Get(capability.EFFECTIVE, cap) }) {