summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-09-06 14:01:59 +0200
committerGitHub <noreply@github.com>2019-09-06 14:01:59 +0200
commit24171ae060caacb32669f6aa263282ea52ff6201 (patch)
treed29fe529027675a6ebbcb8ea268c51d1d08ef10c /libpod
parent0d8a22496e3c7e3d44251bdbac194c55de141e2c (diff)
parent3a09956dff0d475e8b7e988a6fdcda59e242d297 (diff)
downloadpodman-24171ae060caacb32669f6aa263282ea52ff6201.tar.gz
podman-24171ae060caacb32669f6aa263282ea52ff6201.tar.bz2
podman-24171ae060caacb32669f6aa263282ea52ff6201.zip
Merge pull request #3954 from mheon/hardcode_default_storepaths
Ensure good defaults on blank c/storage configuration
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime.go25
1 files changed, 23 insertions, 2 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 28774773e..323a46266 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -281,10 +281,17 @@ func defaultRuntimeConfig() (RuntimeConfig, error) {
if err != nil {
return RuntimeConfig{}, err
}
+ graphRoot := storeOpts.GraphRoot
+ if graphRoot == "" {
+ logrus.Warnf("Storage configuration is unset - using hardcoded default paths")
+ graphRoot = "/var/lib/containers/storage"
+ }
+ volumePath := filepath.Join(graphRoot, "volumes")
+ staticDir := filepath.Join(graphRoot, "libpod")
return RuntimeConfig{
// Leave this empty so containers/storage will use its defaults
StorageConfig: storage.StoreOptions{},
- VolumePath: filepath.Join(storeOpts.GraphRoot, "volumes"),
+ VolumePath: volumePath,
ImageDefaultTransport: DefaultTransport,
StateType: BoltDBStateStore,
OCIRuntime: "runc",
@@ -314,7 +321,7 @@ func defaultRuntimeConfig() (RuntimeConfig, error) {
},
InitPath: define.DefaultInitPath,
CgroupManager: SystemdCgroupsManager,
- StaticDir: filepath.Join(storeOpts.GraphRoot, "libpod"),
+ StaticDir: staticDir,
TmpDir: "",
MaxLogSize: -1,
NoPivotRoot: false,
@@ -789,6 +796,20 @@ func probeConmon(conmonBinary string) error {
// Make a new runtime based on the given configuration
// Sets up containers/storage, state store, OCI runtime
func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
+ // Let's sanity-check some paths first.
+ // Relative paths can cause nasty bugs, because core paths we use could
+ // shift between runs (or even parts of the program - the OCI runtime
+ // uses a different working directory than we do, for example.
+ if !filepath.IsAbs(runtime.config.StaticDir) {
+ return errors.Wrapf(define.ErrInvalidArg, "static directory must be an absolute path - instead got %q", runtime.config.StaticDir)
+ }
+ if !filepath.IsAbs(runtime.config.TmpDir) {
+ return errors.Wrapf(define.ErrInvalidArg, "temporary directory must be an absolute path - instead got %q", runtime.config.TmpDir)
+ }
+ if !filepath.IsAbs(runtime.config.VolumePath) {
+ return errors.Wrapf(define.ErrInvalidArg, "volume path must be an absolute path - instead got %q", runtime.config.VolumePath)
+ }
+
// Find a working conmon binary
foundConmon := false
foundOutdatedConmon := false