aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2023-05-12 20:52:49 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2023-05-12 20:52:49 +0200
commit273e14dda135a58b834a5a8dc005f0c26f3711e7 (patch)
tree8cec9ebebfffa7df06fd4ee73e680c6e090c93c7 /pkg
parent68d6aafae84de72563199f80e3906bfbad3cd6c5 (diff)
downloadfeed2imap-go-273e14dda135a58b834a5a8dc005f0c26f3711e7.tar.gz
feed2imap-go-273e14dda135a58b834a5a8dc005f0c26f3711e7.tar.bz2
feed2imap-go-273e14dda135a58b834a5a8dc005f0c26f3711e7.zip
Issue #95 Add warning when config can be read globally.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/config/config.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
index a7c540f..0d2c944 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -125,6 +125,17 @@ func Load(path string) (*Config, error) {
return nil, fmt.Errorf("while opening '%s': %w", path, err)
}
+ defer f.Close()
+
+ stat, err := f.Stat()
+ if err != nil {
+ return nil, fmt.Errorf("while getting stats of '%s': %w", path, err)
+ }
+
+ if stat.Mode().Perm()&0004 != 0 {
+ log.Warnf("Config file '%s' can be read by anyone. As this contains your IMAP credentials, you are advised to remove global read access.", path)
+ }
+
cfg := WithDefault()
if err = cfg.parse(f); err != nil {
return nil, fmt.Errorf("while parsing: %w", err)