@@ -5,6 +5,7 @@ package libcontainer
55import (
66 "bytes"
77 "encoding/json"
8+ "errors"
89 "fmt"
910 "io"
1011 "io/ioutil"
@@ -14,17 +15,17 @@ import (
1415 "unsafe"
1516
1617 "github.com/containerd/console"
18+ "github.com/opencontainers/runtime-spec/specs-go"
19+ "github.com/sirupsen/logrus"
20+ "github.com/vishvananda/netlink"
21+ "golang.org/x/sys/unix"
22+
1723 "github.com/opencontainers/runc/libcontainer/capabilities"
1824 "github.com/opencontainers/runc/libcontainer/cgroups"
1925 "github.com/opencontainers/runc/libcontainer/configs"
2026 "github.com/opencontainers/runc/libcontainer/system"
2127 "github.com/opencontainers/runc/libcontainer/user"
2228 "github.com/opencontainers/runc/libcontainer/utils"
23- "github.com/opencontainers/runtime-spec/specs-go"
24- "github.com/pkg/errors"
25- "github.com/sirupsen/logrus"
26- "github.com/vishvananda/netlink"
27- "golang.org/x/sys/unix"
2829)
2930
3031type initType string
@@ -139,7 +140,7 @@ func finalizeNamespace(config *initConfig) error {
139140 // inherited are marked close-on-exec so they stay out of the
140141 // container
141142 if err := utils .CloseExecFrom (config .PassedFilesCount + 3 ); err != nil {
142- return errors . Wrap ( err , "close exec fds" )
143+ return fmt . Errorf ( "error closing exec fds: %w" , err )
143144 }
144145
145146 // we only do chdir if it's specified
@@ -174,14 +175,14 @@ func finalizeNamespace(config *initConfig) error {
174175 }
175176 // drop capabilities in bounding set before changing user
176177 if err := w .ApplyBoundingSet (); err != nil {
177- return errors . Wrap ( err , " apply bounding set" )
178+ return fmt . Errorf ( "unable to apply bounding set: %w" , err )
178179 }
179180 // preserve existing capabilities while we change users
180181 if err := system .SetKeepCaps (); err != nil {
181- return errors . Wrap ( err , " set keep caps" )
182+ return fmt . Errorf ( "unable to set keep caps: %w" , err )
182183 }
183184 if err := setupUser (config ); err != nil {
184- return errors . Wrap ( err , " setup user" )
185+ return fmt . Errorf ( "unable to setup user: %w" , err )
185186 }
186187 // Change working directory AFTER the user has been set up, if we haven't done it yet.
187188 if doChdir {
@@ -190,10 +191,10 @@ func finalizeNamespace(config *initConfig) error {
190191 }
191192 }
192193 if err := system .ClearKeepCaps (); err != nil {
193- return errors . Wrap ( err , " clear keep caps" )
194+ return fmt . Errorf ( "unable to clear keep caps: %w" , err )
194195 }
195196 if err := w .ApplyCaps (); err != nil {
196- return errors . Wrap ( err , " apply caps" )
197+ return fmt . Errorf ( "unable to apply caps: %w" , err )
197198 }
198199 return nil
199200}
0 commit comments