void hdata_print_log_map_cb (void *data, struct t_hashtable *hashtable, const void *key, const void *value) { struct t_hdata *ptr_hdata; /* make C compiler happy */ (void) data; (void) hashtable; (void) key; ptr_hdata = (struct t_hdata *)value; log_printf (""); log_printf ("[hdata (addr:0x%lx)]", ptr_hdata); log_printf (" name . . . . . . . . . : '%s'", ptr_hdata->name); log_printf (" plugin . . . . . . . . : 0x%lx", ptr_hdata->plugin); log_printf (" var_prev . . . . . . . : '%s'", ptr_hdata->var_prev); log_printf (" var_next . . . . . . . : '%s'", ptr_hdata->var_next); log_printf (" hash_var . . . . . . . : 0x%lx (hashtable: '%s')", ptr_hdata->hash_var, hashtable_get_string (ptr_hdata->hash_var, "keys_values")); log_printf (" hash_list. . . . . . . : 0x%lx (hashtable: '%s')", ptr_hdata->hash_list, hashtable_get_string (ptr_hdata->hash_list, "keys_values")); log_printf (" create_allowed . . . . : %d", (int)ptr_hdata->create_allowed); log_printf (" delete_allowed . . . . : %d", (int)ptr_hdata->delete_allowed); log_printf (" callback_update. . . . : 0x%lx", ptr_hdata->callback_update); log_printf (" callback_update_data . : 0x%lx", ptr_hdata->callback_update_data); log_printf (" update_pending . . . . : %d", (int)ptr_hdata->update_pending); hashtable_map (ptr_hdata->hash_var, &hdata_print_log_var_map_cb, NULL); }
int secure_decrypt_data_not_decrypted (const char *passphrase) { char **keys, *buffer, *decrypted; const char *value; int num_ok, num_keys, i, length_buffer, length_decrypted, rc; /* we need a passphrase to decrypt data! */ if (!passphrase || !passphrase[0]) return 0; num_ok = 0; keys = string_split (hashtable_get_string (secure_hashtable_data_encrypted, "keys"), ",", 0, 0, &num_keys); if (keys) { for (i = 0; i < num_keys; i++) { value = hashtable_get (secure_hashtable_data_encrypted, keys[i]); if (value && value[0]) { buffer = malloc (strlen (value) + 1); if (buffer) { length_buffer = string_decode_base16 (value, buffer); decrypted = NULL; length_decrypted = 0; rc = secure_decrypt_data (buffer, length_buffer, secure_hash_algo[CONFIG_INTEGER(secure_config_crypt_hash_algo)], secure_cipher[CONFIG_INTEGER(secure_config_crypt_cipher)], passphrase, &decrypted, &length_decrypted); if ((rc == 0) && decrypted) { hashtable_set (secure_hashtable_data, keys[i], decrypted); hashtable_remove (secure_hashtable_data_encrypted, keys[i]); num_ok++; } if (decrypted) free (decrypted); free (buffer); } } } string_free_split (keys); } return num_ok; }
const char * hdata_get_string (struct t_hdata *hdata, const char *property) { if (!hdata || !property) return NULL; if (string_strcasecmp (property, "var_keys") == 0) return hashtable_get_string (hdata->hash_var, "keys"); else if (string_strcasecmp (property, "var_values") == 0) return hashtable_get_string (hdata->hash_var, "values"); else if (string_strcasecmp (property, "var_keys_values") == 0) return hashtable_get_string (hdata->hash_var, "keys_values"); else if (string_strcasecmp (property, "var_prev") == 0) return hdata->var_prev; else if (string_strcasecmp (property, "var_next") == 0) return hdata->var_next; else if (string_strcasecmp (property, "list_keys") == 0) return hashtable_get_string (hdata->hash_list, "keys"); else if (string_strcasecmp (property, "list_values") == 0) return hashtable_get_string (hdata->hash_list, "values"); else if (string_strcasecmp (property, "list_keys_values") == 0) return hashtable_get_string (hdata->hash_list, "keys_values"); return NULL; }