mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
fix: log if there is readDir() failure with ListBuckets (#15461)
This is actionable and must be logged. Bonus: also honor umask by using 0o666 for all Open() syscalls.
This commit is contained in:
@@ -152,12 +152,24 @@ func parseDirEnt(buf []byte) (consumed int, name []byte, typ os.FileMode, err er
|
||||
// the directory itself, if the dirPath doesn't exist this function doesn't return
|
||||
// an error.
|
||||
func readDirFn(dirPath string, fn func(name string, typ os.FileMode) error) error {
|
||||
f, err := Open(dirPath)
|
||||
f, err := OpenFile(dirPath, readMode, 0o666)
|
||||
if err != nil {
|
||||
if osErrToFileErr(err) == errFileNotFound {
|
||||
return nil
|
||||
}
|
||||
return osErrToFileErr(err)
|
||||
if !osIsPermission(err) {
|
||||
return osErrToFileErr(err)
|
||||
}
|
||||
// There may be permission error when dirPath
|
||||
// is at the root of the disk mount that may
|
||||
// not have the permissions to avoid 'noatime'
|
||||
f, err = Open(dirPath)
|
||||
if err != nil {
|
||||
if osErrToFileErr(err) == errFileNotFound {
|
||||
return nil
|
||||
}
|
||||
return osErrToFileErr(err)
|
||||
}
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
@@ -234,12 +246,14 @@ func readDirFn(dirPath string, fn func(name string, typ os.FileMode) error) erro
|
||||
func readDirWithOpts(dirPath string, opts readDirOpts) (entries []string, err error) {
|
||||
f, err := OpenFile(dirPath, readMode, 0o666)
|
||||
if err != nil {
|
||||
if osIsPermission(err) {
|
||||
f, err = Open(dirPath)
|
||||
if err != nil {
|
||||
return nil, osErrToFileErr(err)
|
||||
}
|
||||
} else {
|
||||
if !osIsPermission(err) {
|
||||
return nil, osErrToFileErr(err)
|
||||
}
|
||||
// There may be permission error when dirPath
|
||||
// is at the root of the disk mount that may
|
||||
// not have the permissions to avoid 'noatime'
|
||||
f, err = Open(dirPath)
|
||||
if err != nil {
|
||||
return nil, osErrToFileErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user