ipmid: allow command not found for filtered commands

Filters are executed first and the actual ipmi command handler will not
execute if the filter rejects it for any reason.

However, if a filter returns a value for a command that is not even
implemented, the old logic would return that value instead of command
not implemented (C1h). This is incorrect behavior.

This fix will run the filter and then check to see if the command is
registered. If the command is registered AND the filter has returned
some error, only then will the filter error get returned. If the command
is registered and the filter returns no error, the command is executed.
If the command is not registered, C1h is returned, as per the spec.

Tested:
    1) Add some bogus command definitions to the whitelist filter
    2) Run the bogus command
    3) See that C1h is returned, not insufficient privilege

Change-Id: I069df8f47a169d6b2961460a561bf9cae6ae285c
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/ipmid-new.cpp b/ipmid-new.cpp
index bb427f7..abd0a10 100644
--- a/ipmid-new.cpp
+++ b/ipmid-new.cpp
@@ -233,17 +233,18 @@
 {
     // filter the command first; a non-null message::Response::ptr
     // means that the message has been rejected for some reason
-    message::Response::ptr response = filterIpmiCommand(request);
-    if (response)
-    {
-        return response;
-    }
+    message::Response::ptr filterResponse = filterIpmiCommand(request);
 
     Cmd cmd = request->ctx->cmd;
     unsigned int key = makeCmdKey(keyCommon, cmd);
     auto cmdIter = handlers.find(key);
     if (cmdIter != handlers.end())
     {
+        // only return the filter response if the command is found
+        if (filterResponse)
+        {
+            return filterResponse;
+        }
         HandlerTuple& chosen = cmdIter->second;
         if (request->ctx->priv < std::get<Privilege>(chosen))
         {
@@ -257,6 +258,11 @@
         cmdIter = handlers.find(wildcard);
         if (cmdIter != handlers.end())
         {
+            // only return the filter response if the command is found
+            if (filterResponse)
+            {
+                return filterResponse;
+            }
             HandlerTuple& chosen = cmdIter->second;
             if (request->ctx->priv < std::get<Privilege>(chosen))
             {