Currently calls to unshare.HomeDir() cache the result and return the same thing over and over. It was added in containers/storage#669 for performance reasons though it is not clear to me how much this actually safes in practise? Are we really calling this on a hot path were we would need to get the home dir over and over? I really doubt that.
Also I assume the vast majority cases uses the $HOME env so the lookup there should be fast enough IMO, the user db fallback might be slower but since that is the not common case I do not think it matters much.
The reason the cache is problematic is at least for tests who set a custom $HOME, I have been surprised more than once of this behavior and it requires additional test work around often. The latest thing where this took me extra time to understand what is wrong was in containers/podman#28573 as machine test also use a custom per test $HOME.
Currently calls to unshare.HomeDir() cache the result and return the same thing over and over. It was added in containers/storage#669 for performance reasons though it is not clear to me how much this actually safes in practise? Are we really calling this on a hot path were we would need to get the home dir over and over? I really doubt that.
Also I assume the vast majority cases uses the $HOME env so the lookup there should be fast enough IMO, the user db fallback might be slower but since that is the not common case I do not think it matters much.
The reason the cache is problematic is at least for tests who set a custom $HOME, I have been surprised more than once of this behavior and it requires additional test work around often. The latest thing where this took me extra time to understand what is wrong was in containers/podman#28573 as machine test also use a custom per test $HOME.