diff --git a/dap-sdk/core/src/dap_config.c b/dap-sdk/core/src/dap_config.c index 7089b308fe6ee0044b597452478bac1069ab9419..37e59e489efc14d611b0b537be4fd9f70826d8a0 100755 --- a/dap-sdk/core/src/dap_config.c +++ b/dap-sdk/core/src/dap_config.c @@ -221,7 +221,7 @@ dap_config_t * dap_config_open(const char * a_name) if (l_param_value[0] == '[') { if(l_param_value[1] == ']') { - log_it(L_WARNING, "Empty array!"); + //log_it(L_WARNING, "Empty array!"); continue; } diff --git a/dap-sdk/crypto/src/dap_cert.c b/dap-sdk/crypto/src/dap_cert.c index 67ce81d47a19efc6ed47e5c1095cef4cf064c09d..920e16678ad35a37c074412ef3e620b6850ffceb 100755 --- a/dap-sdk/crypto/src/dap_cert.c +++ b/dap-sdk/crypto/src/dap_cert.c @@ -32,6 +32,7 @@ #include "utlist.h" #include "dap_common.h" #include "dap_config.h" +#include "dap_file_utils.h" #include "dap_string.h" #include "dap_strfuncs.h" #include "dap_cert.h" @@ -521,7 +522,7 @@ void dap_cert_add_folder(const char *a_folder_path) l_cert_folder_item->name = dap_strdup(a_folder_path); HASH_ADD_STR(s_cert_folders, name, l_cert_folder_item); } - + dap_mkdir_with_parents(a_folder_path); DIR * l_dir = opendir(a_folder_path); if( l_dir ) { struct dirent * l_dir_entry; diff --git a/dap-sdk/crypto/src/dap_cert_file.c b/dap-sdk/crypto/src/dap_cert_file.c index 7a733e50b6550763a24c1940f5c96fdba8b97c7e..55fb7f6fe35432b3599e0fe08f0d84f0401c3fd9 100755 --- a/dap-sdk/crypto/src/dap_cert_file.c +++ b/dap-sdk/crypto/src/dap_cert_file.c @@ -28,6 +28,7 @@ #include "dap_common.h" #include "dap_enc.h" #include "dap_enc_key.h" +#include "dap_file_utils.h" #include "dap_cert_file.h" #define LOG_TAG "dap_cert_file" @@ -42,6 +43,10 @@ static const char s_key_inheritor[] = "Inheritor"; */ int dap_cert_file_save(dap_cert_t * a_cert, const char * a_cert_file_path) { + char * l_file_dir = dap_path_get_dirname(a_cert_file_path); + dap_mkdir_with_parents(l_file_dir); + DAP_DELETE(l_file_dir); + FILE * l_file = fopen(a_cert_file_path,"wb"); if( l_file ){ uint32_t l_data_size = 0; diff --git a/modules/global-db/dap_chain_global_db_driver.c b/modules/global-db/dap_chain_global_db_driver.c index b596f92b176ba99e362d115bb775dcecbc843d1b..645875763a6453aba0647717e7a605cd1ef7d2c0 100644 --- a/modules/global-db/dap_chain_global_db_driver.c +++ b/modules/global-db/dap_chain_global_db_driver.c @@ -30,6 +30,7 @@ #include <assert.h> #include "dap_common.h" +#include "dap_file_utils.h" #include "dap_strfuncs.h" #include "dap_list.h" #include "dap_hash.h" @@ -87,6 +88,7 @@ int dap_db_driver_init(const char *a_driver_name, const char *a_filename_db) // Setup driver name s_used_driver = dap_strdup(a_driver_name); + dap_mkdir_with_parents(a_filename_db); // Compose path char l_db_path_ext[strlen(a_driver_name) + strlen(a_filename_db) + 6]; dap_snprintf(l_db_path_ext, sizeof(l_db_path_ext), "%s/gdb-%s", a_filename_db, a_driver_name); diff --git a/modules/global-db/dap_chain_global_db_driver_sqlite.c b/modules/global-db/dap_chain_global_db_driver_sqlite.c index 56faf0c854cc03642358b229f1893f604aed42c6..186b3d9c51854ac96e32dbdc2951302d838e2d4d 100644 --- a/modules/global-db/dap_chain_global_db_driver_sqlite.c +++ b/modules/global-db/dap_chain_global_db_driver_sqlite.c @@ -663,7 +663,7 @@ dap_store_obj_t* dap_db_driver_sqlite_read_last_store_obj(const char *a_group) sqlite3_free(l_str_query); DAP_DEL_Z(l_table_name); if(l_ret != SQLITE_OK) { - log_it(L_ERROR, "read last l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); + //log_it(L_ERROR, "read last l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); dap_db_driver_sqlite_free(l_error_message); return NULL; } @@ -672,7 +672,7 @@ dap_store_obj_t* dap_db_driver_sqlite_read_last_store_obj(const char *a_group) l_ret = dap_db_driver_sqlite_fetch_array(l_res, &l_row); if(l_ret != SQLITE_ROW && l_ret != SQLITE_DONE) { - log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); + //log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); } if(l_ret == SQLITE_ROW && l_row) { l_obj = DAP_NEW_Z(dap_store_obj_t); @@ -724,7 +724,7 @@ dap_store_obj_t* dap_db_driver_sqlite_read_cond_store_obj(const char *a_group, u DAP_DEL_Z(l_table_name); if(l_ret != SQLITE_OK) { - log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); + //log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); dap_db_driver_sqlite_free(l_error_message); return NULL; } @@ -737,7 +737,7 @@ dap_store_obj_t* dap_db_driver_sqlite_read_cond_store_obj(const char *a_group, u l_ret = dap_db_driver_sqlite_fetch_array(l_res, &l_row); if(l_ret != SQLITE_ROW && l_ret != SQLITE_DONE) { - log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); + // log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); } if(l_ret == SQLITE_ROW && l_row) { // realloc memory @@ -809,7 +809,7 @@ dap_store_obj_t* dap_db_driver_sqlite_read_store_obj(const char *a_group, const sqlite3_free(l_str_query); DAP_DEL_Z(l_table_name); if(l_ret != SQLITE_OK) { - log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); + //log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); dap_db_driver_sqlite_free(l_error_message); return NULL; } @@ -822,7 +822,7 @@ dap_store_obj_t* dap_db_driver_sqlite_read_store_obj(const char *a_group, const l_ret = dap_db_driver_sqlite_fetch_array(l_res, &l_row); if(l_ret != SQLITE_ROW && l_ret != SQLITE_DONE) { - log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); + // log_it(L_ERROR, "read l_ret=%d, %s\n", sqlite3_errcode(s_db), sqlite3_errmsg(s_db)); } if(l_ret == SQLITE_ROW && l_row) { // realloc memory diff --git a/modules/net/dap_chain_node_cli.c b/modules/net/dap_chain_node_cli.c index 4595af52098f63f58191891c63edad804813637c..ca9a57683d2418674902133ff1dbfd07530ddacd 100644 --- a/modules/net/dap_chain_node_cli.c +++ b/modules/net/dap_chain_node_cli.c @@ -3,24 +3,24 @@ * Dmitriy A. Gerasimov <gerasimov.dmitriy@demlabs.net> * Alexander Lysikov <alexander.lysikov@demlabs.net> * DeM Labs Inc. https://demlabs.net - * Kelvin Project https://github.com/kelvinblockchain - * Copyright (c) 2019 + * Cellframe https://cellframe.net + * Copyright (c) 2019-2021 * All rights reserved. - This file is part of DAP (Deus Applications Prototypes) the open source project + This file is part of Cellframe SDK - DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + Cellframe SDK is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - DAP is distributed in the hope that it will be useful, + Cellframe SDK is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. + along with any Cellframe SDK based project. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> @@ -61,6 +61,7 @@ #include "dap_common.h" #include "dap_config.h" #include "dap_strfuncs.h" +#include "dap_file_utils.h" #include "dap_list.h" #include "dap_chain_node_cli_cmd.h" #include "dap_chain_node_client.h" @@ -1046,6 +1047,9 @@ int dap_chain_node_cli_init(dap_config_t * g_config) l_listen_port = dap_config_get_item_uint16_default( g_config, "conserver", "listen_port_tcp",0); const char * l_listen_unix_socket_path = dap_config_get_item_str( g_config, "conserver", "listen_unix_socket_path"); + + + const char * l_listen_unix_socket_permissions_str = dap_config_get_item_str( g_config, "conserver", "listen_unix_socket_permissions"); mode_t l_listen_unix_socket_permissions = 0770; @@ -1069,9 +1073,15 @@ int dap_chain_node_cli_init(dap_config_t * g_config) //int gdsg = sizeof(struct sockaddr_un); + // Creatuing directory if not created + char * l_listen_unix_socket_path_dir = dap_path_get_dirname(l_listen_unix_socket_path); + dap_mkdir_with_parents(l_listen_unix_socket_path_dir); + DAP_DELETE(l_listen_unix_socket_path_dir); + if ( access( l_listen_unix_socket_path , R_OK) != -1 ) unlink( l_listen_unix_socket_path ); + // connecting the address with a socket if( bind(sockfd, (const struct sockaddr*) &l_server_addr, sizeof(struct sockaddr_un)) == SOCKET_ERROR) { // errno = EACCES 13 Permission denied diff --git a/modules/net/include/dap_chain_node_cli.h b/modules/net/include/dap_chain_node_cli.h index e98b1a1622786a4bb173469e0d8faf1354711cfe..361a0e3846884ea8ce23f95effceca21577ff9ab 100644 --- a/modules/net/include/dap_chain_node_cli.h +++ b/modules/net/include/dap_chain_node_cli.h @@ -1,26 +1,26 @@ /* * Authors: - * Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net> + * Dmitriy A. Gerasimov <gerasimov.dmitriy@demlabs.net> * Alexander Lysikov <alexander.lysikov@demlabs.net> * DeM Labs Inc. https://demlabs.net - * Kelvin Project https://github.com/kelvinblockchain - * Copyright (c) 2019 + * Cellframe https://cellframe.net + * Copyright (c) 2019-2021 * All rights reserved. - This file is part of DAP (Deus Applications Prototypes) the open source project + This file is part of Cellframe SDK - DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + Cellframe SDK is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - DAP is distributed in the hope that it will be useful, + Cellframe SDK is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. + along with any Cellframe SDK based project. If not, see <http://www.gnu.org/licenses/>. */ #pragma once