Fix getting individual journal entries with an underscore
The journal entries with an underscore in the ID could not
be accessed individually.
This change tracks the unique ID while searching for the entry
so it can find the correct entry with an underscore.
Tested:
Checked that individual journal entries with and without an
underscore can be accessed.
Passed the Redfish Service Validator.
Change-Id: I4aedbe1cb7d5f3cb896c5a0e766e9a274f0ee076
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index a9356ae..578e673 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1435,14 +1435,25 @@
journalTmp, sd_journal_close);
journalTmp = nullptr;
// Go to the timestamp in the log and move to the entry at the index
+ // tracking the unique ID
+ std::string idStr;
+ bool firstEntry = true;
ret = sd_journal_seek_realtime_usec(journal.get(), ts);
for (int i = 0; i <= index; i++)
{
sd_journal_next(journal.get());
+ if (!getUniqueEntryID(journal.get(), idStr, firstEntry))
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (firstEntry)
+ {
+ firstEntry = false;
+ }
}
// Confirm that the entry ID matches what was requested
- std::string idStr;
- if (!getUniqueEntryID(journal.get(), idStr) || idStr != entryID)
+ if (idStr != entryID)
{
messages::resourceMissingAtURI(asyncResp->res, entryID);
return;