From 04c126a3b49e51b0b4b3dd4e8a8e53b8664710da Mon Sep 17 00:00:00 2001 From: Piotr Resztak Date: Wed, 12 Oct 2022 23:05:28 +0200 Subject: [PATCH] vendor containers/psgo@v1.8.0 Signed-off-by: Piotr Resztak --- go.mod | 2 +- go.sum | 5 ++-- test/e2e/top_test.go | 18 +++++++++++ vendor/github.com/containers/psgo/README.md | 2 ++ vendor/github.com/containers/psgo/psgo.go | 33 +++++++++++++++++++++ vendor/modules.txt | 2 +- 6 files changed, 57 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 7ddb7b68a8..ad78854df1 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/containers/conmon v2.0.20+incompatible github.com/containers/image/v5 v5.23.0 github.com/containers/ocicrypt v1.1.6 - github.com/containers/psgo v1.7.3 + github.com/containers/psgo v1.8.0 github.com/containers/storage v1.43.1-0.20221013143630-714f4fc6e80e github.com/coreos/go-systemd/v22 v22.4.0 github.com/coreos/stream-metadata-go v0.0.0-20210225230131-70edb9eb47b3 diff --git a/go.sum b/go.sum index c552e26b7f..da0e092a35 100644 --- a/go.sum +++ b/go.sum @@ -425,10 +425,9 @@ github.com/containers/ocicrypt v1.1.3/go.mod h1:xpdkbVAuaH3WzbEabUd5yDsl9SwJA5pA github.com/containers/ocicrypt v1.1.5/go.mod h1:WgjxPWdTJMqYMjf3M6cuIFFA1/MpyyhIM99YInA+Rvc= github.com/containers/ocicrypt v1.1.6 h1:uoG52u2e91RE4UqmBICZY8dNshgfvkdl3BW6jnxiFaI= github.com/containers/ocicrypt v1.1.6/go.mod h1:WgjxPWdTJMqYMjf3M6cuIFFA1/MpyyhIM99YInA+Rvc= -github.com/containers/psgo v1.7.3 h1:KTNurTMXpZjDJHWmlieVO7k7jgKJ4CR/HpPeSaAKtgc= -github.com/containers/psgo v1.7.3/go.mod h1:PfaNzzHmMb8M9/blPgyD4BB3ZEj/0ApZIxN6nNtA+t4= +github.com/containers/psgo v1.8.0 h1:2loGekmGAxM9ir5OsXWEfGwFxorMPYnc6gEDsGFQvhY= +github.com/containers/psgo v1.8.0/go.mod h1:T8ZxnX3Ur4RvnhxFJ7t8xJ1F48RhiZB4rSrOaR/qGHc= github.com/containers/storage v1.37.0/go.mod h1:kqeJeS0b7DO2ZT1nVWs0XufrmPFbgV3c+Q/45RlH6r4= -github.com/containers/storage v1.42.0/go.mod h1:JiUJwOgOo1dr2DdOUc1MRe2GCAXABYoYmOdPF8yvH78= github.com/containers/storage v1.43.0/go.mod h1:uZ147thiIFGdVTjMmIw19knttQnUCl3y9zjreHrg11s= github.com/containers/storage v1.43.1-0.20221013143630-714f4fc6e80e h1:uBtZPqpZetk6RYw115Rr+35UTvM93qltpdDLw7zFgvM= github.com/containers/storage v1.43.1-0.20221013143630-714f4fc6e80e/go.mod h1:K2qol6lCT/LRqZ3TMNRBU22tCTC6/Mb4G23K5SHhrYw= diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index 5f51742d16..e9b06dd685 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -2,6 +2,7 @@ package integration import ( "os" + "os/user" . "github.com/containers/podman/v4/test/utils" . "github.com/onsi/ginkgo" @@ -89,6 +90,23 @@ var _ = Describe("Podman top", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) + + result = podmanTest.Podman([]string{"container", "top", session.OutputToString(), "uid"}) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(0)) + Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) + Expect(result.OutputToStringArray()[1]).To(Equal("0")) + + user, err := user.Current() + if err != nil { + os.Exit(1) + } + + result = podmanTest.Podman([]string{"container", "top", session.OutputToString(), "huid"}) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(0)) + Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) + Expect(result.OutputToStringArray()[1]).To(Equal(user.Uid)) }) It("podman top with ps(1) options", func() { diff --git a/vendor/github.com/containers/psgo/README.md b/vendor/github.com/containers/psgo/README.md index 684c80a0c0..e54423ca78 100644 --- a/vendor/github.com/containers/psgo/README.md +++ b/vendor/github.com/containers/psgo/README.md @@ -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** diff --git a/vendor/github.com/containers/psgo/psgo.go b/vendor/github.com/containers/psgo/psgo.go index d6cfcef4dc..5c2c4d0b0b 100644 --- a/vendor/github.com/containers/psgo/psgo.go +++ b/vendor/github.com/containers/psgo/psgo.go @@ -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. diff --git a/vendor/modules.txt b/vendor/modules.txt index d4d0581629..474b63884e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -257,7 +257,7 @@ github.com/containers/ocicrypt/keywrap/pkcs7 github.com/containers/ocicrypt/spec github.com/containers/ocicrypt/utils github.com/containers/ocicrypt/utils/keyprovider -# github.com/containers/psgo v1.7.3 +# github.com/containers/psgo v1.8.0 ## explicit; go 1.14 github.com/containers/psgo github.com/containers/psgo/internal/capabilities