From 027d6ca6de3644414ee1f847d161184d027e4137 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 13 Nov 2018 10:11:39 +0100 Subject: rootless: create empty mounts.conf if it doesn't exist Signed-off-by: Giuseppe Scrivano --- pkg/secrets/secrets.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pkg') diff --git a/pkg/secrets/secrets.go b/pkg/secrets/secrets.go index 7208f53b7..242953609 100644 --- a/pkg/secrets/secrets.go +++ b/pkg/secrets/secrets.go @@ -149,6 +149,15 @@ func SecretMountsWithUIDGID(mountLabel, containerWorkingDir, mountFile, mountPre mountFiles = append(mountFiles, []string{OverrideMountsFile, DefaultMountsFile}...) if rootless.IsRootless() { mountFiles = append([]string{UserOverrideMountsFile}, mountFiles...) + _, err := os.Stat(UserOverrideMountsFile) + if err != nil && os.IsNotExist(err) { + os.MkdirAll(filepath.Dir(UserOverrideMountsFile), 0755) + if f, err := os.Create(UserOverrideMountsFile); err != nil { + logrus.Warnf("could not create file %s: %v", UserOverrideMountsFile, err) + } else { + f.Close() + } + } } } else { mountFiles = append(mountFiles, mountFile) -- cgit v1.2.3-54-g00ecf