summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-12-16 20:19:50 +0100
committerGitHub <noreply@github.com>2021-12-16 20:19:50 +0100
commitbe6f9ce92186bca7cce2a0b89f82cb7c7e720029 (patch)
tree6518997ad63b2c54bcfbe5f4a7aee1faf2d58288
parent273da42af237dde44d34d215dfafa33f0b76d9ab (diff)
parent459e7841473d7b6343d29091ba98b43afbb0aa6c (diff)
downloadpodman-be6f9ce92186bca7cce2a0b89f82cb7c7e720029.tar.gz
podman-be6f9ce92186bca7cce2a0b89f82cb7c7e720029.tar.bz2
podman-be6f9ce92186bca7cce2a0b89f82cb7c7e720029.zip
Merge pull request #12610 from Luap99/cryptorand
MovePauseProcessToScope do not seed everytime
-rw-r--r--utils/utils.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/utils/utils.go b/utils/utils.go
index 241e361cd..45cec2c5f 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -2,16 +2,15 @@ package utils
import (
"bytes"
+ "crypto/rand"
"fmt"
"io"
"io/ioutil"
- "math/rand"
"os"
"os/exec"
"strconv"
"strings"
"sync"
- "time"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod/define"
@@ -205,10 +204,14 @@ func moveProcessToScope(pidPath, slice, scope string) error {
func MovePauseProcessToScope(pausePidPath string) {
var err error
- state := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < 10; i++ {
- r := state.Int()
- err = moveProcessToScope(pausePidPath, "user.slice", fmt.Sprintf("podman-pause-%d.scope", r))
+ randBytes := make([]byte, 4)
+ _, 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 {
return
}