mirror of
https://github.com/containers/podman.git
synced 2025-10-28 11:55:06 +08:00
Update module github.com/cyphar/filepath-securejoin to v0.3.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
68
vendor/github.com/cyphar/filepath-securejoin/testing_mocks_linux.go
generated
vendored
Normal file
68
vendor/github.com/cyphar/filepath-securejoin/testing_mocks_linux.go
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
//go:build linux
|
||||
|
||||
// Copyright (C) 2024 SUSE LLC. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package securejoin
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type forceGetProcRootLevel int
|
||||
|
||||
const (
|
||||
forceGetProcRootDefault forceGetProcRootLevel = iota
|
||||
forceGetProcRootOpenTree // force open_tree()
|
||||
forceGetProcRootOpenTreeAtRecursive // force open_tree(AT_RECURSIVE)
|
||||
forceGetProcRootUnsafe // force open()
|
||||
)
|
||||
|
||||
var testingForceGetProcRoot *forceGetProcRootLevel
|
||||
|
||||
func testingCheckClose(check bool, f *os.File) bool {
|
||||
if check {
|
||||
if f != nil {
|
||||
_ = f.Close()
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func testingForcePrivateProcRootOpenTree(f *os.File) bool {
|
||||
return testing.Testing() && testingForceGetProcRoot != nil &&
|
||||
testingCheckClose(*testingForceGetProcRoot >= forceGetProcRootOpenTree, f)
|
||||
}
|
||||
|
||||
func testingForcePrivateProcRootOpenTreeAtRecursive(f *os.File) bool {
|
||||
return testing.Testing() && testingForceGetProcRoot != nil &&
|
||||
testingCheckClose(*testingForceGetProcRoot >= forceGetProcRootOpenTreeAtRecursive, f)
|
||||
}
|
||||
|
||||
func testingForceGetProcRootUnsafe(f *os.File) bool {
|
||||
return testing.Testing() && testingForceGetProcRoot != nil &&
|
||||
testingCheckClose(*testingForceGetProcRoot >= forceGetProcRootUnsafe, f)
|
||||
}
|
||||
|
||||
type forceProcThreadSelfLevel int
|
||||
|
||||
const (
|
||||
forceProcThreadSelfDefault forceProcThreadSelfLevel = iota
|
||||
forceProcSelfTask
|
||||
forceProcSelf
|
||||
)
|
||||
|
||||
var testingForceProcThreadSelf *forceProcThreadSelfLevel
|
||||
|
||||
func testingForceProcSelfTask() bool {
|
||||
return testing.Testing() && testingForceProcThreadSelf != nil &&
|
||||
*testingForceProcThreadSelf >= forceProcSelfTask
|
||||
}
|
||||
|
||||
func testingForceProcSelf() bool {
|
||||
return testing.Testing() && testingForceProcThreadSelf != nil &&
|
||||
*testingForceProcThreadSelf >= forceProcSelf
|
||||
}
|
||||
Reference in New Issue
Block a user