Oved Ourfali has uploaded a new change for review.

Change subject: core: sysprep.inf contents are visible in engine.log (#849666)
......................................................................

core: sysprep.inf contents are visible in engine.log (#849666)

https://bugzilla.redhat.com/849666

When VDSM returs VM devices without address, an information message with
the device details is printed to the log.
In the sysprep case, it is a floppy device, which may contain sensitive
information.

This patch will not print the details of floppy devices.

Change-Id: I5b9825ef299272ce2d6e9ea3bdecc92bcd1a78cc
Signed-off-by: Oved Ourfali <[email protected]>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
1 file changed, 32 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/7491/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
index 27efdc2..b1a4f92 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
@@ -39,6 +39,7 @@
 import org.ovirt.engine.core.common.config.ConfigValues;
 import org.ovirt.engine.core.common.utils.EnumUtils;
 import org.ovirt.engine.core.common.utils.VmDeviceCommonUtils;
+import org.ovirt.engine.core.common.utils.VmDeviceType;
 import org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.FullListVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.GetVmStatsVDSCommandParameters;
@@ -914,6 +915,27 @@
                 new FullListVDSCommandParameters(_vds.getId(), 
vmsToUpdate)).ExecuteWithReturnValue());
     }
 
+    private boolean shouldLogDeviceDetails(String deviceType) {
+        return !StringUtils.equalsIgnoreCase(deviceType, 
VmDeviceType.FLOPPY.getName());
+    }
+
+    private void logDeviceInformation(Guid vmId, XmlRpcStruct device) {
+        String message = "Recieved a {0} Device without an address when 
processing VM {1} devices, skipping device";
+        String deviceType = getDeviceType(device);
+
+        if (shouldLogDeviceDetails(deviceType)) {
+            Map<String,Object> deviceInfo = device.getInnerMap();
+            log.infoFormat(message + ": {2}",
+                           StringUtils.defaultIfEmpty(deviceType, 
StringUtils.EMPTY),
+                           vmId,
+                           deviceInfo.toString());
+        } else {
+            log.infoFormat(message,
+                           StringUtils.defaultIfEmpty(deviceType, 
StringUtils.EMPTY),
+                           vmId);
+        }
+    }
+
     /**
      * Actually process the VM device update in DB.
      * @param vm
@@ -935,9 +957,7 @@
             XmlRpcStruct device = new XmlRpcStruct((Map<String, Object>) o);
             Guid deviceId = getDeviceId(device);
             if ((device.getItem(VdsProperties.Address)) == null) {
-                log.infoFormat("Recieved a Device without an address when 
processing VM {0} devices, skipping device: {1}.",
-                        vmId,
-                        device.getInnerMap().toString());
+                logDeviceInformation(vmId, device);
                 continue;
             }
             VmDevice vmDevice = deviceMap.get(new VmDeviceId(deviceId, vmId));
@@ -1022,6 +1042,15 @@
         return deviceId == null ? null : new Guid(deviceId);
     }
 
+    /**
+     * gets the device type from the structure returned by VDSM
+     * @param device
+     * @return
+     */
+    private static String getDeviceType(XmlRpcStruct device) {
+        return (String) device.getItem(VdsProperties.Device);
+    }
+
     // if not statistics check if status changed and add to running list
     private List<VM> checkVmsStatusChanged() {
         List<VM> running = new ArrayList<VM>();


--
To view, visit http://gerrit.ovirt.org/7491
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b9825ef299272ce2d6e9ea3bdecc92bcd1a78cc
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Oved Ourfali <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to