@@ -249,4 +249,89 @@ var _ = Describe("Podman start", func() {
249249 Expect (session1 ).Should (Exit (0 ))
250250 Expect (session1 .OutputToString ()).To (BeEquivalentTo (cid2 ))
251251 })
252+
253+ It ("podman start container does not set HOME to home of caller" , func () {
254+ home , err := os .UserHomeDir ()
255+ Expect (err ).ToNot (HaveOccurred ())
256+ session := podmanTest .Podman ([]string {"create" , "--userns" , "keep-id" , "--user" , "bin:bin" , "--volume" , fmt .Sprintf ("%s:%s:ro" , home , home ), ALPINE , "ls" })
257+ session .WaitWithDefaultTimeout ()
258+ Expect (session ).Should (Exit (0 ))
259+ cid := session .OutputToString ()
260+
261+ session = podmanTest .Podman ([]string {"start" , cid })
262+ session .WaitWithDefaultTimeout ()
263+ Expect (session ).Should (Exit (0 ))
264+
265+ session = podmanTest .Podman ([]string {"inspect" , cid , "--format" , "{{.Config.Env}}" })
266+ session .WaitWithDefaultTimeout ()
267+ Expect (session ).Should (Exit (0 ))
268+ env := session .OutputToString ()
269+ Expect (env ).To (ContainSubstring ("HOME" ))
270+ Expect (env ).ToNot (ContainSubstring (fmt .Sprintf ("HOME=%s" , home )))
271+
272+ session = podmanTest .Podman ([]string {"restart" , cid })
273+ session .WaitWithDefaultTimeout ()
274+ Expect (session ).Should (Exit (0 ))
275+
276+ session = podmanTest .Podman ([]string {"inspect" , cid , "--format" , "{{.Config.Env}}" })
277+ session .WaitWithDefaultTimeout ()
278+ Expect (session ).Should (Exit (0 ))
279+ env = session .OutputToString ()
280+ Expect (env ).To (ContainSubstring ("HOME" ))
281+ Expect (env ).ToNot (ContainSubstring (fmt .Sprintf ("HOME=%s" , home )))
282+ })
283+
284+ It ("podman start container sets HOME to home of execUser" , func () {
285+ session := podmanTest .Podman ([]string {"create" , "--userns" , "keep-id" , "--user" , "bin:bin" , ALPINE , "ls" })
286+ session .WaitWithDefaultTimeout ()
287+ Expect (session ).Should (Exit (0 ))
288+ cid := session .OutputToString ()
289+
290+ session = podmanTest .Podman ([]string {"start" , cid })
291+ session .WaitWithDefaultTimeout ()
292+ Expect (session ).Should (Exit (0 ))
293+
294+ session = podmanTest .Podman ([]string {"inspect" , cid , "--format" , "{{.Config.Env}}" })
295+ session .WaitWithDefaultTimeout ()
296+ Expect (session ).Should (Exit (0 ))
297+ env := session .OutputToString ()
298+ Expect (env ).To (ContainSubstring ("HOME=/bin" ))
299+
300+ session = podmanTest .Podman ([]string {"restart" , cid })
301+ session .WaitWithDefaultTimeout ()
302+ Expect (session ).Should (Exit (0 ))
303+
304+ session = podmanTest .Podman ([]string {"inspect" , cid , "--format" , "{{.Config.Env}}" })
305+ session .WaitWithDefaultTimeout ()
306+ Expect (session ).Should (Exit (0 ))
307+ env = session .OutputToString ()
308+ Expect (env ).To (ContainSubstring ("HOME=/bin" ))
309+ })
310+
311+ It ("podman start container retains the HOME env if present" , func () {
312+ session := podmanTest .Podman ([]string {"create" , "--userns" , "keep-id" , "--user" , "bin:bin" , "--env=HOME=/env/is/respected" , ALPINE , "ls" })
313+ session .WaitWithDefaultTimeout ()
314+ Expect (session ).Should (Exit (0 ))
315+ cid := session .OutputToString ()
316+
317+ session = podmanTest .Podman ([]string {"start" , cid })
318+ session .WaitWithDefaultTimeout ()
319+ Expect (session ).Should (Exit (0 ))
320+
321+ session = podmanTest .Podman ([]string {"inspect" , cid , "--format" , "{{.Config.Env}}" })
322+ session .WaitWithDefaultTimeout ()
323+ Expect (session ).Should (Exit (0 ))
324+ env := session .OutputToString ()
325+ Expect (env ).To (ContainSubstring ("HOME=/env/is/respected" ))
326+
327+ session = podmanTest .Podman ([]string {"restart" , cid })
328+ session .WaitWithDefaultTimeout ()
329+ Expect (session ).Should (Exit (0 ))
330+
331+ session = podmanTest .Podman ([]string {"inspect" , cid , "--format" , "{{.Config.Env}}" })
332+ session .WaitWithDefaultTimeout ()
333+ Expect (session ).Should (Exit (0 ))
334+ env = session .OutputToString ()
335+ Expect (env ).To (ContainSubstring ("HOME=/env/is/respected" ))
336+ })
252337})
0 commit comments