mirror of
https://github.com/safing/portmaster
synced 2025-09-13 08:19:41 +00:00
Fix file permissions on windows (#1758)
* [service] Set file permissions on windows * [service] Fix minor windows permission bugs * [service] Fix permission bugs * [service] Fix windows non admin user start
This commit is contained in:
parent
ca88c6d8ad
commit
943b9b7859
9 changed files with 52 additions and 13 deletions
|
@ -1,6 +1,11 @@
|
|||
package renameio
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/hectane/go-acl"
|
||||
)
|
||||
|
||||
// WriteFile mirrors os.WriteFile, replacing an existing file with the same
|
||||
// name atomically.
|
||||
|
@ -14,7 +19,12 @@ func WriteFile(filename string, data []byte, perm os.FileMode) error {
|
|||
}()
|
||||
|
||||
// Set permissions before writing data, in case the data is sensitive.
|
||||
if err := t.Chmod(perm); err != nil {
|
||||
if runtime.GOOS == "windows" {
|
||||
err = acl.Chmod(t.path, perm)
|
||||
} else {
|
||||
err = t.Chmod(perm)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue