Fix Windows chown error (#28748)

* noop for windows chown

* changelog
This commit is contained in:
miagilepner
2024-10-22 14:57:26 +02:00
committed by GitHub
parent 9097689d2a
commit 4439ee8798
4 changed files with 18 additions and 1 deletions

6
changelog/28748.txt Normal file
View File

@@ -0,0 +1,6 @@
```release-note:bug
agent: Fix chown error running agent on Windows with an auto-auth file sinks.
```
```release-note:bug
proxy: Fix chown error running proxy on Windows with an auto-auth file sink.
```

View File

@@ -13,6 +13,7 @@ import (
hclog "github.com/hashicorp/go-hclog" hclog "github.com/hashicorp/go-hclog"
uuid "github.com/hashicorp/go-uuid" uuid "github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/command/agentproxyshared/sink" "github.com/hashicorp/vault/command/agentproxyshared/sink"
"github.com/hashicorp/vault/helper/osutil"
) )
// fileSink is a Sink implementation that writes a token to a file // fileSink is a Sink implementation that writes a token to a file
@@ -117,7 +118,7 @@ func (f *fileSink) WriteToken(token string) error {
return fmt.Errorf("error opening temp file in dir %s for writing: %w", targetDir, err) return fmt.Errorf("error opening temp file in dir %s for writing: %w", targetDir, err)
} }
if err := tmpFile.Chown(f.owner, f.group); err != nil { if err := osutil.Chown(tmpFile, f.owner, f.group); err != nil {
return fmt.Errorf("error changing ownership of %s: %w", tmpFile.Name(), err) return fmt.Errorf("error changing ownership of %s: %w", tmpFile.Name(), err)
} }

View File

@@ -8,6 +8,7 @@ package osutil
import ( import (
"fmt" "fmt"
"io/fs" "io/fs"
"os"
"os/user" "os/user"
"strconv" "strconv"
"syscall" "syscall"
@@ -59,3 +60,7 @@ func FileUidMatch(info fs.FileInfo, path string, uid int) (err error) {
func Umask(newmask int) int { func Umask(newmask int) int {
return syscall.Umask(newmask) return syscall.Umask(newmask)
} }
func Chown(f *os.File, owner, group int) error {
return f.Chown(owner, group)
}

View File

@@ -7,6 +7,7 @@ package osutil
import ( import (
"io/fs" "io/fs"
"os"
) )
func FileUidMatch(info fs.FileInfo, path string, uid int) error { func FileUidMatch(info fs.FileInfo, path string, uid int) error {
@@ -17,3 +18,7 @@ func FileUidMatch(info fs.FileInfo, path string, uid int) error {
func Umask(newmask int) int { func Umask(newmask int) int {
return 0 return 0
} }
func Chown(f *os.File, owner, group int) error {
return nil
}