vendor containers/psgo@v1.8.0

Signed-off-by: Piotr Resztak <piotr.resztak@gmail.com>
This commit is contained in:
Piotr Resztak
2022-10-12 23:05:28 +02:00
parent b712736bd2
commit 04c126a3b4
6 changed files with 57 additions and 5 deletions

2
go.mod
View File

@ -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

5
go.sum
View File

@ -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=

View File

@ -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() {

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.

2
vendor/modules.txt vendored
View File

@ -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