lib/config, gui: Disallow some options in combination with "untrusted" (fixes #8920) (#8921)

This prevents combining untrusted with introducer and auto-accept, and
also verifies that folders shared with untrusted devices have passwords
at config loading time.

Co-authored-by: Simon Frei <freisim93@gmail.com>
This commit is contained in:
Jakob Borg
2023-06-14 09:24:31 +02:00
committed by GitHub
co-authored by Simon Frei
parent 7d56fba321
commit 6b475bdb78
8 changed files with 143 additions and 16 deletions
+13
View File
@@ -34,6 +34,19 @@ func (cfg *DeviceConfiguration) prepare(sharedFolders []string) {
}
cfg.IgnoredFolders = sortedObservedFolderSlice(ignoredFolders)
// A device cannot be simultaneously untrusted and an introducer, nor
// auto accept folders.
if cfg.Untrusted {
if cfg.Introducer {
l.Warnf("Device %s (%s) is both untrusted and an introducer, removing introducer flag", cfg.DeviceID.Short(), cfg.Name)
cfg.Introducer = false
}
if cfg.AutoAcceptFolders {
l.Warnf("Device %s (%s) is both untrusted and auto-accepting folders, removing auto-accept flag", cfg.DeviceID.Short(), cfg.Name)
cfg.AutoAcceptFolders = false
}
}
}
func (cfg *DeviceConfiguration) IgnoredFolder(folder string) bool {