mirror of
https://github.com/containers/podman.git
synced 2025-06-26 04:46:57 +08:00
rootless: check uid with Geteuid() instead of Getuid()
change the tests to use chroot to set a numeric UID/GID. Go syscall.Credential doesn't change the effective UID/GID of the process. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1372 Approved by: mheon
This commit is contained in:

committed by
Atomic Bot

parent
bdee681409
commit
807f6f8d8f
@ -10,7 +10,6 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -190,11 +189,13 @@ func (p *PodmanTest) PodmanAsUser(args []string, uid, gid uint32, env []string)
|
||||
} else {
|
||||
fmt.Printf("Running: (env: %v) %s %s\n", env, p.PodmanBinary, strings.Join(podmanOptions, " "))
|
||||
}
|
||||
command := exec.Command(p.PodmanBinary, podmanOptions...)
|
||||
var command *exec.Cmd
|
||||
|
||||
if uid != 0 || gid != 0 {
|
||||
command.SysProcAttr = &syscall.SysProcAttr{}
|
||||
command.SysProcAttr.Credential = &syscall.Credential{Uid: uid, Gid: gid}
|
||||
nsEnterOpts := append([]string{"--userspec", fmt.Sprintf("%d:%d", uid, gid), "/", p.PodmanBinary}, podmanOptions...)
|
||||
command = exec.Command("chroot", nsEnterOpts...)
|
||||
} else {
|
||||
command = exec.Command(p.PodmanBinary, podmanOptions...)
|
||||
}
|
||||
if env != nil {
|
||||
command.Env = env
|
||||
|
Reference in New Issue
Block a user