Merge remote branch 'origin/next' into next

This commit is contained in:
Martin Raiber 2012-08-02 19:00:01 +02:00
commit 753a2ae3e6
7 changed files with 190 additions and 15 deletions

View File

@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS = urbackup_client
urbackup_client_SOURCES = AcceptThread.cpp Client.cpp Database.cpp Query.cpp SelectThread.cpp Server.cpp ServerLinux.cpp ServiceAcceptor.cpp ServiceWorker.cpp SessionMgr.cpp StreamPipe.cpp Template.cpp WorkerThread.cpp main.cpp md5.cpp stringtools.cpp libfastcgi/fastcgi.cpp Mutex_lin.cpp LoadbalancerClient.cpp DBSettingsReader.cpp file_common.cpp file_fstream.cpp file_linux.cpp FileSettingsReader.cpp LookupService.cpp SettingsReader.cpp Table.cpp OutputStream.cpp ThreadPool.cpp MemoryPipe.cpp Condition_lin.cpp MemorySettingsReader.cpp sqlite/sqlite3.c sqlite/shell.c SQLiteFactory.cpp
urbackup_client_SOURCES = AcceptThread.cpp Client.cpp Database.cpp Query.cpp SelectThread.cpp Server.cpp ServerLinux.cpp ServiceAcceptor.cpp ServiceWorker.cpp SessionMgr.cpp StreamPipe.cpp Template.cpp WorkerThread.cpp main.cpp md5.cpp stringtools.cpp libfastcgi/fastcgi.cpp Mutex_lin.cpp LoadbalancerClient.cpp DBSettingsReader.cpp file_common.cpp file_fstream.cpp file_linux.cpp FileSettingsReader.cpp LookupService.cpp SettingsReader.cpp Table.cpp OutputStream.cpp ThreadPool.cpp MemoryPipe.cpp Condition_lin.cpp MemorySettingsReader.cpp sqlite/sqlite3.c sqlite/shell.c SQLiteFactory.cpp PipeThrottler.cpp
urbackup_client_LDADD = -ldl
bin_SCRIPTS = start_urbackup_client
AM_CXXFLAGS = $(PTHREAD_CFLAGS) -DLINUX
@ -14,5 +14,5 @@ install-exec-local: defaults_client init.d_client
mkdir -p "$(DESTDIR)$(localstatedir)/urbackup"
mkdir -p "$(DESTDIR)$(localstatedir)/urbackup/data"
noinst_HEADERS=SessionMgr.h WorkerThread.h Helper_win32.h Database.h defaults.h ServiceAcceptor.h Query.h SettingsReader.h file.h Mutex_boost.h Condition_boost.h file_memory.h MemorySettingsReader.h Condition_lin.h LookupService.h Template.h types.h DBSettingsReader.h stringtools.h ThreadPool.h libs.h vld_.h ServiceWorker.h StreamPipe.h LoadbalancerClient.h socket_header.h FileSettingsReader.h SelectThread.h md5.h vld.h Table.h Client.h MemoryPipe.h Mutex_lin.h AcceptThread.h OutputStream.h Server.h Interface/SessionMgr.h Interface/Service.h Interface/PluginMgr.h Interface/Database.h Interface/Pipe.h Interface/CustomClient.h Interface/User.h Interface/Query.h Interface/SettingsReader.h Interface/Types.h Interface/Template.h Interface/ThreadPool.h Interface/Mutex.h Interface/File.h Interface/Condition.h Interface/Table.h Interface/Plugin.h Interface/Thread.h Interface/Action.h Interface/Object.h Interface/OutputStream.h Interface/Server.h libfastcgi/fastcgi.hpp sqlite/sqlite3.h sqlite/sqlite3ext.h utf8/utf8.h utf8/utf8/checked.h utf8/utf8/core.h utf8/utf8/unchecked.h cryptoplugin/ICryptoFactory.h cryptoplugin/IAESEncryption.h cryptoplugin/IAESDecryption.h Interface/DatabaseFactory.h Interface/DatabaseInt.h sqlite/shell.h SQLiteFactory.h
noinst_HEADERS=SessionMgr.h WorkerThread.h Helper_win32.h Database.h defaults.h ServiceAcceptor.h Query.h SettingsReader.h file.h Mutex_boost.h Condition_boost.h file_memory.h MemorySettingsReader.h Condition_lin.h LookupService.h Template.h types.h DBSettingsReader.h stringtools.h ThreadPool.h libs.h vld_.h ServiceWorker.h StreamPipe.h LoadbalancerClient.h socket_header.h FileSettingsReader.h SelectThread.h md5.h vld.h Table.h Client.h MemoryPipe.h Mutex_lin.h AcceptThread.h OutputStream.h Server.h Interface/SessionMgr.h Interface/Service.h Interface/PluginMgr.h Interface/Database.h Interface/Pipe.h Interface/CustomClient.h Interface/User.h Interface/Query.h Interface/SettingsReader.h Interface/Types.h Interface/Template.h Interface/ThreadPool.h Interface/Mutex.h Interface/File.h Interface/Condition.h Interface/Table.h Interface/Plugin.h Interface/Thread.h Interface/Action.h Interface/Object.h Interface/OutputStream.h Interface/Server.h libfastcgi/fastcgi.hpp sqlite/sqlite3.h sqlite/sqlite3ext.h utf8/utf8.h utf8/utf8/checked.h utf8/utf8/core.h utf8/utf8/unchecked.h cryptoplugin/ICryptoFactory.h cryptoplugin/IAESEncryption.h cryptoplugin/IAESDecryption.h Interface/DatabaseFactory.h Interface/DatabaseInt.h sqlite/shell.h SQLiteFactory.h PipeThrottler.h
EXTRA_DIST=docs/start_urbackup_client.1 docs/urbackup_client.1 init.d_client defaults_client start_urbackup_client

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT([urbackup-client], [0.40.1], [martin@urbackup.org])
AC_INIT([urbackup-client], [1.0], [martin@urbackup.org])
AC_CONFIG_SRCDIR([AcceptThread.cpp])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
@ -50,6 +50,6 @@ AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRFTIME
AC_CHECK_FUNCS([gettimeofday memset select socket strstr])
AC_CONFIG_SUBDIRS([client fileservplugin fsimageplugin urbackup])
AC_CONFIG_SUBDIRS([client cryptoplugin fileservplugin fsimageplugin urbackupclient])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

165
cryptoplugin/m4/cryptopp.m4 Normal file
View File

@ -0,0 +1,165 @@
# -*- Autoconf -*-
# This file is part of the aMule Project.
#
# Copyright (c) 2003-2009 aMule Team ( admin@amule.org / http://www.amule.org )
#
# Any parts of this program derived from the xMule, lMule or eMule project,
# or contributed by third-party developers are copyrighted by their
# respective authors.
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#
dnl --------------------------------------------------------------------------
dnl MULE_CHECK_CRYPTOPP([VERSION = 5.1], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl
dnl Check for cryptopp library
dnl --------------------------------------------------------------------------
dnl
dnl This macro sets these variables:
dnl - CRYPTOPP_PREFIX
dnl This is the user or system directory where crypto++ is installed or sources
dnl - CRYPTOPP_VERSION_STRING
dnl Something like "5.5.2"
dnl - CRYPTOPP_VERSION_NUMBER
dnl Something like 5005002
dnl - CRYPTOPP_STYLE
dnl "sources", "installed" or "gentoo_debian"
dnl - CRYPTOPP_LIB_NAME
dnl "cryptopp" or "crypto++"
dnl - CRYPTOPP_INCLUDE_PREFIX
dnl The string that goes here: #include <@CRYPTOPP_INCLUDE_PREFIX@/rsa.h>
dnl - CRYPTOPP_CPPFLAGS
dnl Flags to be added to CPPFLAGS
dnl - CRYPTOPP_LDFLAGS
dnl Flags to be added to LDFLAGS
dnl - CRYPTOPP_LIBS
dnl Library to be added to LIBS
dnl
dnl The CRYPTOPP_CPPFLAGS, CRYPTOPP_LDFLAGS and CRYPTOPP_LIBS variables are also substituted.
dnl
dnl Worth notice:
dnl - cryptopp_includedir
dnl The string that goes in -I on CPPFLAGS
dnl - cryptopp_libdir
dnl The string that goes in -L on LDFLAGS
dnl - cryptopp_header_path
dnl The file we use to discover the version of cryptopp
dnl
AC_DEFUN([MULE_CHECK_CRYPTOPP],
[dnl
AC_REQUIRE([AC_PROG_EGREP])dnl
m4_define([MIN_CRYPTO_VERSION], [m4_ifval([$1], [$1], [5.1])])dnl
AC_ARG_WITH([crypto-prefix],
[AS_HELP_STRING([--with-crypto-prefix=PREFIX], [prefix where crypto++ is installed])])
AC_MSG_CHECKING([for crypto++ version >= MIN_CRYPTO_VERSION])
cryptopp_file_with_version="cryptlib.h"
CRYPTOPP_STYLE="unknown"
CRYPTOPP_LIB_NAME="unknown"
cryptopp_includedir="unknown"
CRYPTOPP_INCLUDE_PREFIX="unknown"
cryptopp_libdir="unknown"
AS_IF([test -n "$with_crypto_prefix"], [
# Find the Cryptopp header in the user-provided location
AS_IF([test -f $with_crypto_prefix/$cryptopp_file_with_version], [
CRYPTOPP_STYLE="sources"
CRYPTOPP_LIB_NAME="cryptopp"
cryptopp_includedir=
CRYPTOPP_INCLUDE_PREFIX="$with_crypto_prefix"
cryptopp_libdir=
], AS_IF([test -f $with_crypto_prefix/include/cryptopp/$cryptopp_file_with_version], [
CRYPTOPP_STYLE="installed"
CRYPTOPP_LIB_NAME="cryptopp"
cryptopp_includedir="$with_crypto_prefix/include"
CRYPTOPP_INCLUDE_PREFIX="$CRYPTOPP_LIB_NAME"
cryptopp_libdir="$with_crypto_prefix/lib"
], AS_IF([test -f $with_crypto_prefix/include/crypto++/$cryptopp_file_with_version], [
# Debian uses libcrypto++5.1 - it's not my fault, please soda patch the package
CRYPTOPP_STYLE="gentoo_debian"
CRYPTOPP_LIB_NAME="crypto++"
cryptopp_includedir="$with_crypto_prefix/include"
CRYPTOPP_INCLUDE_PREFIX="$CRYPTOPP_LIB_NAME"
cryptopp_libdir="$with_crypto_prefix/lib"
])))
], [
for CRYPTOPP_PREFIX in /usr /usr/local /opt /opt/local /usr/pkg /mingw ; do
# Find the Cryptopp header in system locations
AS_IF([test -f $CRYPTOPP_PREFIX/$cryptopp_file_with_version], [
CRYPTOPP_STYLE="sources"
CRYPTOPP_LIB_NAME="cryptopp"
cryptopp_includedir=
CRYPTOPP_INCLUDE_PREFIX="$CRYPTOPP_PREFIX"
cryptopp_libdir=
break
], AS_IF([test -f $CRYPTOPP_PREFIX/include/cryptopp/$cryptopp_file_with_version], [
CRYPTOPP_STYLE="installed"
CRYPTOPP_LIB_NAME="cryptopp"
cryptopp_includedir="$CRYPTOPP_PREFIX/include"
CRYPTOPP_INCLUDE_PREFIX="$CRYPTOPP_LIB_NAME"
cryptopp_libdir="$CRYPTOPP_PREFIX/lib"
break
], AS_IF([test -f $CRYPTOPP_PREFIX/include/crypto++/$cryptopp_file_with_version], [
# Debian uses libcrypto++5.1 - it's not my fault, please soda patch the package
CRYPTOPP_STYLE="gentoo_debian"
CRYPTOPP_LIB_NAME="crypto++"
cryptopp_includedir="$CRYPTOPP_PREFIX/include"
CRYPTOPP_INCLUDE_PREFIX="$CRYPTOPP_LIB_NAME"
cryptopp_libdir="$CRYPTOPP_PREFIX/lib"
break
])))
done
])
AS_IF([test $CRYPTOPP_STYLE = "unknown"], [result=no; resultstr=""], [
# Find out the crypto++ version and check against the minimum required
cryptopp_header_path="${cryptopp_includedir+$cryptopp_includedir/}$CRYPTOPP_INCLUDE_PREFIX/$cryptopp_file_with_version"
CRYPTOPP_VERSION_STRING=`$EGREP "Reference Manual|API Reference" $cryptopp_header_path | sed -e ['s/[^0-9]*\([0-9.]*\).*/\1/']`
CRYPTOPP_VERSION_NUMBER=`echo $CRYPTOPP_VERSION_STRING | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
minvers=`echo MIN_CRYPTO_VERSION | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
AS_IF([test -n "$CRYPTOPP_VERSION_NUMBER" && test "$CRYPTOPP_VERSION_NUMBER" -ge $minvers], [
result=yes
resultstr=" (version $CRYPTOPP_VERSION_STRING, $CRYPTOPP_STYLE)"
AS_IF([test -n "$cryptopp_includedir"], [CRYPTOPP_CPPFLAGS="-I$cryptopp_includedir"], [CRYPTOPP_CPPFLAGS=])
AS_IF([test -n "$cryptopp_libdir"], [
CRYPTOPP_LDFLAGS="-L$cryptopp_libdir"
CRYPTOPP_LIBS="-l$CRYPTOPP_LIB_NAME"
], [
CRYPTOPP_LDFLAGS=
CRYPTOPP_LIBS="${CRYPTOPP_INCLUDE_PREFIX}/lib${CRYPTOPP_LIB_NAME}.a"
])
AH_TEMPLATE([CRYPTOPP_INCLUDE_PREFIX], [Define this to the include prefix of crypto++])
AC_DEFINE_UNQUOTED([CRYPTOPP_INCLUDE_PREFIX], $CRYPTOPP_INCLUDE_PREFIX)
], [
result=no
resultstr=" (version $CRYPTOPP_VERSION_STRING is not new enough)"
])
])
AC_MSG_RESULT([$result$resultstr])
AS_IF([test ${result:-no} = yes], [$2], [$3])
dnl Exported symbols
AC_SUBST([CRYPTOPP_CPPFLAGS])dnl
AC_SUBST([CRYPTOPP_LDFLAGS])dnl
AC_SUBST([CRYPTOPP_LIBS])dnl
m4_undefine([MIN_CRYPTO_VERSION])dnl
])

View File

@ -33,7 +33,7 @@
#include "ChunkSendThread.h"
#include <algorithm>
#include <memory.h>
#define CLIENT_TIMEOUT 120
#define CHECK_BASE_PATH
@ -166,7 +166,7 @@ void CClientThread::EnableNagle(void)
{
once=false;
int opt=1;
int err=setsockopt(mSocket, IPPROTO_TCP, TCP_CORK, (char*)&opt, sizeof(int) );
int err=setsockopt(int_socket, IPPROTO_TCP, TCP_CORK, (char*)&opt, sizeof(int) );
if( err==SOCKET_ERROR )
{
Log("Error: Setting TCP_CORK failed. errno: "+nconvert(errno), LL_WARNING);
@ -655,7 +655,7 @@ bool CClientThread::ProcessPacket(CRData *data)
size_t count=(std::max)((size_t)s_bsize, (size_t)(filesize-foffset));
if( clientpipe==NULL && ( id==ID_GET_FILE || id==ID_GET_FILE_RESUME ) )
{
sendfile64(mSocket, hFile, &foffset, count);
sendfile64(int_socket, hFile, &foffset, count);
}
else
{
@ -665,7 +665,7 @@ bool CClientThread::ProcessPacket(CRData *data)
rc=SendInt(buf, rc);
if(rc==SOCKET_ERROR)
{
LOG("Error: Sending data failed");
Log("Error: Sending data failed");
CloseHandle(hFile);
return false;
}
@ -1062,7 +1062,7 @@ bool CClientThread::GetFileBlockdiff(CRData *data)
if(hFile == INVALID_HANDLE_VALUE)
{
hFile=NULL;
hFile=(HANDLE)NULL;
#ifdef CHECK_BASE_PATH
std::wstring basePath=map_file(getuntil(L"/",o_filename)+L"/");
if(!isDirectory(basePath))
@ -1094,10 +1094,17 @@ bool CClientThread::GetFileBlockdiff(CRData *data)
sendfilepart=0;
sent_bytes=0;
#ifdef _WIN32
LARGE_INTEGER filesize;
GetFileSizeEx(hFile, &filesize);
curr_filesize=filesize.QuadPart;
#else
struct stat64 stat_buf;
fstat64(hFile, &stat_buf);
curr_filesize=stat_buf.st_size;
#endif
next_checkpoint=start_offset+c_checkpoint_dist;
if(next_checkpoint>curr_filesize)
@ -1106,7 +1113,7 @@ bool CClientThread::GetFileBlockdiff(CRData *data)
CWData sdata;
sdata.addUChar(ID_FILESIZE);
sdata.addUInt64(filesize.QuadPart);
sdata.addUInt64(curr_filesize);
SendInt(sdata.getDataPtr(), sdata.getDataSize());
if(mutex==NULL)
@ -1119,7 +1126,7 @@ bool CClientThread::GetFileBlockdiff(CRData *data)
if(chunk_send_thread_ticket==ILLEGAL_THREADPOOL_TICKET)
{
IFile * tf=Server->openFileFromHandle(hFile);
IFile * tf=Server->openFileFromHandle((void*)hFile);
if(tf==NULL)
{
Log("Could not open file from handle", LL_ERROR);
@ -1130,14 +1137,14 @@ bool CClientThread::GetFileBlockdiff(CRData *data)
else
{
IScopedLock lock(mutex);
update_file=Server->openFileFromHandle(hFile);
update_file=Server->openFileFromHandle((void*)hFile);
if(update_file==NULL)
{
Log("Could not open update file from handle", LL_ERROR);
}
cond->notify_all();
}
hFile=NULL;
hFile=(HANDLE)NULL;
return true;
}

View File

@ -6,6 +6,8 @@
#include <windows.h>
#include <WinBase.h>
#define MSG_NOSIGNAL 0
#else
#define HANDLE int
#endif
#include <deque>

View File

@ -1,4 +1,4 @@
lib_LTLIBRARIES = liburbackupclient_fileservplugin.la
liburbackupclient_fileservplugin_la_SOURCES = dllmain.cpp ../stringtools.cpp bufmgr.cpp CampusThread.cpp CClientThread.cpp CriticalSection.cpp CTCPFileServ.cpp CUDPThread.cpp data.cpp download.cpp FileServ.cpp FileServFactory.cpp log.cpp main.cpp map_buffer.cpp pluginmgr.cpp tcpstack.cpp
noinst_HEADERS = bufmgr.h CUDPThread.h FileServFactory.h IFileServ.h packet_ids.h socket_header.h CampusThread.h CriticalSection.h data.h FileServ.h log.h pluginmgr.h tcpstack.h CClientThread.h CTCPFileServ.h download.h IFileServFactory.h map_buffer.h settings.h types.h
liburbackupclient_fileservplugin_la_SOURCES = dllmain.cpp ../stringtools.cpp bufmgr.cpp CampusThread.cpp CClientThread.cpp CriticalSection.cpp CTCPFileServ.cpp CUDPThread.cpp data.cpp download.cpp FileServ.cpp FileServFactory.cpp log.cpp main.cpp map_buffer.cpp pluginmgr.cpp ../urbackupcommon/fileclient/tcpstack.cpp
noinst_HEADERS = bufmgr.h CUDPThread.h FileServFactory.h IFileServ.h packet_ids.h socket_header.h CampusThread.h CriticalSection.h data.h FileServ.h log.h pluginmgr.h ../urbackupcommon/fileclient/tcpstack.h CClientThread.h CTCPFileServ.h download.h IFileServFactory.h map_buffer.h settings.h types.h
AM_CXXFLAGS = -DLINUX

View File

@ -1421,6 +1421,7 @@ void IndexThread::execute_postbackup_hook(void)
pid1 = fork();
if( pid1==0 )
{
setsid();
pid_t pid2;
pid2 = fork();
if(pid2==0)