mirror of
https://git.vectorsigma.ru/public/AdGuardHome.git
synced 2026-08-03 18:29:39 +00:00
Pull request 2456: 7985-fix-contol-profile
Updates #7985. Squashed commit of the following: commit 1d5a3e66cc046ac8be6c0ebe7f5e06bc3e2a5e72 Merge:bdc76b1b152398e27eAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Aug 28 19:05:51 2025 +0300 Merge branch 'master' into 7985-fix-contol-profile commitbdc76b1b10Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Aug 26 15:47:07 2025 +0300 home: imp code commitaef012ed02Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Aug 26 13:14:39 2025 +0300 home: add tests commit799e8b49a1Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Aug 25 16:59:06 2025 +0300 all: fix control profile
This commit is contained in:
@@ -629,8 +629,8 @@ func validateBindHosts(conf *configuration) (err error) {
|
||||
}
|
||||
|
||||
// parseConfig loads configuration from the YAML file, upgrading it if
|
||||
// necessary.
|
||||
func parseConfig() (err error) {
|
||||
// necessary. l must not be nil.
|
||||
func parseConfig(ctx context.Context, l *slog.Logger) (err error) {
|
||||
// Do the upgrade if necessary.
|
||||
config.fileData, err = readConfigFile()
|
||||
if err != nil {
|
||||
@@ -652,7 +652,7 @@ func parseConfig() (err error) {
|
||||
return err
|
||||
} else if upgraded {
|
||||
confPath := configFilePath()
|
||||
log.Debug("writing config file %q after config upgrade", confPath)
|
||||
l.DebugContext(ctx, "writing config file after config upgrade", "path", confPath)
|
||||
|
||||
err = maybe.WriteFile(confPath, config.fileData, aghos.DefaultPermFile)
|
||||
if err != nil {
|
||||
@@ -666,7 +666,7 @@ func parseConfig() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validateConfig()
|
||||
err = validateConfig(ctx, l)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -679,8 +679,9 @@ func parseConfig() (err error) {
|
||||
return validateTLSCipherIDs(config.TLS.OverrideTLSCiphers)
|
||||
}
|
||||
|
||||
// validateConfig returns error if the configuration is invalid.
|
||||
func validateConfig() (err error) {
|
||||
// validateConfig returns error if the configuration is invalid. l must not be
|
||||
// nil.
|
||||
func validateConfig(ctx context.Context, l *slog.Logger) (err error) {
|
||||
err = validateBindHosts(config)
|
||||
if err != nil {
|
||||
// Don't wrap the error since it's informative enough as is.
|
||||
@@ -716,6 +717,10 @@ func validateConfig() (err error) {
|
||||
config.Filtering.FiltersUpdateIntervalHours = 24
|
||||
}
|
||||
|
||||
if len(config.Users) == 0 {
|
||||
l.WarnContext(ctx, "no users in the configuration file; authentication is disabled")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user