fix: replace syscall.O_NOFOLLOW with utils.OpenFileSecure for Windows (pull/5764) (#5776)

This commit is contained in:
Dennis Mwangi
2025-04-28 13:41:00 +03:00
committed by GitHub
parent 6c8515fe36
commit 5d5a166efd
5 changed files with 14 additions and 18 deletions

View File

@@ -26,12 +26,11 @@ package yaml
import (
"errors"
"fmt"
"github.com/beego/beego/v2/core/utils"
"gopkg.in/yaml.v3"
"os"
"strings"
"sync"
"syscall"
"gopkg.in/yaml.v3"
"github.com/beego/beego/v2/core/config"
"github.com/beego/beego/v2/core/logs"
@@ -292,7 +291,7 @@ func (c *ConfigContainer) GetSection(section string) (map[string]string, error)
// SaveConfigFile save the config into file
func (c *ConfigContainer) SaveConfigFile(filename string) (err error) {
// Write configuration file by filename.
f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|syscall.O_NOFOLLOW, 0600)
f, err := utils.OpenFileSecure(filename, os.O_RDWR|os.O_CREATE, 0600)
if err != nil {
return err
}