Merge pull request #16144 from presztak/vendor_psgo

vendor containers/psgo@v1.8.0
This commit is contained in:
OpenShift Merge Robot
2022-10-15 07:07:19 -04:00
committed by GitHub
6 changed files with 57 additions and 5 deletions

View File

@@ -83,6 +83,8 @@ The ps library is compatible with all AIX format descriptors of the ps command-l
- The corresponding host PID of a container process.
- **huser**
- The corresponding effective user of a container process on the host.
- **huid**
- The corresponding host UID of a container process.
- **label**
- Current security attributes of the process.
- **seccomp**

View File

@@ -181,6 +181,11 @@ var (
header: "USER",
procFn: processUSER,
},
{
normal: "uid",
header: "UID",
procFn: processUID,
},
{
code: "%a",
normal: "args",
@@ -294,6 +299,12 @@ var (
onHost: true,
procFn: processHUSER,
},
{
normal: "huid",
header: "HUID",
onHost: true,
procFn: processHUID,
},
{
normal: "hgroup",
header: "HGROUP",
@@ -648,6 +659,11 @@ func processUSER(p *process.Process, ctx *psContext) (string, error) {
return process.LookupUID(p.Status.Uids[1])
}
// processUID returns the effective UID of the process as the decimal representation.
func processUID(p *process.Process, ctx *psContext) (string, error) {
return p.Status.Uids[1], nil
}
// processRUSER returns the effective user name of the process. This will be
// the textual user ID, if it can be obtained, or a decimal representation
// otherwise.
@@ -857,6 +873,23 @@ func processHUSER(p *process.Process, ctx *psContext) (string, error) {
return "?", nil
}
// processHUID returns the effective UID of the corresponding host process
// of the (container) as the decimal representation or "?" if no corresponding
// process could be found.
func processHUID(p *process.Process, ctx *psContext) (string, error) {
if hp := findHostProcess(p, ctx); hp != nil {
if ctx.opts != nil && len(ctx.opts.UIDMap) > 0 {
// Return uid without searching its textual representation.
lookupFunc := func(uid string) (string, error) {
return uid, nil
}
return findID(hp.Status.Uids[1], ctx.opts.UIDMap, lookupFunc, "/proc/sys/fs/overflowuid")
}
return hp.Status.Uids[1], nil
}
return "?", nil
}
// processHGROUP returns the effective group ID of the corresponding host
// process of the (container) or "?" if no corresponding process could be
// found.