Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Sohan Kunkerkar <sohank2602@gmail.com>
  • Loading branch information
sohankunkerkar committed Apr 18, 2024
1 parent bc14210 commit f6c46db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ linters-settings:
# - filepathJoin
# - whyNoLint
gocyclo:
min-complexity: 165
min-complexity: 170
nakedret:
max-func-lines: 15
goconst:
Expand Down
25 changes: 17 additions & 8 deletions server/container_create_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,16 +758,25 @@ func (s *Server) createSandboxContainer(ctx context.Context, ctr ctrfactory.Cont
ctr.DisableFips(),
)
if ctr.DisableFips() {
// Add a mount to override and disable the crypto.fips_enabled sysctl inside the container
options := []string{"noexec", "nosuid", "nodev", "ro"}
sysctlData := []byte("0\n")
sysctlMount := rspec.Mount{
// Create a temporary file to store the value to be written to /proc/sys/crypto/fips_enabled
tmpFile, err := os.CreateTemp("", "tmpfips-")
if err != nil {
return nil, err
}
defer os.Remove(tmpFile.Name())

// Write the value to the temporary file
if _, err := tmpFile.WriteString("0\n"); err != nil {
return nil, err
}

// Create the tmpfs mount
secretMounts = append(secretMounts, rspec.Mount{
Destination: "/proc/sys/crypto/fips_enabled",
Source: "tmpfs",
Source: tmpFile.Name(),
Type: "tmpfs",
Options: append(options, fmt.Sprintf("mode=0644,data=%s", sysctlData)),
}
secretMounts = append(secretMounts, sysctlMount)
Options: []string{"noexec", "nosuid", "nodev", "ro"},
})
}

mounts := []rspec.Mount{}
Expand Down

0 comments on commit f6c46db

Please sign in to comment.