testutil/daemon: shorten XDG_RUNTIME_DIR

XDG_RUNTIME_DIR will contain sockets so its path mustn't be too long.
Prior to this commit, it was set to very long path like
`/go/src/github.com/docker/docker/bundles/test-integration/TestDiskUsage/de4fb36576d7d/xdgrun`

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2024-01-17 22:45:03 +09:00
parent af4f6c124d
commit ae9fbcb82c
No known key found for this signature in database
GPG key ID: 49524C6F9F638F1A

View file

@ -174,7 +174,9 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
if err := os.Chown(d.execRoot, uid, gid); err != nil {
return nil, err
}
d.rootlessXDGRuntimeDir = filepath.Join(d.Folder, "xdgrun")
// $XDG_RUNTIME_DIR mustn't be too long, as ${XDG_RUNTIME_DIR/dockerd-rootless
// contains Unix sockets
d.rootlessXDGRuntimeDir = filepath.Join(os.TempDir(), "xdgrun-"+id)
if err := os.MkdirAll(d.rootlessXDGRuntimeDir, 0o700); err != nil {
return nil, err
}