summaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
authorDoug Rabson <dfr@rabson.org>2022-08-31 18:02:38 +0100
committerDoug Rabson <dfr@rabson.org>2022-09-01 10:27:04 +0100
commitb667d7340c1717720216ebdb1c62052006e7ac5f (patch)
tree38e43cf9687bad09cc846960967c29b8f6679ee0 /libpod/runtime.go
parent72f4c77139adf61bc39890e08ed9b86c365ae09b (diff)
downloadpodman-b667d7340c1717720216ebdb1c62052006e7ac5f.tar.gz
podman-b667d7340c1717720216ebdb1c62052006e7ac5f.tar.bz2
podman-b667d7340c1717720216ebdb1c62052006e7ac5f.zip
libpod: Ensure that generated container names are random
Fixes #15569. Signed-off-by: Doug Rabson <dfr@rabson.org>
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 9b97fd724..1503b2344 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
+ "math/rand"
"os"
"path/filepath"
"strings"
@@ -112,6 +113,13 @@ type Runtime struct {
secretsManager *secrets.SecretsManager
}
+func init() {
+ // generateName calls namesgenerator.GetRandomName which the
+ // global RNG from math/rand. Seed it here to make sure we
+ // don't get the same name every time.
+ rand.Seed(time.Now().UnixNano())
+}
+
// SetXdgDirs ensures the XDG_RUNTIME_DIR env and XDG_CONFIG_HOME variables are set.
// containers/image uses XDG_RUNTIME_DIR to locate the auth file, XDG_CONFIG_HOME is
// use for the containers.conf configuration file.