mirror of
https://github.com/minio/minio.git
synced 2025-04-18 09:50:02 -04:00
fail if port is not accessible (#10616)
throw proper error when port is not accessible for the regular user, this is possibly a regression. ``` ERROR Unable to start the server: Insufficient permissions to use specified port > Please ensure MinIO binary has 'cap_net_bind_service=+ep' permissions HINT: Use 'sudo setcap cap_net_bind_service=+ep /path/to/minio' to provide sufficient permissions ```
This commit is contained in:
parent
98a08e1644
commit
e0cb814f3f
@ -19,7 +19,6 @@ package config
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net"
|
"net"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@ -111,18 +110,16 @@ func ErrorToErr(err error) Err {
|
|||||||
case *net.OpError:
|
case *net.OpError:
|
||||||
return ErrPortAccess(err).Msg("Insufficient permissions to use specified port")
|
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)
|
|
||||||
} else {
|
|
||||||
// Failed to identify what type of error this, return a simple UI error
|
|
||||||
return Err{msg: err.Error()}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Failed to identify what type of error this, return a simple UI error
|
||||||
|
return Err{msg: err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FmtError converts a fatal error message to a more clear error
|
// FmtError converts a fatal error message to a more clear error
|
||||||
// using some colors
|
// using some colors
|
||||||
func FmtError(introMsg string, err error, jsonFlag bool) string {
|
func FmtError(introMsg string, err error, jsonFlag bool) string {
|
||||||
|
|
||||||
renderedTxt := ""
|
renderedTxt := ""
|
||||||
uiErr := ErrorToErr(err)
|
uiErr := ErrorToErr(err)
|
||||||
// JSON print
|
// JSON print
|
||||||
|
@ -205,12 +205,6 @@ Example 1:
|
|||||||
`Use 'sudo setcap cap_net_bind_service=+ep /path/to/minio' to provide sufficient permissions`,
|
`Use 'sudo setcap cap_net_bind_service=+ep /path/to/minio' to provide sufficient permissions`,
|
||||||
)
|
)
|
||||||
|
|
||||||
ErrNoPermissionsToAccessDirFiles = newErrFn(
|
|
||||||
"Missing permissions to access the specified path",
|
|
||||||
"Please ensure the specified path can be accessed",
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
|
|
||||||
ErrSSLUnexpectedError = newErrFn(
|
ErrSSLUnexpectedError = newErrFn(
|
||||||
"Invalid TLS certificate",
|
"Invalid TLS certificate",
|
||||||
"Please check the content of your certificate data",
|
"Please check the content of your certificate data",
|
||||||
@ -247,12 +241,6 @@ Example 1:
|
|||||||
"",
|
"",
|
||||||
)
|
)
|
||||||
|
|
||||||
ErrUnexpectedDataContent = newErrFn(
|
|
||||||
"Unexpected data content",
|
|
||||||
"Please contact MinIO at https://slack.min.io",
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
|
|
||||||
ErrUnexpectedError = newErrFn(
|
ErrUnexpectedError = newErrFn(
|
||||||
"Unexpected error",
|
"Unexpected error",
|
||||||
"Please contact MinIO at https://slack.min.io",
|
"Please contact MinIO at https://slack.min.io",
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/minio/minio-go/v7/pkg/set"
|
"github.com/minio/minio-go/v7/pkg/set"
|
||||||
"github.com/minio/minio/cmd/config"
|
"github.com/minio/minio/cmd/config"
|
||||||
@ -199,9 +198,7 @@ func checkPortAvailability(host, port string) (err error) {
|
|||||||
if err = l.Close(); err != nil {
|
if err = l.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if errors.Is(err, syscall.EADDRINUSE) {
|
} else {
|
||||||
// As we got EADDRINUSE error, the port is in use by other process.
|
|
||||||
// Return the error.
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user