mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
podman: always call into SetupRootless
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:

committed by
Matthew Heon

parent
3b37095b2b
commit
7b4ebfa657
@ -18,7 +18,6 @@ import (
|
||||
"github.com/containers/podman/v4/libpod/define"
|
||||
"github.com/containers/podman/v4/libpod/events"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||
"github.com/containers/podman/v4/pkg/rootless"
|
||||
"github.com/containers/podman/v4/pkg/signal"
|
||||
systemdDefine "github.com/containers/podman/v4/pkg/systemd/define"
|
||||
"github.com/containers/podman/v4/pkg/util"
|
||||
@ -54,7 +53,7 @@ func setupContainerEngine(cmd *cobra.Command) (entities.ContainerEngine, error)
|
||||
cobra.CompErrorln(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
if !registry.IsRemote() && rootless.IsRootless() {
|
||||
if !registry.IsRemote() {
|
||||
_, noMoveProcess := cmd.Annotations[registry.NoMoveProcess]
|
||||
|
||||
err := containerEngine.SetupRootless(registry.Context(), noMoveProcess)
|
||||
|
@ -19,7 +19,6 @@ import (
|
||||
"github.com/containers/podman/v4/pkg/checkpoint/crutils"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||
"github.com/containers/podman/v4/pkg/parallel"
|
||||
"github.com/containers/podman/v4/pkg/rootless"
|
||||
"github.com/containers/podman/v4/version"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
@ -265,7 +264,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
|
||||
// 2) running as non-root
|
||||
// 3) command doesn't require Parent Namespace
|
||||
_, found := cmd.Annotations[registry.ParentNSRequired]
|
||||
if !registry.IsRemote() && rootless.IsRootless() && !found {
|
||||
if !registry.IsRemote() && !found {
|
||||
_, noMoveProcess := cmd.Annotations[registry.NoMoveProcess]
|
||||
err := registry.ContainerEngine().SetupRootless(registry.Context(), noMoveProcess)
|
||||
if err != nil {
|
||||
|
@ -67,6 +67,10 @@ func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) {
|
||||
}
|
||||
|
||||
func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool) error {
|
||||
if !rootless.IsRootless() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// do it only after podman has already re-execed and running with uid==0.
|
||||
hasCapSysAdmin, err := unshare.HasCapSysAdmin()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user