Commit graph

5843 commits

Author SHA1 Message Date
Patrick Ohly
ec32dd02d0 runtests.py: disable rpm packaging
When building on the new syncevolution.org reference platform, Ubuntu Trusty,
building rpm packages with checkinstall fails for unknown reasons. As
providing those rpms is of questionable value (libraries are more likely to be
different on rpm-based distros than on Debian/Ubuntu), building rpm simply
gets disabled entirely.

As a fallback for users there still are the plain .tar.gz archives containing
the same files.
2016-09-26 12:58:26 +02:00
Patrick Ohly
0c90fff232 runtests.py: don't run tests unless explicitly enabled
Previously, when --enabled was not given, all tests were run.  That was meant
to simplify running all tests, but that is rare and more likely to happen by
mistake when not selecting tests correctly in the automated testing, so now we
revert the logic and don't select a test if no --enable filter is set.
2016-09-26 12:58:26 +02:00
Patrick Ohly
40c801ccf9 runtests.py: fix XDG dir fallback
The XDG symlinks were created as fallback in case that the XDG env variables
somehow were ignored. In practice, the symlinks were not needed, so it didn't
matter that they were set incorrectly to the path name outside of the chroot.
But it's confusing when debugging the setup and just plain wrong, so better
fix it...
2016-09-26 12:58:26 +02:00
Patrick Ohly
d0d778ed99 runtests.py: make published test results world-readable
client-test makes new directories user-readable because that is
the default for all SyncEvolution directories. But after publishing
the test results, they need to be world-readable, because they are
going to be accessed via some kind of web server running under
some different user.
2016-09-26 12:58:26 +02:00
Patrick Ohly
f183271d65 autotools: allow extending core linker flags
These linker flags are added to those normally used for linking against
libsyncevolution. The intended usage is to extend linking of syncevolution.org
binaries such that static versions of libcppunit, libpcrecpp and libopenobex
are used, because the ABI of those libs have changed such that binaries linked
on Ubuntu Trusty would not run on more recent distros like Ubuntu Xenial.

For example, on Ubuntu Trusty i386 one can configure with:
   PCRECPP_LIBS=-lpcre \
   LIBOPENOBEX_LIBS=-lpcre \
   '--with-extra-core-ldadd=/usr/lib/i386-linux-gnu/libpcrecpp.a -lpcre /usr/lib/libopenobex.a /usr/lib/i386-linux-gnu/libusb.a' \
   CPPUNIT_LIBS=/usr/lib/i386-linux-gnu/libcppunit.a
2016-09-26 12:58:26 +02:00
Patrick Ohly
33dce914e8 autotools: use cppcheck.pc
Now cppcheck is found via the normal PKG_CHECK_MODULES. The advantage
is that CPPUNIT_CFLAGS and CPPUNIT_LIBS can be overridden with
configure parameters, which will be used to link cppcheck statically
into syncevolution.org binaries (libcppunit ABI has changed).
2016-09-20 07:00:28 -07:00
Patrick Ohly
499c1c72d5 syncevolution.org: drop binary compatibility hack for old libnotify
syncevolution.org binaries are going to support distros >= Ubuntu Trusty.
All of those have libnotify.so.4, so the old binary compatibility hack is
no longer needed.
2016-09-20 06:51:11 -07:00
Patrick Ohly
bf3c8d5361 ClientTest.cpp: fix clang warning
SOURCE_ASSERT_EQUAL() expects to get an expression as first parameter
which may become NULL. Passing a known-non-NULL pointer makes no sense
and triggers a warning from clang:

ClientTestAssert.h:109:50: error: nonnull argument 'copy' compared to NULL
[-Werror=nonnull-compare]
 # define CT_ASSERT_TRUE_CLANG_BUILD(_expression) if (!(_expression)) {
 exit(1); }
...                                                  ^
ClientTest.cpp:859:5: note: in
expansion of macro 'SOURCE_ASSERT_EQUAL'
SOURCE_ASSERT_EQUAL(&copy, 0, config.m_dump(client, copy, copyFile));
2016-08-29 04:59:38 -07:00
Patrick Ohly
a53e5289bd dbus-sync.cpp: fix cppcheck performance warning
cppcheck correctly warned that initializing a reference is enough,
no need to copy the string:

dbus-sync.cpp:97: cppcheck performance: passedByValue - Function parameter
'source' should be passed by reference.
2016-08-29 04:58:24 -07:00
Patrick Ohly
16e6e854c3 gdbus-cxx-bridge.h: avoid false cppcheck warning
cppcheck seems to mix up different template variations. The following error
needs to be suppressed in the classes which don't even have an m_a member:

gdbus-cxx-bridge.h:330: cppcheck warning: uninitMemberVar - Member variable
'Set::m_a' is not initialized in the constructor.
gdbus-cxx-bridge.h:339: cppcheck warning: uninitMemberVar - Member variable
'Set::m_a' is not initialized in the constructor.
2016-08-29 04:55:24 -07:00
Patrick Ohly
d560aeda07 compilation: fix std::find() == 0 misuse
cppcheck correctly warns about the old code as less efficient (looks
at entire string instead of just the start). Using boost::starts_with
is less obscure and avoids the warning.
2016-08-29 04:52:49 -07:00
Patrick Ohly
f7dbb2ed72 runtests.py: better logging of failed command
When execution of a command fails, then printing the actual
string passed to system() is more readable and accurate than
the original array.
2016-08-26 11:20:30 -07:00
Patrick Ohly
2b4b93f1ab compilation: fix const/non-const issue under C++14/gcc 6
Building client-test fails because a const pointer looses the
const attribute while passing it through boost::bind.

Fixes:

boost/lambda/detail/function_adaptors.hpp:357:16: error: invalid conversion
from 'const SyncEvo::SyncSource*' to 'SyncEvo::SyncSource*' [-fpermissive]
return func(a1);
2016-08-26 11:18:20 -07:00
Patrick Ohly
14452722fd compilation: fix push_back ambiguity under gcc 6/C++14
When compiling as C++14 (the default under gcc 6), template
expansion no longer picks the right instantiation of push_back.
We have to disambiguate which of the different push_back
alternatives we want.

Fixes:

Cmdline.cpp:1734:85: error: no matching function for call to 'bind(<unresolved
overloaded function type>, const boost::reference_wrapper<std::__cxx11::list<std::__cxx11::basic_string<char> >
>, const boost::arg<1>&)'
     processLUIDs(source, boost::bind(&list<string>::push_back, boost::ref(luids), _1));
2016-08-26 11:15:23 -07:00
Patrick Ohly
3299613591 compilation: fix boost::shared_ptr->bool issue under C++14
The implicit conversion of boost::shared_ptr->bool is no
longer supported when compiling as C++14 (the default under
gcc 6). We have to cast explicitly.

Fixes errors like this:

Logging.h:258:41: error: cannot convert 'const boost::shared_ptr<SyncEvo::Logger>' to 'bool' in return
         operator bool () const { return m_logger; }
2016-08-26 11:14:44 -07:00
Patrick Ohly
4e2dd07580 autotools: disable timezone override hack when using libical v2
libical v2 provides support for interoperable timezone definitions
again, so the copy of the original code that was added for libical v1
is not needed anymore and also wouldn't compile.

Therefore SyncEvolution can drop it when being compiled for v2. In that
case, a corresponding change in libsynthesis calls
icaltzutil_set_exact_vtimezones_support(0) to enable interoperable
timezones.

This addresses compilation and running with libical v2, i.e. what
normal distros are doing. Compiling with libical v1 and running
with v2 needs to be addressed separately, if possible at all.
2016-08-26 09:15:22 -07:00
Patrick Ohly
bbfe468290 mkdir_p: support non-readable parent directories (FDO #91000)
The previous mkdir_p() walked down top to bottom and checked each path
entry as it went along. That approach failed unnecessarily when some
existing parent directory could not be read (non-readable /home, for
example).

The new version tries to create the lowest directories first
(brute-force) and only walks up when that is necessary to avoid an
ENOENT.
2015-08-14 18:42:47 +02:00
Patrick Ohly
5a7bb9b572 autotools, NEWS: SyncEvolution 1.5.1 2015-06-05 14:58:41 +02:00
frdsktp
bcf21809d5 syncevo-http-server: stop using deprecated twisted.web.error (FDO #90419)
twisted.web.error.NoResource was replaced by
twisted.web.resource.NoResource.  This has become a real problem for
example on Fedora 22 where the old name is no longer available.
2015-06-05 14:31:43 +02:00
Patrick Ohly
a5f0139a10 syncing: avoid segfault for invalid text inside items (FDO #90118)
As reported by Canonical, syncing fails if data items contain
text which is not correct UTF-8 in one of the fields that
SyncEvolution logs in the command line output (like SUMMARY of
a calendar event).

That is because the byte string coming from the item is passed
unchecked to the D-Bus implementation for transmission via D-Bus. But
D-Bus strings must be correct UTF-8, so depending on the D-Bus library
in use, one gets a segfault (GIO D-Bus, due to an unchecked NULL
pointer access) or an "out of memory" error (libdbus, which checks for
NULL).

What the D-Bus bindings now do is checking the string in advance (to
avoid error messages inside the D-Bus implementations) and then
replacing all invalid bytes with question marks. The rest of the
string is preserved.

Handling this inside the D-Bus binding layer is not the "correct"
solution (which would be to check for UTF-8 in the higher layers were
such bad data might get into SyncEvolution), but it is the less
intrusive and more complete one. Changing the bindings such that all
strings must be declared explicitly as "UTF-8 string" would have been
a way to find all places where such checks are missing, but it turned
out to be too complex and requiring too many changes.
2015-06-05 05:26:26 -07:00
Patrick Ohly
1385ac43fb file backend: log item manipulation
Extracting a meaningful description of each item from the Synthesis
engine when updating and adding items is easy to do for items of
certain known types (contacts and calendar items) and arguably an
improvement; in particular it makes tests like
TestCmdline.testSyncOutput more realistic.
2015-06-01 14:23:46 +02:00
Patrick Ohly
c9a7cf1901 D-Bus testing: check sync result on both sides of TestLocalSync.testSync
Checking that the item still exists on the side where it was created
is okay, but it is more important to check that it also reached the
other side.
2015-06-01 14:22:19 +02:00
Patrick Ohly
0ac91f5658 command line: preserve log prefix of target side of local sync
In some cases, the prefix which was supposed to be embedded
in the log messages from the target side of a local sync got
lost on the way to the command line tool.

Primarily this affected the added/updated/deleted messages, as in:

[INFO remote@client] @client/addressbook: started
[INFO remote@client] updating "Joan Doe"
[INFO remote@client] @client/addressbook: received 1/1

This was not caught by automated testing because the corresponding
test (TestCmdline.testSyncOutput and TestCmdline.testSyncOutput2) is
using the file backend, which does not generate such messages at the
moment (to be changed separately).
2015-06-01 14:17:14 +02:00
Niels Ole Salscheider
cd93586d0b Use ${PKG_CONFIG} instead of pkg-config.
This fixes the build on Exherbo that only has prefixed versions of pkg-config.
2015-04-17 10:41:44 +02:00
Patrick Ohly
84a30285a9 WebDAV: handle 403 during Google OAuth authentication
When sending an access token with insufficient scope (for example,
because the Ubuntu Online Accounts service definition was incomplete,
as documented in FDO #86824), Google responds with a 403 "service
denied" error.

Neon (arguably correctly) treats this as a permanent error and not
as a transient authentication error. Google should better send
a 401 error.

To activate the 401 error handling in SyncEvolution, detect this
special case and turn the general SE_ERROR error into SE_AUTH.
2015-03-03 10:44:03 +01:00
Patrick Ohly
d84f323398 signon: ensure consistent use of "username" provider prefix
The Ubuntu Online Accounts signon backend complained about
invalid "username" content with an error message containing "sso",
the string used for gSSO.

Define these magic strings once and then use only the defines.
2015-03-03 10:44:03 +01:00
Alberto Mardegan
9acfd11de7 signon-accounts: implement getCredentials
Use the information contained in the AgAuthData object to decide which
authentication method is being used.
Move the common authentication code into a private authenticate()
method.

[PO: fixed g_variant_builder_end() mem leak]
[PO: avoid issue found via cppcheck: returning std::string::c_str() in
a method returning a std::string forces a string copy, which is
inefficient.]
[PO: UiPolicy was not set because of an invalid g_variant_builder_add()
"sv" parameter.]
2015-03-03 10:43:26 +01:00
Alberto Mardegan
c58ed9ff59 signon-accounts: pass the AgAuthData to the SignonAuthProvider
Instead of passing the session data and the mechanism, pass the full
AgAuthData object to the SignonAuthProvider constructor.
This object can be used to build the session data without converting all
dictionaries to and from GHashTable.

[PO: fixed g_variant_builder_end() mem leak]
[PO: ForceTokenRefresh was not set because of an invalid g_variant_builder_add()
"sv" parameter.]
2015-03-03 10:41:52 +01:00
Alberto Mardegan
382c81e70f signon-accounts: do not create identities on the fly
It's not sync-evolution task to complete the account creation; in those
platforms where this backend is deployed (Ubuntu, Elementary, KDE) the
account should already be created with a proper SignonIdentity attached
to it.
2015-03-03 10:30:53 +01:00
Alberto Mardegan
ff12834be1 AuthProvider: removed failure count
Remove the failure count from the getOAuth2Bearer() method, and add an
invalidateCachedSecrets() method instead.

This moves the logic of how to deal with failures back to the
AuthProvider backend and simplifies the session code, which only needs
to call invalidateCachedSecrets() when the token is wrong.
This will help implementing a similar logic for the getCredentials()
method, where authentication errors could lead to requesting a new
password.

[PO: avoid issue found via cppcheck: returning std::string::c_str() in
a method returning a std::string forces a string copy, which is
inefficient.]
2015-03-03 10:30:29 +01:00
Alberto Mardegan
ab4524ab9f signon: move libaccounts-based plugins into their own source file
The libaccounts-based backends ("gsso" and "uoa") are going to use more
of libaccounts-glib, making sharing of code with the plain "signon"
plugin much harder to maintain.
2015-03-03 10:15:44 +01:00
Patrick Ohly
75115022c5 CalDAV: more efficient "is empty" check (FDO #86335)
Since 1.4.99.4, syncing WebDAV collections always checks first
whether there are items in the collections. This was partly done for
slow sync prevention (which is not necessary for empty collections),
partly for the "is the datastore usable" check.

However, this did not take into account that for CalDAV collections,
the entire content gets downloaded for this check. That is because
filtering by item type (VEVENT vs. VJOURNAL) is not implemented
correctly by all servers. So now all CalDAV syncs, whether incremental
or slow, always transfered all items, which is not the
intention (incremental syncs should be fast and efficient).

This commit adds a more efficient isEmpty() check: for simple CardDAV
collections, only luid and etag get transferred, as in
listAllItems(). This is the behavior from 1.5.

For CalDAV, a report with a filter for the content type is used and
the transfer gets aborted after the first item, without actually
double-checking the content of the item. This is different from
listAllItems(), which really transfers the content. This extra content
check would only be needed for some old servers (Radical 0.7) and is
not essential, because reporting "not empty" even when empty is safe.
2015-03-03 10:15:44 +01:00
Patrick Ohly
7e5638fd90 WebDAV: utility class for ne_status
Besides offering C++ wrappers for the C API, this class also ensures
that memory for the "reason_string" is properly freed.
2015-03-03 10:15:44 +01:00
Patrick Ohly
85df49a68b WebDAV: enhance report handling (status, aborting)
Capture the item status and pass it to the response handler.

Response handlers are allowed to return a non-zero integer when using
the initAbortingReportParser(), which then aborts processing of the
response.

This leads to errors being returned by
ne_xml_dispatch_request(). Session::run() needs to be told if the
request was aborted, in which case all errors are ignored.
2015-03-03 10:15:44 +01:00
Patrick Ohly
905ca53824 WebDAV: send Basic Auth via http in some cases (FDO #57248)
It turned out that finding databases on an Apple Calendar server accessed via
http depends on sending Basic Auth even when the server does not ask for it:
without authentication, there is no information about the current principal,
which is necessary for finding the user's databases.

To make this work again, sending the authentication header is now forced for
plain http if (and only if) the request which should have returned the
principal URL fails to include it. This implies sending the same request
twice, but as this scenario should be rare in practise (was only done for
testing), this is acceptable.
2015-03-03 10:15:44 +01:00
Patrick Ohly
096b7e61aa wrappercheck.sh: enhanced killing of daemon
Occasionally the script shutdown got stuck on Ubuntu Vivid because killing
the background daemon failed although it was still runnning, thus causing the
wait to hang forever.

Not exactly sure what caused this. The enhancement tries to fall back to
killing the process instead of the process group (in case that there is
a race condition, which shouldn't be the case when waiting for the daemon),
preserves stderr from the kill commands and adds ps output when there is
an unexpected failure.
2015-03-03 10:15:44 +01:00
Patrick Ohly
f4f83c1540 wrappercheck.sh: route daemon stderr through logger.py
Only stdout got passed through logger.py before. stderr ended up
in the daemon log unmodified.
2015-03-03 10:15:44 +01:00
Patrick Ohly
f192b140eb wrappercheck.sh: add --wait-for-dbus-daemon
EDS 3.12 on Ubuntu Vivid no longer prints the message about obtaining
the D-Bus name. Instead we need to wait for it to show up on the session
bus.
2015-03-03 10:15:44 +01:00
Patrick Ohly
f7b19f645e wrappercheck.sh: avoid kill without process pids
During exit, check whether there are really processes to be killed.
Avoids some error messages from the bogus kill invocation.
2015-03-03 10:15:44 +01:00
Patrick Ohly
a8e39070d6 testing: relax SyncEvo::IcalTest::testTimezone
The test started to fail in 2015 because the VTIMEZONE generated by
the code copied from libical has a minor dependency on the current
time: it finds the transitions for the current year, then pretends
that the same rule applied since 1970. While doing that, it uses this
years transition date and just replaces the year. Because the exact
date varies between years, the result depends on the current year.

The test now simply ignores the day of the month, while still checking
year and month. Those should always be the same.
2015-03-03 10:15:44 +01:00
Patrick Ohly
4e60b67c27 testing: ignore dl error on Ubuntu Vivid 2015-03-03 10:14:19 +01:00
Patrick Ohly
fa27793134 PlainGStr: fix incorrect destruction when using reset()
When storing a pointer with PlainGStr::reset(), the default delete []
was used to free the memory. Should have used g_free(), as in the
constructor. Affects the signon backend.
2015-03-03 10:14:19 +01:00
Patrick Ohly
0c5f9c5170 StringPrintfV: add missing va_end()
When returning prematurely, va_end() was not called. This is a
potential resource leak. Found with cppcheck 1.67.
2015-03-03 10:14:19 +01:00
Patrick Ohly
4bedb549b3 gdbus: add missing va_end()
When returning prematurely, va_end() was not called. This is a
potential resource leak. Found with cppcheck 1.67.
2015-03-03 10:14:19 +01:00
Patrick Ohly
b74f7273fa PullParams: cleaner initialization
cppcheck warned about the non-portable initialization of a float
via memset. It is okay on all current architectures, but better
assign a real float 0 value anyway, while keeping the memset for
the rest of the elements.

The second memset() had already become redundant when adding the
PullParams constructor.
2015-03-03 10:14:19 +01:00
Patrick Ohly
08ba09df04 shutdown: fix memory allocation deadlock
When the SuspendFlags::handleSignal() signal handler got called while
the program was allocating memory in libc, a deadlock occurred when
the mutex locking code in RecMutex::lock() tried to allocate the guard
instance (see backtrace below).

This could be fixed with new mutex code which gives up the guard
concept, a guard concept using C11 mechanisms (copy semantic of a
stack-allocated guard) or not locking at all in getSuspendFlags().

This commit uses the latter. It is simpler and can still be done
correctly because locking is not necessary except when the singleton
has not been allocated yet. That part gets moved into the process
startup phase via SyncContext::initMain().

Thread 1 (Thread 0x7fec389e6840 (LWP 16592)):
    at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
   from /lib/x86_64-linux-gnu/libc.so.6
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    d=<optimized out>, p=0x7fec38196f60 <SyncEvo::suspendRecMutex>,
    this=<synthetic pointer>)
    at /usr/include/boost/smart_ptr/detail/shared_count.hpp:167
    p=0x7fec38196f60 <SyncEvo::suspendRecMutex>, this=<synthetic pointer>)
    at /usr/include/boost/smart_ptr/shared_ptr.hpp:363
    this=<synthetic pointer>)
    at /data/runtests/work/sources/syncevolution/src/syncevo/ThreadSupport.h:60
    at /data/runtests/work/sources/syncevolution/src/syncevo/ThreadSupport.h:81
    at /data/runtests/work/sources/syncevolution/src/syncevo/SuspendFlags.cpp:58
    at /data/runtests/work/sources/syncevolution/src/syncevo/SuspendFlags.cpp:280
    oldp=0x115b7d0, oldsize=80, nb=48) at malloc.c:4208
    at malloc.c:3029
    n_bytes=n_bytes@entry=32)
2015-03-03 10:14:19 +01:00
Patrick Ohly
c61db46f8d syncevolution.org binaries: allow libical1a
Because of the confustion around the libical 1.0 ABI, Debian ended
up renaming the package for Debian Jessie while keeping the libical.so.1
soname. Pre-built binaries from older distros work, so just adapt
the package meta data.
2015-03-03 10:14:19 +01:00
Patrick Ohly
112c932432 glib: fix TrackGLib::ref()
The class is used for non-GObject types, so we must use a
type-specific method to increase the
ref-count. intrusive_ptr_add_ref() does that automatically for us.
Calling g_object_ref() was a cut-and-paste error.
2015-02-09 15:02:22 +01:00
Tino Mettler
89dbb2d223 Use TLS instead of SSLv3
This fixes a potential security risk and connection problems with clients
that don't support SSLv3 anymore.

Closes: #772040
2014-12-12 08:45:24 +01:00
Patrick Ohly
0511cb1dcf GDBus GIO: fix compilation on s390 32bit, II (Fedora Bug #1163188)
The previous commit for the problem caused a compilation error
in the PBAP backend, because Bluez uses a 64 bit type that no longer
had a type trait on 32 bit architectures.

Adding "[unsigned] long long" traits fixes that. It seems to work
also on 64 bit architectures, so I am not adding any ifdefs and just
enable it unconditionally.
2014-12-11 23:29:26 -08:00