Skip to content

Commit f5e7ebe

Browse files
author
Ivan Stoev
committed
Adding all the source.
0 parents  commit f5e7ebe

File tree

1,492 files changed

+556230
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,492 files changed

+556230
-0
lines changed

pCloudCC/CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
project(pcl_client)
3+
4+
find_package(Boost COMPONENTS system program_options REQUIRED)
5+
include_directories(${Boost_INCLUDE_DIR})
6+
link_directories(${Boost_LIBRARY_DIR})
7+
8+
#set (CMAKE_CXX_FLAGS "-fsanitize=address")
9+
10+
set (PCLSYNC_PATH ../pclsync)
11+
include_directories(${PCLSYNC_PATH})
12+
# add_custom_target(
13+
# pclsync_clean
14+
# COMMAND make clean
15+
# WORKING_DIRECTORY ${PCLSYNC_PATH}
16+
# )
17+
18+
# add_custom_target(
19+
# pclsync
20+
# COMMAND make fs
21+
# WORKING_DIRECTORY ${PCLSYNC_PATH}
22+
# )
23+
24+
set (OVERLAY_CLENT_PATH ${PCLSYNC_PATH}/lib/poverlay_linux)
25+
include_directories(${OVERLAY_CLENT_PATH})
26+
27+
link_directories(${PCLSYNC_PATH} ${PCLSYNC_PATH}/lib/mbedtls/library ${PCLSYNC_PATH}/lib/sqlite/inst/lib ${OVERLAY_CLENT_PATH})
28+
29+
30+
add_executable(pcl_client main.cpp pclsync_lib.cpp control_tools.cpp ${OVERLAY_CLENT_PATH}/overlay_client.c ${OVERLAY_CLENT_PATH}/debug.c)
31+
32+
33+
target_link_libraries(pcl_client psynclib mbedtls sqlite3 fuse pthread z
34+
)
35+
36+
target_link_libraries(pcl_client ${Boost_LIBRARIES})
37+
38+
add_dependencies(pcl_client pclsync_clean pclsync)
39+
40+
install(TARGETS pcl_client RUNTIME DESTINATION bin)

pCloudCC/control_tools.cpp

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#include "control_tools.h"
2+
#include "pclsync_lib.h"
3+
#include "overlay_client.h"
4+
5+
#include <iostream>
6+
7+
#include <sys/types.h>
8+
#include <sys/stat.h>
9+
#include <stdio.h>
10+
#include <stdlib.h>
11+
#include <fcntl.h>
12+
#include <errno.h>
13+
#include <unistd.h>
14+
#include <syslog.h>
15+
#include <string.h>
16+
#include <map>
17+
#include <string>
18+
#include <apr-1.0/apr_poll.h>
19+
20+
namespace control_tools{
21+
22+
static const int STOP = 0;
23+
24+
enum command_ids_ {
25+
STARTCRYPTO = 20,
26+
STOPCRYPTO,
27+
FINALIZE
28+
};
29+
30+
31+
int start_crypto(const char * pass) {
32+
int ret;
33+
char* errm;
34+
if (SendCall(STARTCRYPTO, pass, &ret, &errm))
35+
std::cout << "Satrt Crypto failed. return is " << ret<< " and message is "<<errm << std::endl;
36+
else
37+
std::cout << "Crypto started. "<< std::endl;
38+
free(errm);
39+
}
40+
int stop_crypto(){
41+
int ret;
42+
char* errm;
43+
if (SendCall(STOPCRYPTO, "", &ret, &errm))
44+
std::cout << "Stop Crypto failed. return is " << ret<< " and message is "<<errm << std::endl;
45+
else
46+
std::cout << "Crypto Stoped. "<< std::endl;
47+
free(errm);
48+
}
49+
int finalize(){
50+
int ret;
51+
char* errm;
52+
if (SendCall(FINALIZE, "", &ret, &errm))
53+
std::cout << "Finalize failed. return is " << ret<< " and message is "<<errm << std::endl;
54+
else
55+
std::cout << "Exiting ..."<< std::endl;
56+
57+
free(errm);
58+
}
59+
void process_commands()
60+
{
61+
std::cout<< "Supported commands are:" << std::endl << "startcrypto <crypto pass>, stopcrypto, finalize, q, quit" << std::endl;
62+
std::cout<< ">" ;
63+
for (std::string line; std::getline(std::cin, line);) {
64+
if (!line.compare("finalize")) {
65+
finalize();
66+
break;}
67+
else if (!line.compare("stopcrypto"))
68+
stop_crypto();
69+
else if (!line.compare(0,11,"startcrypto",0,11) && (line.length() > 12))
70+
start_crypto(line.c_str() + 12);
71+
else if (!line.compare("q") || !line.compare("quit"))
72+
break;
73+
74+
std::cout<< ">" ;
75+
}
76+
}
77+
78+
int demonize(bool do_commands) {
79+
pid_t pid, sid;
80+
81+
pid = fork();
82+
if (pid < 0)
83+
exit(EXIT_FAILURE);
84+
if (pid > 0) {
85+
std::cout << "Demon process crated. Process id is: " << pid << std::endl;
86+
if (do_commands) {
87+
process_commands();
88+
}
89+
else
90+
std::cout << "sudo kill -9 "<<pid<< std::endl<<"To stop it."<< std::endl;
91+
exit(EXIT_SUCCESS);
92+
}
93+
umask(0);
94+
/* Open any logs here */
95+
sid = setsid();
96+
if (sid < 0)
97+
exit(EXIT_FAILURE);
98+
99+
if ((chdir("/")) < 0)
100+
exit(EXIT_FAILURE);
101+
close(STDIN_FILENO);
102+
close(STDOUT_FILENO);
103+
close(STDERR_FILENO);
104+
105+
if (console_client::clibrary::init())
106+
exit(EXIT_FAILURE);
107+
while (1) {
108+
sleep(10);
109+
}
110+
111+
}
112+
113+
}

pCloudCC/control_tools.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2013-2015 pCloud Ltd.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of pCloud Ltd nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL pCloud Ltd BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#ifndef CONTROL_TOOLS_H
29+
#define CONTROL_TOOLS_H
30+
namespace control_tools {
31+
int start_crypto(const char * pass);
32+
int stop_crypto();
33+
int finalize();
34+
int demonize(bool do_commands);
35+
void process_commands();
36+
}
37+
38+
#endif //CONTROL_TOOLS_H

pCloudCC/lib/mbedtls/.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CMakeCache.txt
2+
CMakeFiles
3+
CTestTestfile.cmake
4+
cmake_install.cmake
5+
Testing
6+
Coverage
7+
*.gcno
8+
*.gcda
9+
10+
# MSVC files generated by CMake:
11+
/*.sln
12+
/*.vcxproj
13+
/*.filters
14+
15+
# MSVC build artifacts:
16+
*.exe
17+
*.pdb
18+
*.ilk
19+
*.lib
20+
21+
# CMake generates *.dir/ folders for in-tree builds (used by MSVC projects), ignore all of those:
22+
*.dir/

pCloudCC/lib/mbedtls/@.travis.yml.old

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
language: c
2+
compiler:
3+
- clang
4+
- gcc
5+
before_install: sudo apt-get update
6+
install: sudo apt-get install gnutls-bin valgrind perl
7+
script:
8+
- cmake -D CMAKE_BUILD_TYPE:String="Check" .
9+
- make
10+
- make test
11+
- ( cd tests && ./compat.sh )
12+
- ( cd tests && ./ssl-opt.sh )
13+
- tests/scripts/test-ref-configs.pl
14+
env:
15+
global:
16+
secure: LidFb8vsR72MKTVpaZ8IYHR1xeVnff47/+ckEge5F9gcwf7QmfSI3+gBLZZciNdyrWzOFhlQ5Q2z/pqVeRtEkKrlcporoMMcHRIbyIA+lfRE1HnYHw7jITScfN9ZmK4msU1ElRlAk6U7ND6MPTH8QfWwchNafDk9d3AoHL4/RrQ=
17+
18+
addons:
19+
coverity_scan:
20+
project:
21+
name: "polarssl/polarssl"
22+
description: "mbed TLS Open Source SSL Library"
23+
notification_email: [email protected]
24+
build_command_prepend:
25+
build_command: make
26+
branch_pattern: development

pCloudCC/lib/mbedtls/CMakeLists.txt

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
project(MBEDTLS C)
3+
4+
string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}")
5+
6+
if(CMAKE_COMPILER_IS_GNUCC)
7+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings -Wlogical-op")
8+
set(CMAKE_C_FLAGS_RELEASE "-O2")
9+
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
10+
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
11+
set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -O3")
12+
set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls ")
13+
set(CMAKE_C_FLAGS_CHECK "-Werror -O1")
14+
set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual")
15+
endif(CMAKE_COMPILER_IS_GNUCC)
16+
17+
if(CMAKE_COMPILER_IS_CLANG)
18+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith")
19+
set(CMAKE_C_FLAGS_RELEASE "-O2")
20+
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
21+
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
22+
set(CMAKE_C_FLAGS_ASAN "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover -O3")
23+
set(CMAKE_C_FLAGS_ASANDBG "-Werror -fsanitize=address -fno-common -fsanitize=undefined -fno-sanitize-recover -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls ")
24+
set(CMAKE_C_FLAGS_MEMSAN "-Werror -fsanitize=memory -O3")
25+
set(CMAKE_C_FLAGS_MEMSANDBG "-Werror -fsanitize=memory -O1 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2")
26+
set(CMAKE_C_FLAGS_CHECK "-Werror -O1")
27+
endif(CMAKE_COMPILER_IS_CLANG)
28+
29+
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
30+
CACHE STRING "Choose the type of build: None Debug Release Coverage ASan ASanDbg MemSan MemSanDbg Check CheckFull"
31+
FORCE)
32+
33+
if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
34+
if(CMAKE_COMPILER_IS_GNUCC)
35+
set(CMAKE_SHARED_LINKER_FLAGS "--coverage")
36+
endif(CMAKE_COMPILER_IS_GNUCC)
37+
if(CMAKE_COMPILER_IS_CLANG)
38+
set(CMAKE_SHARED_LINKER_FLAGS "--coverage")
39+
endif(CMAKE_COMPILER_IS_CLANG)
40+
endif(CMAKE_BUILD_TYPE STREQUAL "Coverage")
41+
42+
option(USE_PKCS11_HELPER_LIBRARY "Build mbed TLS with the pkcs11-helper library." OFF)
43+
44+
option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF)
45+
option(ENABLE_PROGRAMS "Build mbed TLS programs." ON)
46+
option(ENABLE_TESTING "Build mbed TLS tests." ON)
47+
48+
if(ENABLE_TESTING)
49+
enable_testing()
50+
endif()
51+
52+
if(LIB_INSTALL_DIR)
53+
else()
54+
set(LIB_INSTALL_DIR lib)
55+
endif()
56+
57+
include_directories(include/)
58+
59+
if(ENABLE_ZLIB_SUPPORT)
60+
find_package(ZLIB)
61+
62+
if(ZLIB_FOUND)
63+
include_directories(${ZLIB_INCLUDE_DIR})
64+
endif(ZLIB_FOUND)
65+
endif(ENABLE_ZLIB_SUPPORT)
66+
67+
add_subdirectory(library)
68+
add_subdirectory(include)
69+
70+
if(ENABLE_TESTING)
71+
if(CMAKE_COMPILER_IS_GNUCC)
72+
add_subdirectory(tests)
73+
endif(CMAKE_COMPILER_IS_GNUCC)
74+
if(CMAKE_COMPILER_IS_CLANG)
75+
add_subdirectory(tests)
76+
endif(CMAKE_COMPILER_IS_CLANG)
77+
endif()
78+
79+
if(ENABLE_PROGRAMS)
80+
add_subdirectory(programs)
81+
endif()
82+
83+
ADD_CUSTOM_TARGET(apidoc
84+
COMMAND doxygen doxygen/mbedtls.doxyfile
85+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
86+
87+
if(ENABLE_TESTING)
88+
ADD_CUSTOM_TARGET(test-ref-config
89+
COMMAND tests/scripts/test-ref-configs.pl
90+
)
91+
92+
ADD_CUSTOM_TARGET(covtest
93+
COMMAND make test
94+
COMMAND programs/test/selftest
95+
COMMAND cd tests && ./compat.sh
96+
COMMAND cd tests && ./ssl-opt.sh
97+
)
98+
99+
ADD_CUSTOM_TARGET(lcov
100+
COMMAND rm -rf Coverage
101+
COMMAND lcov --capture --initial --directory library/CMakeFiles/mbedtls.dir -o files.info
102+
COMMAND lcov --capture --directory library/CMakeFiles/mbedtls.dir -o tests.info
103+
COMMAND lcov --add-tracefile files.info --add-tracefile tests.info -o all.info
104+
COMMAND lcov --remove all.info -o final.info '*.h'
105+
COMMAND gendesc tests/Descriptions.txt -o descriptions
106+
COMMAND genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --no-branch-coverage -o Coverage final.info
107+
COMMAND rm -f files.info tests.info all.info final.info descriptions
108+
)
109+
110+
ADD_CUSTOM_TARGET(memcheck
111+
COMMAND sed -i.bak s+/usr/bin/valgrind+`which valgrind`+ DartConfiguration.tcl
112+
COMMAND ctest -O memcheck.log -D ExperimentalMemCheck
113+
COMMAND tail -n1 memcheck.log | grep 'Memory checking results:' > /dev/null
114+
COMMAND rm -f memcheck.log
115+
COMMAND mv DartConfiguration.tcl.bak DartConfiguration.tcl
116+
)
117+
endif()

0 commit comments

Comments
 (0)