]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Don't allow encryption secretPath to be NULL
authorJohn Ferlan <jferlan@redhat.com>
Tue, 19 Jun 2018 16:05:31 +0000 (12:05 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 26 Jun 2018 18:02:43 +0000 (14:02 -0400)
Allowing a NULL @secretPath for virStorageBackendCreateQemuImgCmdFromVol
would result in a generated command line with a dangling "file=" output.
So let's make sure the @secretPath exists before processing.

This means we should pass a dummy path from the storage test.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
src/storage/storage_util.c
tests/storagevolxml2argvtest.c

index 87f2115869e9274e457d52c72030dd08f4f0f01d..88427cecb447b34f4447f5a29b1b1eac11555387 100644 (file)
@@ -1233,6 +1233,11 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
 
     if (info.format == VIR_STORAGE_FILE_RAW && vol->target.encryption &&
         vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
+        if (!info.secretPath) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("path to secret data file is required"));
+            goto error;
+        }
         if (virAsprintf(&info.secretAlias, "%s_encrypt0", vol->name) < 0)
             goto error;
         if (storageBackendCreateQemuImgSecretObject(cmd, info.secretPath,
index 0265a0ffe2afa39df1dbdca1611a78950e53e6fc..4286c50c6e7e526389fb673c9c3f0865196e0e35 100644 (file)
@@ -82,7 +82,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
     cmd = virStorageBackendCreateQemuImgCmdFromVol(obj, vol,
                                                    inputvol, flags,
                                                    create_tool,
-                                                   NULL);
+                                                   "/path/to/secretFile");
     if (!cmd) {
         if (shouldFail) {
             virResetLastError();