(ctx context.Context, console bool, stdioFDs []*fd.FD, passFDs []fdMapping, user specs.User, containerName string)
| 2004 | } |
| 2005 | |
| 2006 | func createFDTable(ctx context.Context, console bool, stdioFDs []*fd.FD, passFDs []fdMapping, user specs.User, containerName string) (*kernel.FDTable, *host.TTYFileDescription, error) { |
| 2007 | if len(stdioFDs) != 3 { |
| 2008 | return nil, nil, fmt.Errorf("stdioFDs should contain exactly 3 FDs (stdin, stdout, and stderr), but %d FDs received", len(stdioFDs)) |
| 2009 | } |
| 2010 | fdMap := map[int]*fd.FD{ |
| 2011 | 0: stdioFDs[0], |
| 2012 | 1: stdioFDs[1], |
| 2013 | 2: stdioFDs[2], |
| 2014 | } |
| 2015 | |
| 2016 | // Create the entries for the host files that were passed to our app. |
| 2017 | for _, customFD := range passFDs { |
| 2018 | if customFD.guest < 0 { |
| 2019 | return nil, nil, fmt.Errorf("guest file descriptors must be 0 or greater") |
| 2020 | } |
| 2021 | fdMap[customFD.guest] = customFD.host |
| 2022 | } |
| 2023 | |
| 2024 | k := kernel.KernelFromContext(ctx) |
| 2025 | fdTable := k.NewFDTable() |
| 2026 | opts := fdimport.ImportOptions{ |
| 2027 | Console: console, |
| 2028 | Restorable: true, |
| 2029 | UID: auth.KUID(user.UID), |
| 2030 | GID: auth.KGID(user.GID), |
| 2031 | ContainerName: containerName, |
| 2032 | SupportTTYs: true, |
| 2033 | } |
| 2034 | ttyFile, err := fdimport.Import(ctx, fdTable, fdMap, opts) |
| 2035 | if err != nil { |
| 2036 | fdTable.DecRef(ctx) |
| 2037 | return nil, nil, err |
| 2038 | } |
| 2039 | return fdTable, ttyFile, nil |
| 2040 | } |
| 2041 | |
| 2042 | // portForward implements initiating a portForward connection in the sandbox. portForwardProxies |
| 2043 | // represent a two connections each copying to each other (read ends to write ends) in goroutines. |
no test coverage detected
searching dependent graphs…