mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-04 08:07:18 -04:00
Ensure libmutton.ini is created with 0600 permissions (on *nix)
This commit is contained in:
@@ -92,6 +92,7 @@ func WriteConfig(valuesToWrite [][3]string, keysToPrune [][2]string, append bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save to libmutton.ini
|
// save to libmutton.ini
|
||||||
|
setUmask(0077) // only give permissions to owner
|
||||||
err := cfg.SaveTo(global.ConfigPath)
|
err := cfg.SaveTo(global.ConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
back.PrintError("Failed to save libmutton.ini: "+err.Error(), back.ErrorWrite, true)
|
back.PrintError("Failed to save libmutton.ini: "+err.Error(), back.ErrorWrite, true)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package core
|
||||||
|
|
||||||
|
// setUmask is a dummy function on Windows.
|
||||||
|
func setUmask(umask int) {
|
||||||
|
return
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user