From d861edfc00a01ae23a864c1291aeabf1236c5667 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 3 Jan 2020 16:45:26 +0100 Subject: [PATCH] xl: Print the correct err msg when access to the backend is forbidden (#8735) minio server /data{1..4} shows an error about inability to bind a port, though the real problem is /data{1..4} cannot be created because of the lack of permissions. This commit fix the behavior. --- cmd/config/errors-utils.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/config/errors-utils.go b/cmd/config/errors-utils.go index c242db9df..301619608 100644 --- a/cmd/config/errors-utils.go +++ b/cmd/config/errors-utils.go @@ -20,7 +20,7 @@ import ( "errors" "fmt" "io" - "os" + "net" "syscall" "github.com/minio/minio/pkg/color" @@ -106,9 +106,11 @@ func ErrorToErr(err error) Err { // Show a generic message for known golang errors if errors.Is(err, syscall.EADDRINUSE) { return ErrPortAlreadyInUse(err).Msg("Specified port is already in use") - } else if errors.Is(err, syscall.EACCES) { - return ErrPortAccess(err).Msg("Insufficient permissions to use specified port") - } else if os.IsPermission(err) { + } else if errors.Is(err, syscall.EACCES) || errors.Is(err, syscall.EPERM) { + switch err.(type) { + case *net.OpError: + return ErrPortAccess(err).Msg("Insufficient permissions to use specified port") + } return ErrNoPermissionsToAccessDirFiles(err).Msg("Insufficient permissions to access path") } else if errors.Is(err, io.ErrUnexpectedEOF) { return ErrUnexpectedDataContent(err)