Ensure libmutton.ini is created with 0600 permissions (on *nix)

This commit is contained in:
2025-05-29 16:52:15 +00:00
parent fa6f057b49
commit 50ab27c674
3 changed files with 21 additions and 0 deletions
+1
View File
@@ -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)
+12
View File
@@ -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)
}
+8
View File
@@ -0,0 +1,8 @@
//go:build windows
package core
// setUmask is a dummy function on Windows.
func setUmask(umask int) {
return
}