Fix handling of overridden paths from database

If the first time you run podman in a user account you do a
su - USER, and the second time, you run as the logged in USER
podman fails, because it is not handling the tmpdir definition
in the database. This PR fixes this problem.

vendor containers/common v0.11.1

This should fix a couple of issues we have seen in podman 1.9.1
with handling of libpod.conf.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2020-05-08 08:37:14 -04:00
parent ff1c59065e
commit 5cbb0b8a66
16 changed files with 220 additions and 32 deletions

View File

@ -34,9 +34,32 @@ func CheckAuthFile(authfile string) error {
return nil
}
// systemContextWithOptions returns a version of sys
// updated with authFile and certDir values (if they are not "").
// NOTE: this is a shallow copy that can be used and updated, but may share
// data with the original parameter.
func systemContextWithOptions(sys *types.SystemContext, authFile, certDir string) *types.SystemContext {
if sys != nil {
copy := *sys
sys = &copy
} else {
sys = &types.SystemContext{}
}
if authFile != "" {
sys.AuthFilePath = authFile
}
if certDir != "" {
sys.DockerCertPath = certDir
}
return sys
}
// Login implements a “log in” command with the provided opts and args
// reading the password from opts.Stdin or the options in opts.
func Login(ctx context.Context, systemContext *types.SystemContext, opts *LoginOptions, args []string) error {
systemContext = systemContextWithOptions(systemContext, opts.AuthFile, opts.CertDir)
var (
server string
err error
@ -172,6 +195,11 @@ func getUserAndPass(opts *LoginOptions, password, userFromAuthFile string) (stri
// Logout implements a “log out” command with the provided opts and args
func Logout(systemContext *types.SystemContext, opts *LogoutOptions, args []string) error {
if err := CheckAuthFile(opts.AuthFile); err != nil {
return err
}
systemContext = systemContextWithOptions(systemContext, opts.AuthFile, "")
var (
server string
err error
@ -194,9 +222,6 @@ func Logout(systemContext *types.SystemContext, opts *LogoutOptions, args []stri
}
server = getRegistryName(args[0])
}
if err := CheckAuthFile(opts.AuthFile); err != nil {
return err
}
if opts.All {
if err := config.RemoveAllAuthentication(systemContext); err != nil {