Vendor in latest containers/psgo code

This fixes a couple of issues with podman top.

podman top --latest USER HUSER

Now shows you the User inside of the containers usernamespace as well as the user on the host.

podman top --latest capeff capbnd

Now has headings that differentiatiate between the Capabiltiies.  We also have support for
ambient capabilities.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1286
Approved by: vrothberg
This commit is contained in:
Daniel J Walsh
2018-08-16 12:10:23 -04:00
committed by Atomic Bot
parent d20f3a5146
commit 37e3f47ef3
7 changed files with 108 additions and 23 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/containers/psgo/internal/host"
"github.com/containers/psgo/internal/proc"
"github.com/containers/psgo/internal/types"
"github.com/opencontainers/runc/libcontainer/user"
"github.com/pkg/errors"
)
@ -61,13 +62,13 @@ func LookupUID(uid string) (string, error) {
// New returns a new Process with the specified pid and parses the relevant
// data from /proc and /dev.
func New(pid string) (*Process, error) {
func New(ctx *types.PsContext, pid string) (*Process, error) {
p := Process{Pid: pid}
if err := p.parseStat(); err != nil {
return nil, err
}
if err := p.parseStatus(); err != nil {
if err := p.parseStatus(ctx); err != nil {
return nil, err
}
if err := p.parseCmdLine(); err != nil {
@ -88,10 +89,10 @@ func New(pid string) (*Process, error) {
}
// FromPIDs creates a new Process for each pid.
func FromPIDs(pids []string) ([]*Process, error) {
func FromPIDs(ctx *types.PsContext, pids []string) ([]*Process, error) {
processes := []*Process{}
for _, pid := range pids {
p, err := New(pid)
p, err := New(ctx, pid)
if err != nil {
if os.IsNotExist(err) {
// proc parsing is racy
@ -116,8 +117,8 @@ func (p *Process) parseStat() error {
}
// parseStatus parses /proc/$pid/status.
func (p *Process) parseStatus() error {
s, err := proc.ParseStatus(p.Pid)
func (p *Process) parseStatus(ctx *types.PsContext) error {
s, err := proc.ParseStatus(ctx, p.Pid)
if err != nil {
return err
}
@ -135,7 +136,7 @@ func (p *Process) parseCmdLine() error {
return nil
}
// parsePIDNamespace parses all host-related data fields.
// parsePIDNamespace sets the PID namespace.
func (p *Process) parsePIDNamespace() error {
pidNS, err := proc.ParsePIDNamespace(p.Pid)
if err != nil {