mirror of
https://github.com/containers/podman.git
synced 2025-06-17 15:08:08 +08:00
Fix race condition when listing /dev
Also replace os.IsNotExist(err) with errors.Is(err, fs.ErrNotExist) Fixes: https://github.com/containers/podman/issues/23582 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -84,7 +84,7 @@ func ParseDockerignore(containerfiles []string, root string) ([]string, string,
|
|||||||
// does not attempts to re-resolve it
|
// does not attempts to re-resolve it
|
||||||
ignoreFile = path
|
ignoreFile = path
|
||||||
ignore, dockerIgnoreErr = os.ReadFile(path)
|
ignore, dockerIgnoreErr = os.ReadFile(path)
|
||||||
if os.IsNotExist(dockerIgnoreErr) {
|
if errors.Is(dockerIgnoreErr, fs.ErrNotExist) {
|
||||||
// In this case either ignorefile was not found
|
// In this case either ignorefile was not found
|
||||||
// or it is a symlink to unexpected file in such
|
// or it is a symlink to unexpected file in such
|
||||||
// case manually set ignorefile to `/dev/null` so
|
// case manually set ignorefile to `/dev/null` so
|
||||||
|
@ -191,6 +191,9 @@ func getDevices(path string) ([]spec.LinuxDevice, error) {
|
|||||||
default:
|
default:
|
||||||
sub, err := getDevices(filepath.Join(path, f.Name()))
|
sub, err := getDevices(filepath.Join(path, f.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if sub != nil {
|
if sub != nil {
|
||||||
@ -209,7 +212,7 @@ func getDevices(path string) ([]spec.LinuxDevice, error) {
|
|||||||
if err == errNotADevice {
|
if err == errNotADevice {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if os.IsNotExist(err) {
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user