mirror of
https://github.com/containers/podman.git
synced 2025-12-05 04:40:47 +08:00
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
25 lines
522 B
Go
25 lines
522 B
Go
package proc
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
// ParsePIDNamespace returns the content of /proc/$pid/ns/pid.
|
|
func ParsePIDNamespace(pid string) (string, error) {
|
|
pidNS, err := os.Readlink(fmt.Sprintf("/proc/%s/ns/pid", pid))
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return pidNS, nil
|
|
}
|
|
|
|
// ParseUserNamespace returns the content of /proc/$pid/ns/user.
|
|
func ParseUserNamespace(pid string) (string, error) {
|
|
userNS, err := os.Readlink(fmt.Sprintf("/proc/%s/ns/user", pid))
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return userNS, nil
|
|
}
|