netipmid: move to sdbusplus from sdbus minus

In main, wrapping the raw sd_bus object with an sdbusplus class makes
deals with the unref problem automatically.

Change-Id: I7d21c21bc09cc96e2d4b07d1b51b6f82239e0793
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/main.cpp b/main.cpp
index f49d4c7..b142ed7 100644
--- a/main.cpp
+++ b/main.cpp
@@ -43,6 +43,8 @@
 static bool selReservationValid = false;
 sd_bus_slot* ipmid_slot = nullptr;
 
+std::shared_ptr<sdbusplus::bus::bus> sdbusp;
+
 /*
  * @brief Required by apphandler IPMI Provider Library
  */
@@ -52,6 +54,14 @@
 }
 
 /*
+ * @brief mechanism to get at sdbusplus object
+ */
+std::shared_ptr<sdbusplus::bus::bus> getSdBus()
+{
+    return sdbusp;
+}
+
+/*
  * @brief Required by apphandler IPMI Provider Library
  */
 sd_event* ipmid_get_sd_event_connection()
@@ -110,13 +120,14 @@
                   << "\n";
         goto finish;
     }
+    sdbusp = std::make_shared<sdbusplus::bus::bus>(bus);
 
     /* Get an sd event handler */
     rc = sd_event_default(&events);
     if (rc < 0)
     {
         std::cerr << "Failure to create sd_event" << strerror(-rc) << "\n";
-        goto finish;
+        return EXIT_FAILURE;
     }
 
     // Register callback to update cache for a GUID change and cache the GUID
@@ -137,7 +148,6 @@
         .startEventLoop(events);
 
 finish:
-    sd_bus_unref(bus);
     sd_event_unref(events);
 
     return 0;