Commit Graph

5980 Commits

Author SHA1 Message Date
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
Patrick Ohly f4d91d4cef GDBus GIO: fix compilation on s390 32bit (Fedora Bug #1163188)
size_t is defined as unsigned long on s390 in 32bit mode, which is is not the
same type as uin32_t = unsigned int, which caused a compile failure due to the
missing type trait.

The solution is to define traits for all the standard language types instead
of the fixed-size types. This removes the 64 bit types on 32 bit platforms but
adds the types that were missing on s390.

All the types that we use in the D-Bus bindings are among these standard
types, so that is okay.
2014-11-17 23:33:41 -08:00
Patrick Ohly 97b2051c2d autotools, NEWS: SyncEvolution 1.5 2014-10-31 13:22:05 +01:00
Patrick Ohly 5e0680a448 signon: fix HashTable2Variant() ref counting (TC-1667)
This fixes a crash/memory corruption issue in the plain signon backend
as used in Tizen.

The real bug was that HashTable2Variant() creates a GHashTableCXX by
stealing a floating GVariant without actually acquiring the reference,
leading to various glib errors caused by double free and/or invalid
memory access.

The code in signon.cpp receiving the GHashTableCXX was correct, albeit
overly complicated (creating a new reference via g_variant_ref_sink()
explicitly instead of relying on GHashTableCXX semantic).
2014-10-31 13:22:04 +01:00
Patrick Ohly 37bd43cc20 autotools: bump libsynthesis requirement
We need a libsynthesis with RELAXEDCOMPARE().
2014-10-30 21:49:51 +01:00
Patrick Ohly 0f41165500 sync: ignore unnecessary username property
A local sync or Bluetooth sync do not need the 'username' property.
When it is set despite that, issue a warning.

Previously, the value was checked even when not needed, which
caused such syncs to fail when set to something other than a plain
username.
2014-10-24 16:42:34 +02:00
Patrick Ohly f3e1e10916 wrappercheck: augment output of daemon with time stamps
Useful for correlating events in the daemon with events in testing.
We need to use a process group to deliver SIGINT/SIGTERM, otherwise
we cannot be sure that we catch all processes created by the daemon.

The return code of the daemon was not checked before (accidentally?!)
and this patch does not change that. Might be fixed in the future.
2014-10-24 07:13:33 -07:00
Patrick Ohly 7a046c1998 wrappercheck: fix repeated daemon startup
The daemon log gets reused when starting daemons multiple times.
When starting a second time, the simple grep used to find the
output of the previous and did not wait properly. We need to count
matching lines and continue once a new one appears.
2014-10-24 07:06:38 -07:00
Patrick Ohly 3d2b8841ea wrappercheck: augment output
Multiple different wrappercheck instances are running concurrently
in the nightly testing, so better include a prefix with unique PID
in the "set -x" output to identify where it came from.
2014-10-24 07:04:49 -07:00
Patrick Ohly 18d301b37c wrappercheck: configurable sleep after daemon launch
When output checking isn't possible, allow sleeping for a configurable
amount of time.
2014-10-24 07:02:17 -07:00
Patrick Ohly c2dd6033ed D-Bus server: fix unreliable shutdown handling
Occassionally, syncevo-dbus-server locked up after receiving
a CTRL-C. This primarily affected nightly testing, in particular (?)
on Ubuntu Lucid.

The reason was two-fold:
- indirectly allocating memory when getSuspendFlags() had to
  allocated the guard instance of the mutex
- glib mutex held by some other thread when trying to do
  g_main_loop_quit().

SuspendFlags already handles signals without these problems. So
instead of overriding that, let SuspendFlags signal the receival
of a signal by writing to its FD and monitor that in our main
event loop, then quit the main event loop from inside the main
thread itself.
2014-10-24 05:25:04 -07:00
Patrick Ohly efedc4d4f1 glib: add GIOChannelCXX
Will be needed by D-Bus server when watching SuspendFlags FD.
2014-10-24 05:21:21 -07:00
Patrick Ohly 5668542116 testing: include stack backtrace when killing stuck process
The issue with malloc being called in niam() in syncevo-dbus-server
and deadlocking was only found after adding gdb's output of the
syncevo-dbus-server stack backtrace.
2014-10-10 03:19:45 -07:00
Patrick Ohly 9f04119d32 testing: ignore some minor leaks 2014-10-10 03:19:45 -07:00