diff --git a/core/configParser.go b/core/configParser.go index a041215..8a62b78 100644 --- a/core/configParser.go +++ b/core/configParser.go @@ -92,6 +92,7 @@ func WriteConfig(valuesToWrite [][3]string, keysToPrune [][2]string, append bool } // save to libmutton.ini + setUmask(0077) // only give permissions to owner err := cfg.SaveTo(global.ConfigPath) if err != nil { back.PrintError("Failed to save libmutton.ini: "+err.Error(), back.ErrorWrite, true) diff --git a/core/utilitiesUNIX.go b/core/utilitiesUNIX.go new file mode 100644 index 0000000..6bb17d7 --- /dev/null +++ b/core/utilitiesUNIX.go @@ -0,0 +1,12 @@ +//go:build !windows + +package core + +import "syscall" + +// setUmask sets the file mode creation mask (umask) for the current process. +// The call to syscall.Umask needs to be embedded in another function to allow +// compilation on Windows. +func setUmask(umask int) { + syscall.Umask(umask) +} diff --git a/core/utilitiesWIN.go b/core/utilitiesWIN.go new file mode 100644 index 0000000..f79f771 --- /dev/null +++ b/core/utilitiesWIN.go @@ -0,0 +1,8 @@ +//go:build windows + +package core + +// setUmask is a dummy function on Windows. +func setUmask(umask int) { + return +}