Skip to content

Commit

Permalink
argon2: Pass O_NOFOLLOW when opening the lock file
Browse files Browse the repository at this point in the history
I was going to also pass O_CLOEXEC, but the go runtime already does
this.
  • Loading branch information
chrisccoulson committed Jan 17, 2025
1 parent e094dfa commit a264de8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion argon2_out_of_process_support_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
"io"
"os"
"syscall"
"time"

"github.com/snapcore/secboot/internal/paths"
Expand Down Expand Up @@ -146,7 +147,7 @@ func acquireArgon2OutOfProcessHandlerSystemLock(timeout time.Duration) (release
}

// Attempt to open the lock file for writing.
lockFile, err = os.OpenFile(paths.Argon2OutOfProcessHandlerSystemLockPath, os.O_RDWR|os.O_CREATE, 0600)
lockFile, err = os.OpenFile(paths.Argon2OutOfProcessHandlerSystemLockPath, os.O_RDWR|os.O_CREATE|syscall.O_NOFOLLOW, 0600)
if err != nil {
// No error is expected here.
return nil, fmt.Errorf("cannot open lock file for writing: %w", err)
Expand Down

0 comments on commit a264de8

Please sign in to comment.