mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
runc list: use standard os/user
Switch from github.com/moby/sys/user to Go stdlib os/user (which has both libc-backed and pure Go implementations). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -5,11 +5,12 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/moby/sys/user"
|
|
||||||
"github.com/opencontainers/runc/libcontainer"
|
"github.com/opencontainers/runc/libcontainer"
|
||||||
"github.com/opencontainers/runc/libcontainer/utils"
|
"github.com/opencontainers/runc/libcontainer/utils"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
@@ -136,9 +137,10 @@ func getContainers(context *cli.Context) ([]containerState, error) {
|
|||||||
}
|
}
|
||||||
// This cast is safe on Linux.
|
// This cast is safe on Linux.
|
||||||
uid := st.Sys().(*syscall.Stat_t).Uid
|
uid := st.Sys().(*syscall.Stat_t).Uid
|
||||||
owner, err := user.LookupUid(int(uid))
|
owner := "#" + strconv.Itoa(int(uid))
|
||||||
if err != nil {
|
u, err := user.LookupId(owner[1:])
|
||||||
owner.Name = fmt.Sprintf("#%d", uid)
|
if err == nil {
|
||||||
|
owner = u.Username
|
||||||
}
|
}
|
||||||
|
|
||||||
container, err := libcontainer.Load(root, item.Name())
|
container, err := libcontainer.Load(root, item.Name())
|
||||||
@@ -170,7 +172,7 @@ func getContainers(context *cli.Context) ([]containerState, error) {
|
|||||||
Rootfs: state.BaseState.Config.Rootfs,
|
Rootfs: state.BaseState.Config.Rootfs,
|
||||||
Created: state.BaseState.Created,
|
Created: state.BaseState.Created,
|
||||||
Annotations: annotations,
|
Annotations: annotations,
|
||||||
Owner: owner.Name,
|
Owner: owner,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return s, nil
|
return s, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user