summaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/filters/containers.go14
-rw-r--r--pkg/domain/infra/abi/system.go7
2 files changed, 19 insertions, 2 deletions
diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go
index 45791cd84..9ac72e415 100644
--- a/pkg/domain/filters/containers.go
+++ b/pkg/domain/filters/containers.go
@@ -83,7 +83,19 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo
return func(c *libpod.Container) bool {
for _, filterValue := range filterValues {
containerConfig := c.Config()
- if strings.Contains(containerConfig.RootfsImageID, filterValue) || strings.Contains(containerConfig.RootfsImageName, filterValue) {
+ var imageTag string
+ var imageNameWithoutTag string
+ // Compare with ImageID, ImageName
+ // Will match ImageName if running image has tag latest for other tags exact complete filter must be given
+ imageNameSlice := strings.SplitN(containerConfig.RootfsImageName, ":", 2)
+ if len(imageNameSlice) == 2 {
+ imageNameWithoutTag = imageNameSlice[0]
+ imageTag = imageNameSlice[1]
+ }
+
+ if (containerConfig.RootfsImageID == filterValue) ||
+ (containerConfig.RootfsImageName == filterValue) ||
+ (imageNameWithoutTag == filterValue && imageTag == "latest") {
return true
}
}
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index 6319c1ab1..9bba0fa6c 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -21,6 +21,7 @@ import (
"github.com/containers/podman/v3/pkg/util"
"github.com/containers/podman/v3/utils"
"github.com/containers/storage"
+ "github.com/containers/storage/pkg/unshare"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -58,7 +59,11 @@ func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) {
func (ic *ContainerEngine) SetupRootless(_ context.Context, cmd *cobra.Command) error {
// do it only after podman has already re-execed and running with uid==0.
- if os.Geteuid() == 0 {
+ hasCapSysAdmin, err := unshare.HasCapSysAdmin()
+ if err != nil {
+ return err
+ }
+ if hasCapSysAdmin {
ownsCgroup, err := cgroups.UserOwnsCurrentSystemdCgroup()
if err != nil {
logrus.Infof("Failed to detect the owner for the current cgroup: %v", err)