mirror of
https://github.com/containers/podman.git
synced 2025-06-22 09:58:10 +08:00
Merge pull request #12610 from Luap99/cryptorand
MovePauseProcessToScope do not seed everytime
This commit is contained in:
@ -2,16 +2,15 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/containers/common/pkg/cgroups"
|
"github.com/containers/common/pkg/cgroups"
|
||||||
"github.com/containers/podman/v3/libpod/define"
|
"github.com/containers/podman/v3/libpod/define"
|
||||||
@ -205,10 +204,14 @@ func moveProcessToScope(pidPath, slice, scope string) error {
|
|||||||
func MovePauseProcessToScope(pausePidPath string) {
|
func MovePauseProcessToScope(pausePidPath string) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
state := rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
r := state.Int()
|
randBytes := make([]byte, 4)
|
||||||
err = moveProcessToScope(pausePidPath, "user.slice", fmt.Sprintf("podman-pause-%d.scope", r))
|
_, err = rand.Read(randBytes)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("failed to read random bytes: %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
err = moveProcessToScope(pausePidPath, "user.slice", fmt.Sprintf("podman-pause-%x.scope", randBytes))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user