mirror of
https://github.com/containers/podman.git
synced 2025-06-23 18:59:30 +08:00
Merge pull request #5705 from rhatdan/reset
Cleanup whether to enter user namespace
This commit is contained in:
@ -11,7 +11,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/config"
|
"github.com/containers/common/pkg/config"
|
||||||
@ -192,7 +191,7 @@ func setupRootless(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Geteuid() == 0 || cmd == _searchCommand || cmd == _versionCommand || cmd == _mountCommand || cmd == _migrateCommand || strings.HasPrefix(cmd.Use, "help") {
|
if !executeCommandInUserNS(cmd) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +242,25 @@ func setupRootless(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Most podman commands when run in rootless mode, need to be executed in the
|
||||||
|
// users usernamespace. This function is updated with a list of commands that
|
||||||
|
// should NOT be run within the user namespace.
|
||||||
|
func executeCommandInUserNS(cmd *cobra.Command) bool {
|
||||||
|
if os.Geteuid() == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
switch cmd {
|
||||||
|
case _migrateCommand,
|
||||||
|
_mountCommand,
|
||||||
|
_renumberCommand,
|
||||||
|
_infoCommand,
|
||||||
|
_searchCommand,
|
||||||
|
_versionCommand:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func setRLimits() error {
|
func setRLimits() error {
|
||||||
rlimits := new(syscall.Rlimit)
|
rlimits := new(syscall.Rlimit)
|
||||||
rlimits.Cur = 1048576
|
rlimits.Cur = 1048576
|
||||||
|
Reference in New Issue
Block a user