Skip to content

Commit be310b9

Browse files
committed
use same dir as dst to avoid invalid cross-device links
1 parent 0e32285 commit be310b9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libbeat/cmd/instance/beat.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"net"
2828
"os"
2929
"os/user"
30+
"path/filepath"
3031
"runtime"
3132
"runtime/debug"
3233
"strconv"
@@ -978,8 +979,8 @@ func (b *Beat) LoadMeta(metaPath string) error {
978979

979980
// file does not exist or ID is invalid or first start time is not defined, let's create a new one
980981

981-
// write temporary file first
982-
tmpFile, err := os.CreateTemp("", "beat_meta")
982+
// write temporary file first, use same dir as destination to avoid invalid cross-device links
983+
tmpFile, err := os.CreateTemp(filepath.Dir(metaPath), "new")
983984
if err != nil {
984985
return fmt.Errorf("failed to create temporary Beat meta file: %w", err)
985986
}

0 commit comments

Comments
 (0)