mirror of
https://github.com/containers/podman.git
synced 2025-06-23 18:59:30 +08:00
Merge pull request #8205 from rhatdan/home
Only use container/storage/pkg/unshare.HomeDir()
This commit is contained in:
@ -444,10 +444,7 @@ func (r *ConmonOCIRuntime) startExec(c *Container, sessionID string, options *Ex
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
conmonEnv, extraFiles, err := r.configureConmonEnv(c, runtimeDir)
|
conmonEnv, extraFiles := r.configureConmonEnv(c, runtimeDir)
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var filesToClose []*os.File
|
var filesToClose []*os.File
|
||||||
if options.PreserveFDs > 0 {
|
if options.PreserveFDs > 0 {
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
"github.com/containers/podman/v2/pkg/rootless"
|
"github.com/containers/podman/v2/pkg/rootless"
|
||||||
"github.com/containers/podman/v2/pkg/util"
|
"github.com/containers/podman/v2/pkg/util"
|
||||||
"github.com/containers/podman/v2/utils"
|
"github.com/containers/podman/v2/utils"
|
||||||
|
"github.com/containers/storage/pkg/homedir"
|
||||||
pmount "github.com/containers/storage/pkg/mount"
|
pmount "github.com/containers/storage/pkg/mount"
|
||||||
"github.com/coreos/go-systemd/v22/activation"
|
"github.com/coreos/go-systemd/v22/activation"
|
||||||
"github.com/coreos/go-systemd/v22/daemon"
|
"github.com/coreos/go-systemd/v22/daemon"
|
||||||
@ -1065,10 +1066,7 @@ func (r *ConmonOCIRuntime) createOCIContainer(ctr *Container, restoreOptions *Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0, 1 and 2 are stdin, stdout and stderr
|
// 0, 1 and 2 are stdin, stdout and stderr
|
||||||
conmonEnv, envFiles, err := r.configureConmonEnv(ctr, runtimeDir)
|
conmonEnv, envFiles := r.configureConmonEnv(ctr, runtimeDir)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var filesToClose []*os.File
|
var filesToClose []*os.File
|
||||||
if ctr.config.PreserveFDs > 0 {
|
if ctr.config.PreserveFDs > 0 {
|
||||||
@ -1268,16 +1266,15 @@ func prepareProcessExec(c *Container, cmd, env []string, tty bool, cwd, user, se
|
|||||||
|
|
||||||
// configureConmonEnv gets the environment values to add to conmon's exec struct
|
// configureConmonEnv gets the environment values to add to conmon's exec struct
|
||||||
// TODO this may want to be less hardcoded/more configurable in the future
|
// TODO this may want to be less hardcoded/more configurable in the future
|
||||||
func (r *ConmonOCIRuntime) configureConmonEnv(ctr *Container, runtimeDir string) ([]string, []*os.File, error) {
|
func (r *ConmonOCIRuntime) configureConmonEnv(ctr *Container, runtimeDir string) ([]string, []*os.File) {
|
||||||
env := make([]string, 0, 6)
|
env := make([]string, 0, 6)
|
||||||
env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir))
|
env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir))
|
||||||
env = append(env, fmt.Sprintf("_CONTAINERS_USERNS_CONFIGURED=%s", os.Getenv("_CONTAINERS_USERNS_CONFIGURED")))
|
env = append(env, fmt.Sprintf("_CONTAINERS_USERNS_CONFIGURED=%s", os.Getenv("_CONTAINERS_USERNS_CONFIGURED")))
|
||||||
env = append(env, fmt.Sprintf("_CONTAINERS_ROOTLESS_UID=%s", os.Getenv("_CONTAINERS_ROOTLESS_UID")))
|
env = append(env, fmt.Sprintf("_CONTAINERS_ROOTLESS_UID=%s", os.Getenv("_CONTAINERS_ROOTLESS_UID")))
|
||||||
home, err := util.HomeDir()
|
home := homedir.Get()
|
||||||
if err != nil {
|
if home != "" {
|
||||||
return nil, nil, err
|
env = append(env, fmt.Sprintf("HOME=%s", home))
|
||||||
}
|
}
|
||||||
env = append(env, fmt.Sprintf("HOME=%s", home))
|
|
||||||
|
|
||||||
extraFiles := make([]*os.File, 0)
|
extraFiles := make([]*os.File, 0)
|
||||||
if ctr.config.SdNotifyMode == define.SdNotifyModeContainer {
|
if ctr.config.SdNotifyMode == define.SdNotifyModeContainer {
|
||||||
@ -1294,7 +1291,7 @@ func (r *ConmonOCIRuntime) configureConmonEnv(ctr *Container, runtimeDir string)
|
|||||||
} else {
|
} else {
|
||||||
logrus.Debug("disabling SD notify")
|
logrus.Debug("disabling SD notify")
|
||||||
}
|
}
|
||||||
return env, extraFiles, nil
|
return env, extraFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
// sharedConmonArgs takes common arguments for exec and create/restore and formats them for the conmon CLI
|
// sharedConmonArgs takes common arguments for exec and create/restore and formats them for the conmon CLI
|
||||||
|
Reference in New Issue
Block a user