aboutsummaryrefslogtreecommitdiff
path: root/utils/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'utils/utils.go')
-rw-r--r--utils/utils.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/utils/utils.go b/utils/utils.go
index 095370a08..4c04b939d 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -2,10 +2,10 @@ package utils
import (
"bytes"
+ "crypto/rand"
"fmt"
"io"
"io/ioutil"
- "math/rand"
"os"
"os/exec"
"strconv"
@@ -204,9 +204,14 @@ func moveProcessToScope(pidPath, slice, scope string) error {
func MovePauseProcessToScope(pausePidPath string) {
var err error
- for i := 0; i < 3; i++ {
- r := rand.Int()
- err = moveProcessToScope(pausePidPath, "user.slice", fmt.Sprintf("podman-pause-%d.scope", r))
+ for i := 0; i < 10; i++ {
+ 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
}
@@ -224,3 +229,12 @@ func MovePauseProcessToScope(pausePidPath string) {
}
}
}
+
+// CreateSCPCommand takes an existing command, appends the given arguments and returns a configured podman command for image scp
+func CreateSCPCommand(cmd *exec.Cmd, command []string) *exec.Cmd {
+ cmd.Args = append(cmd.Args, command...)
+ cmd.Env = os.Environ()
+ cmd.Stderr = os.Stderr
+ cmd.Stdout = os.Stdout
+ return cmd
+}