summaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-06-30 15:44:14 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-07-07 08:34:31 -0400
commit6c6670f12a3e6b91c1ebb09e7d9e4f49f89dccc0 (patch)
tree466d433075c1e746d459184fb28fee1d96546e62 /libpod/container.go
parent1a93857acc4ee1e5a9213e2c22f12802d84cd277 (diff)
downloadpodman-6c6670f12a3e6b91c1ebb09e7d9e4f49f89dccc0.tar.gz
podman-6c6670f12a3e6b91c1ebb09e7d9e4f49f89dccc0.tar.bz2
podman-6c6670f12a3e6b91c1ebb09e7d9e4f49f89dccc0.zip
Add username to /etc/passwd inside of container if --userns keep-id
If I enter a continer with --userns keep-id, my UID will be present inside of the container, but most likely my user will not be defined. This patch will take information about the user and stick it into the container. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/libpod/container.go b/libpod/container.go
index fa90fef7a..f7abfb005 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -278,6 +278,9 @@ type ContainerConfig struct {
User string `json:"user,omitempty"`
// Additional groups to add
Groups []string `json:"groups,omitempty"`
+ // AddCurrentUserPasswdEntry indicates that the current user passwd entry
+ // should be added to the /etc/passwd within the container
+ AddCurrentUserPasswdEntry bool `json:"addCurrentUserPasswdEntry,omitempty"`
// Namespace Config
// IDs of container to share namespaces with
@@ -786,7 +789,10 @@ func (c *Container) Hostname() string {
// WorkingDir returns the containers working dir
func (c *Container) WorkingDir() string {
- return c.config.Spec.Process.Cwd
+ if c.config.Spec.Process != nil {
+ return c.config.Spec.Process.Cwd
+ }
+ return "/"
}
// State Accessors