Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions internal/guest/runtime/hcsv2/uvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@ func (h *Host) CreateContainer(ctx context.Context, id string, settings *prot.VM
}()
}

// Export security policy as one of the process's environment variables so that application and sidecar
// containers can have access to it. The security policy is required by containers which need to extract
// init-time claims found in the security policy.
//
// We append the variable after the security policy enforcing logic completes so as to bypass it; the
// security policy variable cannot be included in the security policy as its value is not available
// security policy construction time.

if policyEnforcer, ok := (h.securityPolicyEnforcer).(*securitypolicy.StandardSecurityPolicyEnforcer); ok {
secPolicyEnv := fmt.Sprintf("SECURITY_POLICY=%s", policyEnforcer.EncodedSecurityPolicy)
settings.OCISpecification.Process.Env = append(settings.OCISpecification.Process.Env, secPolicyEnv)
}

// Create the BundlePath
if err := os.MkdirAll(settings.OCIBundlePath, 0700); err != nil {
return nil, errors.Wrapf(err, "failed to create OCIBundlePath: '%s'", settings.OCIBundlePath)
Expand Down