[MM-51329] server/config: add validation for local mode socket file (#23180)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b2e0aa7088
Коммит
a496c14cc2
@@ -12,6 +12,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -3749,6 +3750,16 @@ func (s *ServiceSettings) isValid() *AppError {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.collapsed_threads.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// we check if file has a valid parent, the server will try to create the socket
|
||||
// file if it doesn't exist, but we need to be sure if the directory exist or not
|
||||
if *s.EnableLocalMode {
|
||||
parent := filepath.Dir(*s.LocalModeSocketLocation)
|
||||
_, err := os.Stat(parent)
|
||||
if err != nil {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.local_mode_socket.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user