RpmEnvironmentManager() : config_(getEnvVar("RPM_CONFIGDIR")) { // Honor a caller's environment if (!config_.is_initialized()) { setEnvVar("RPM_CONFIGDIR", "/usr/lib/rpm"); } callback_ = rpmlogSetCallback(&RpmEnvironmentManager::Callback, nullptr); }
~RpmEnvironmentManager() { // If we had set the environment, clean it up afterward. if (!config_.is_initialized()) { unsetEnvVar("RPM_CONFIGDIR"); } if (callback_ != nullptr) { rpmlogSetCallback(callback_, nullptr); callback_ = nullptr; } }
void *probe_init (void) { #ifdef RPM46_FOUND rpmlogSetCallback(rpmErrorCb, NULL); #endif if (rpmReadConfigFiles ((const char *)NULL, (const char *)NULL) != 0) { dI("rpmReadConfigFiles failed: %u, %s.", errno, strerror (errno)); return (NULL); } g_rpm.rpmts = rpmtsCreate(); pthread_mutex_init(&(g_rpm.mutex), NULL); if (OSCAP_GSYM(offline_mode) & PROBE_OFFLINE_OWN) { const char* root = getenv("OSCAP_PROBE_ROOT"); rpmtsSetRootDir(g_rpm.rpmts, root); } return ((void *)&g_rpm); }