diff options
-rw-r--r-- | src/persistence_client_library.c | 27 | ||||
-rw-r--r-- | src/persistence_client_library_db_access.c | 48 | ||||
-rw-r--r-- | src/persistence_client_library_dbus_service.c | 22 | ||||
-rw-r--r-- | src/persistence_client_library_file.c | 5 | ||||
-rw-r--r-- | src/persistence_client_library_prct_access.c | 10 |
5 files changed, 52 insertions, 60 deletions
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c index 0608539..70fe20e 100644 --- a/src/persistence_client_library.c +++ b/src/persistence_client_library.c @@ -24,6 +24,7 @@ #include "persistence_client_library_handle.h" #include "persistence_client_library_custom_loader.h" #include "persistence_client_library.h" +#include "persistence_client_library_backup_filelist.h" #include <string.h> #include <errno.h> @@ -40,6 +41,10 @@ /// debug log and trace (DLT) setup DLT_DECLARE_CONTEXT(gDLTContext); +// declared in persistence_client_library_dbus_service.c +// used to end dbus library +extern int bContinue; + static int gShutdownMode = 0; /// loical function declaration @@ -66,11 +71,26 @@ int pclInitLibrary(const char* appName, int shutdownMode) /// environment variable for max key value data const char *pDataSize = getenv("PERS_MAX_KEY_VAL_DATA_SIZE"); + /// blacklist path environment variable + const char *pBlacklistPath = getenv("PERS_BLACKLIST_PATH"); + if(pDataSize != NULL) { gMaxKeyValDataSize = atoi(pDataSize); } + if(pBlacklistPath != NULL) + { + pBlacklistPath = "/etc/pclBackupBlacklist.txt"; // default path + } + + rval = readBlacklistConfigFile(pBlacklistPath); + if(rval == -1) + { + DLT_LOG(gDLTContext, DLT_LOG_WARN, DLT_STRING("pclInitLibrary -> failed to access blacklist:"), DLT_STRING(pBlacklistPath)); + } + + if( setup_dbus_mainloop() == -1) { DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => Failed to setup main loop")); @@ -140,7 +160,6 @@ int pclInitLibrary(const char* appName, int shutdownMode) DLT_LOG(gDLTContext, DLT_LOG_WARN, DLT_STRING("pclInit => Failed to load custom library config table => error number:"), DLT_INT(status)); } - // assign application name strncpy(gAppId, appName, MaxAppNameLen); gAppId[MaxAppNameLen-1] = '\0'; @@ -148,8 +167,6 @@ int pclInitLibrary(const char* appName, int shutdownMode) // destory mutex pthread_mutex_destroy(&gDbusInitializedMtx); pthread_cond_destroy(&gDbusInitializedCond); - - rval = 1; } else if(gPclInitialized >= PCLinitialized) { @@ -203,10 +220,14 @@ int pclDeinitLibrary(void) gPclInitialized--; // decrement init counter } + // end dbus library + bContinue = FALSE; + return rval; } + void invalidateCustomPlugin(int idx) { gPersCustomFuncs[idx].handle = NULL; diff --git a/src/persistence_client_library_db_access.c b/src/persistence_client_library_db_access.c index e5aad0e..3424d94 100644 --- a/src/persistence_client_library_db_access.c +++ b/src/persistence_client_library_db_access.c @@ -204,16 +204,16 @@ int pers_db_read_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_get_data != NULL) ) { + char pathKeyString[128] = {0}; if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key { - char pathKeyString[128]; - snprintf(pathKeyString, 128, "%s/%s", dbPath, key); - read_size = gPersCustomFuncs[idx].custom_plugin_get_data(pathKeyString, (char*)buffer, buffer_size); + snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key); } else { - read_size = gPersCustomFuncs[idx].custom_plugin_get_data(info->configKey.customID, (char*)buffer, buffer_size); + snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID); } + read_size = gPersCustomFuncs[idx].custom_plugin_get_data(pathKeyString, (char*)buffer, buffer_size); } else { @@ -308,14 +308,16 @@ int pers_db_write_key(char* dbPath, char* key, PersistenceInfo_s* info, unsigned int idx = custom_client_name_to_id(dbPath, 1); if((idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_set_data != NULL) ) { + char pathKeyString[128] = {0}; if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key { - char pathKeyString[128]; - snprintf(pathKeyString, 128, "%s/%s", dbPath, key); - write_size = gPersCustomFuncs[idx].custom_plugin_set_data(pathKeyString, (char*)buffer, buffer_size); + snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key); } else - write_size = gPersCustomFuncs[idx].custom_plugin_set_data(info->configKey.customID, (char*)buffer, buffer_size); + { + snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID); + } + write_size = gPersCustomFuncs[idx].custom_plugin_set_data(pathKeyString, (char*)buffer, buffer_size); } else { @@ -372,14 +374,16 @@ int pers_db_get_key_size(char* dbPath, char* key, PersistenceInfo_s* info) int idx = custom_client_name_to_id(dbPath, 1); if((idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_get_size != NULL) ) { + char pathKeyString[128] = {0}; if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key { - char pathKeyString[128]; - snprintf(pathKeyString, 128, "%s/%s", dbPath, key); - read_size = gPersCustomFuncs[idx].custom_plugin_get_size(pathKeyString); + snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key); } else - read_size = gPersCustomFuncs[idx].custom_plugin_get_size(info->configKey.customID); + { + snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID); + } + read_size = gPersCustomFuncs[idx].custom_plugin_get_size(pathKeyString); } else { @@ -446,14 +450,16 @@ int pers_db_delete_key(char* dbPath, char* key, PersistenceInfo_s* info) int idx = custom_client_name_to_id(dbPath, 1); if((idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_delete_data != NULL) ) { + char pathKeyString[128] = {0}; if(info->configKey.customID[0] == '\0') // if we have not a customID we use the key { - char pathKeyString[128]; - snprintf(pathKeyString, 128, "%s/%s", dbPath, key); - ret = gPersCustomFuncs[idx].custom_plugin_delete_data(pathKeyString); + snprintf(pathKeyString, 128, "0x%08X/%s/%s", info->context.ldbid, info->configKey.custom_name, key); } else - ret = gPersCustomFuncs[idx].custom_plugin_delete_data(info->configKey.customID); + { + snprintf(pathKeyString, 128, "0x%08X/%s", info->context.ldbid, info->configKey.customID); + } + ret = gPersCustomFuncs[idx].custom_plugin_delete_data(pathKeyString); } else { @@ -502,9 +508,9 @@ int pers_send_Notification_Signal(const char* key, PersistenceDbContext_s* conte DBusMessage* message; dbus_bool_t ret; int rval = 0; - char ldbid_array[DbusSubMatchSize]; - char user_array[DbusSubMatchSize]; - char seat_array[DbusSubMatchSize]; + char ldbid_array[DbusSubMatchSize] = {0}; + char user_array[DbusSubMatchSize] = {0}; + char seat_array[DbusSubMatchSize] = {0}; const char* ldbid_ptr = ldbid_array; const char* user_ptr = user_array; const char* seat_ptr = seat_array; @@ -516,10 +522,6 @@ int pers_send_Notification_Signal(const char* key, PersistenceDbContext_s* conte DBusConnection* conn = get_dbus_connection(); - memset(ldbid_array, 0, DbusSubMatchSize); - memset(user_array, 0, DbusSubMatchSize); - memset(seat_array, 0, DbusSubMatchSize); - // dbus_bus_add_match is used for the notification mechanism, // and this works only for type DBUS_TYPE_STRING as message arguments diff --git a/src/persistence_client_library_dbus_service.c b/src/persistence_client_library_dbus_service.c index 6b1d05b..b073b83 100644 --- a/src/persistence_client_library_dbus_service.c +++ b/src/persistence_client_library_dbus_service.c @@ -28,8 +28,6 @@ #include <unistd.h> #include <stdlib.h> -//#define DEBUG_MODE 1 - pthread_mutex_t gDbusInitializedMtx = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t gDbusInitializedCond = PTHREAD_COND_INITIALIZER; @@ -76,22 +74,6 @@ DBusConnection* get_dbus_connection(void) int bContinue = 0; -//------------------------------------------------------------------------ -// debugging only until "correct" exit of main loop is possible!!!!! -//------------------------------------------------------------------------ -#ifdef DEBUG_MODE - -#include "signal.h" - -void sigHandler(int signo) -{ - bContinue = FALSE; -} -#endif -//------------------------------------------------------------------------ - - - #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) @@ -474,10 +456,6 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2, // lock mutex to make sure dbus main loop is running pthread_mutex_lock(&gDbusInitializedMtx); -#if DEBUG_MODE - signal(SIGINT, sigHandler); -#endif - DBusConnection* conn = (DBusConnection*)userData; dbus_error_init(&err); diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c index 82e30c7..c8080ba 100644 --- a/src/persistence_client_library_file.c +++ b/src/persistence_client_library_file.c @@ -18,6 +18,7 @@ */ #include "persistence_client_library_file.h" +#include "persistence_client_library_backup_filelist.h" #include "../include_protected/persistence_client_library_data_organization.h" #include "../include_protected/persistence_client_library_db_access.h" #include "../include_protected/crc32.h" @@ -26,6 +27,7 @@ #include "persistence_client_library_handle.h" #include "persistence_client_library_prct_access.h" + #include <fcntl.h> // for open flags #include <errno.h> #include <string.h> @@ -757,8 +759,7 @@ int pclCalcCrc32Csum(int fd, char crc32sum[]) int pclBackupNeeded(const char* path) { - int needBackup = 1; - return needBackup; + return need_backup_path(path); } diff --git a/src/persistence_client_library_prct_access.c b/src/persistence_client_library_prct_access.c index e9a2991..f3142b4 100644 --- a/src/persistence_client_library_prct_access.c +++ b/src/persistence_client_library_prct_access.c @@ -159,18 +159,8 @@ int get_db_context(PersistenceInfo_s* dbContext, const char* resource_id, unsign } else { - int len = strlen(resource_id); - // if customer storage, we use the custom name as dbPath strncpy(dbPath, dbContext->configKey.custom_name, strlen(dbContext->configKey.custom_name)); - - if(len > DbKeyMaxLen) - { - len = DbKeyMaxLen; - } - // and the resource_id as dbKey - strncpy(dbKey, resource_id, len); - } resourceFound = 1; } |