summaryrefslogtreecommitdiff
path: root/common
AgeCommit message (Collapse)AuthorFilesLines
2019-08-26Add watermark opacity setting.Michael Meeks2-1/+14
Change-Id: I839e8aef91acfed40d4afd8c1b50176ed54c670a
2019-08-17wsd: Use unordered map for anonymizationAshod Nakashian1-5/+4
And simplify the trace-logging enablement check. Change-Id: I4f5c9e08912b8dbc708b191b80032660ce4e1ba0 Reviewed-on: https://gerrit.libreoffice.org/70742 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/71093
2019-08-17wsd: improved anonymization algorithmAshod Nakashian2-17/+28
Better hashing algorithm based on FNV-1a. Adds support for salting the hash, and for providing salt via configuration. More unit-tests added, and better formatting. Change-Id: I2be42675d0cdbaa73c3d7faed99e07631a9c20fc Reviewed-on: https://gerrit.libreoffice.org/70034 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/71091
2019-08-17wsd: cache the logger instance to avoid costly lookupsAshod Nakashian1-2/+10
Change-Id: Idf9261d46b44afc42a960146886c180e37d8d51f Reviewed-on: https://gerrit.libreoffice.org/69641 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/71085 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-08-15common: fix UB in vectorAppend()Miklos Vajna1-0/+6
unit-copy-paste with ubsan failed with: common/Util.hpp:751:43: runtime error: null pointer passed as argument 2, which is declared to never be null /usr/include/string.h:43:28: note: nonnull attribute specified here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior common/Util.hpp:751:43 in Change-Id: I71ae9b43a63f979c300d704419afc9a14cd303cd
2019-08-13common: wrap SigHandlerTrap in a getter function to avoid ODR violationMiklos Vajna2-4/+9
Otherwise both loolwsd and unit-copy-paste.so would have a SigHandlerTrap: ==26186==ERROR: AddressSanitizer: odr-violation (0x000002090ae0): [1] size=40 'SigHandlerTrap' ../common/SigUtil.cpp:76:12 [2] size=40 'SigHandlerTrap' common/SigUtil.cpp:76:12 These globals were registered at these points: [1]: #0 0x5f9a28 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_globals.cc:365 #1 0x7f8f537f1d8b in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/test/../test/.libs/unit-copy-paste.so+0x60ad8b) [2]: #0 0x5f9a28 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_globals.cc:365 #1 0xe2bcfe in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/loolwsd+0xe2bcfe) Change-Id: I54d5f6d4298848cacd437d302cff0e8c5003fb8c
2019-08-12Avoid assertion failure in the iOS appTor Lillqvist1-1/+4
There is just one process, and the UnitBase::Global is dummy, its type is irrelevant. Change-Id: I73fd0c32e50dd698161f25dbc3f4c8655776286a
2019-08-12common: wrap ShutdownRequestFlag in a getter function to avoid ODR violationMiklos Vajna2-3/+25
Otherwise both loolwsd and unit-copy-paste.so would have a ShutdownRequestFlag: ==13663==ERROR: AddressSanitizer: odr-violation (0x00000208f860): [1] size=1 'ShutdownRequestFlag' ../common/SigUtil.cpp:60:19 [2] size=1 'ShutdownRequestFlag' common/SigUtil.cpp:60:19 These globals were registered at these points: [1]: #0 0x5f9a18 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_globals.cc:365 #1 0x7f9b903f1d0b in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/test/../test/.libs/unit-copy-paste.so+0x60ad0b) [2]: #0 0x5f9a18 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_globals.cc:365 #1 0xe2b9fe in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/loolwsd+0xe2b9fe) Change-Id: I247760325f804813249e814dbb4576493619dee7
2019-08-09common: wrap DumpGlobalState in a getter function to avoid ODR violationMiklos Vajna2-4/+8
Otherwise both loolwsd and unit-copy-paste.so would have a DumpGlobalState: ==5783==ERROR: AddressSanitizer: odr-violation (0x00000208f7a0): [1] size=1 'DumpGlobalState' ../common/SigUtil.cpp:49:19 [2] size=1 'DumpGlobalState' common/SigUtil.cpp:49:19 These globals were registered at these points: [1]: #0 0x5f9a08 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_globals.cc:365 #1 0x7f5c5edf1c9b in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/test/../test/.libs/unit-copy-paste.so+0x60ac9b) [2]: #0 0x5f9a08 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_globals.cc:365 #1 0xe2b98e in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/loolwsd+0xe2b98e) Change-Id: I4b7b0238eb9b38a30875e8788c1dcb27f1d1643f
2019-08-08common: wrap TerminationFlag in a getter function to avoid ODR violationMiklos Vajna3-4/+14
Otherwise both loolwsd and unit-copy-paste.so would have a TerminationFlag: ==11732==ERROR: AddressSanitizer: odr-violation (0x00000208f4a0): [1] size=1 'TerminationFlag' ../common/SigUtil.cpp:41:19 [2] size=1 'TerminationFlag' common/SigUtil.cpp:41:19 These globals were registered at these points: [1]: #0 0x5f9988 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_globals.cc:365 #1 0x7f5df9cf18cb in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/test/../test/.libs/unit-copy-paste.so+0x60a8cb) [2]: #0 0x5f9988 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-472c6ef8b0f53061b049039f9775ab127beafbe4.src/compiler-rt/lib/asan/asan_globals.cc:365 #1 0xe2b4fe in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/loolwsd+0xe2b4fe) Change-Id: Ic620b143ecb77699f40676ff39d0fa7abceb34d5
2019-08-05clipboard: persist selections for a while after a view closes.Michael Meeks1-0/+64
re-factor ClientSession state to be a simpler state machine. Have a nice disconnect / disconnected handshake on view close. Change-Id: Ie933cc5c7dfab46c66f4d38a4d75c459aa1cff87
2019-08-05Fix ParseError on valid dataSzymon Kłos1-9/+12
Change-Id: I0706030d9933313e44ae89b92b62576dacbf7e9e
2019-08-05Sync request with clipboard parserSzymon Kłos1-3/+2
Allow to use multiple clipboard streams. Change-Id: Ib98a7c1db8738145138fa3657e94c404260e4a28
2019-08-05Fix build - potential use before initializationAshod Nakashian1-1/+1
Change-Id: I5d9db13b0241af64fa8e9eb9528a6e460166f280
2019-08-05clipboard - set it with a post now.Michael Meeks1-0/+81
Change-Id: I6b9234988185984335408da502f479ccda8a95a7
2019-08-05clipboard: a more helpful calc test.Michael Meeks1-0/+8
Change-Id: Ibe0e583a2019e7bc5968dd8f73cf4e4a07d363b2
2019-08-05Various copy/paste fixes, unit test passing, parsing of result.Michael Meeks1-1/+1
Change-Id: I9168853dd011e86896c3bd474a4d05ee82c0e336
2019-08-05Add hard random/hex key generation utility.Michael Meeks2-0/+24
Change-Id: I8bb95153a5bd63a6b41edf65a0fdf0ebd52ad070
2019-08-05Unit testing - add more hooks and helpers.Michael Meeks1-0/+12
Change-Id: Ieb12699e3b012606eaa0be3cc94d6f9b58adc441
2019-08-05Implement getClipboard and start of a unit test.Michael Meeks1-0/+21
includes Change-Id: I47d38f9285c855dcc6fbeeb73d35f22a46a30c05 Change-Id: I60b84bef1cf832ec5c191d664afd90a080b7ffbc
2019-08-05Switch to text/html for paste where we can.Michael Meeks3-0/+29
Build special URLs to detect the same host being in-use, and much more. Change-Id: I0ca639ea416cb78bf5e5274eac4400542b6b2cda
2019-07-26Don't combine tiles a long way from each other.Michael Meeks1-1/+1
We currently combine only horizontally, but ctrl-right arrow in calc can throw us to the other side of the sheet, creating a very large area to re-render. Change-Id: I7125ab815e3de1296b3af32632626005eeee0ec9
2019-07-24wsd: introduce "TemplateSource" WOPI propertyHenry Castro2-2/+7
Change-Id: I9df1d5d0d4be7fe10ee15c40c36195c86ccf857e Reviewed-on: https://gerrit.libreoffice.org/76190 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2019-06-04Log fatal errors also to stderrSamuel Mehrbrodt1-0/+2
Change-Id: I5e6429ab007d13a2506c375923049b91c80ffba0 Reviewed-on: https://gerrit.libreoffice.org/72722 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2019-05-27Revert "Get rid of use of GNU libtool" and its follow-upTor Lillqvist3-6/+5
The change causes problems for people on various sad distros. Oh well, whatever. This reverts commit bd00d9fd0576b8f249d2145d8570bc395d137dc1. This reverts commit 054a9cdb045a84c0d779ad47cbec0b11f28a4f06. Change-Id: Ie439e4c655d02b6f34bdd1a9c1c5b6db6048b653
2019-05-24Get rid of use of GNU libtoolTor Lillqvist3-5/+6
It is is complicated enough to build the iOS app. Requiring GNU libtool brings with it the risk of polluting the command environment as there already is a completely different command in macOS with the same name, /usr/bin/libtool. And as GNU libtool was used only to build the unit tests for the "normal" server-based Online that are built and run only on Linux anyway, we don't really need any of the "portability" that GNU libtool brings. Without GNU libtool, we compile all the $(wsd_sources) (see test/Makefile.am) that the unit-* tests use into a single object file, WsdSources.o. (Because they need to be compiled as PIC we can't use the already compiled object files for the Online server programs.) This required some additional minor changes to a few source files. Change-Id: I20a2c523170376fa4c1a0d9d8d6b693a9779376f Reviewed-on: https://gerrit.libreoffice.org/72840 Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com>
2019-05-231GB should be enough for developmentSamuel Mehrbrodt1-2/+7
Change-Id: I7567f99c4cf54a25084e25b44887b7906bbc7b06 Reviewed-on: https://gerrit.libreoffice.org/72827 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2019-05-23Drop unused variableTor Lillqvist1-5/+0
Change-Id: I927440f3c05956f3f244f6bc657a76a58e839231
2019-05-22Initial chunked transfer encoding.Michael Meeks1-0/+23
Important for convert-to on larger documents and/or with newer curls. Change-Id: Id18be6d22741a3af7cee39a069c509e4f662977b
2019-05-20Use compile-time rather than run-time string concatenation.Michael Meeks1-2/+2
Saves some time & space. Change-Id: If1e62056447fb7e8f26e8cf107451876adf3fecb
2019-05-20tdf#107038 Poco::DateTimeFormatter with Util::getHttpTimeNow()DarkByt312-0/+14
Added a function to Util to get current time in HTTP format using std::chrono. Change-Id: I9e7a732f585c1758c9348c450a01713a66f1e7b7 Reviewed-on: https://gerrit.libreoffice.org/72585 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-05-17debug: show WebSocketURI & a unique host id in help -> about.Michael Meeks2-0/+13
Rather useful for debugging clustering issues. Change-Id: I6d5f224bf8a3e4034c419137c8ad2b17fdf265ed
2019-05-16Introduce new flag to speed up shutdown of the Online plumbing in the iOS appTor Lillqvist2-0/+8
Spent hours on trying to cleverly use the existing TerminationFlag (with minor modifications to the code that checks it, and some additional code to set and reset it), but could not get it to work. This is simpler, but sure, using a global variable is ugly of course. At least the new MobileTerminationFlag is very specific in semantics and only used in the mobile apps. Change-Id: I0775fdfa7880750ca12c6fd7ec41d3d3ceb2f0ad
2019-05-16Use same kind of thread id as Xcode and osl_getThreadIdentifier() on iOSTor Lillqvist1-4/+12
Reduce the number of different kinds of identifiers for threads that are displayed in various places. Use the number that you get with pthread_threadid_np(), in hex, which is the same that Xcode (i.e. lldb) displays in its "thread list" command. It also is the same number that osl_getThreadIdentifier() returns. Change-Id: I0c14ad99badd7e742d15b7d1f37037fa66c892b4
2019-05-16No need to call Log::shutdown() in a mobile appTor Lillqvist2-0/+4
The process never exists voluntarily. It is killed by the OS when inactive and its resources are needed. Change-Id: I9a7fa8200a44bba8dfcd2b09882f1b87814025be
2019-05-10unipoll: restore missing asserts & some cleanup.Michael Meeks1-2/+2
Change-Id: I4277b5e044ead54d91bc834ea05bec649a608678
2019-05-10Unipoll: terminate repeated polling loop on wakeup.Michael Meeks1-0/+7
Wakeup wakes up the nested SocketPoll::poll nicely, but that's no use if we immediately ignore that and re-poll, so shorten the timeout in this case. Change-Id: I927d2375b92c9ce6c6ebe3f0ab33e2863894e2ef
2019-05-10Unipoll: move event processing into the same thread.Michael Meeks1-0/+9
Change-Id: I15aff3b5f18201eca915da94dbaa05148026e244
2019-05-08wsd: parse empty json string as empty mapAshod Nakashian1-1/+4
Change-Id: I11335e82e42e9f896ae33c2e57cb9d79b642171e Reviewed-on: https://gerrit.libreoffice.org/69633 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/71097 Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Tested-by: Szymon Kłos <szymon.klos@collabora.com>
2019-04-27Revert attempts at re-using ostringstreamMichael Meeks2-34/+17
Cleaning up the thread variable with the shared string stream is something of a nightmare, for a rather marginal gain. ==9296== Invalid write of size 1 ... ==9296== by 0x738C092: str (sstream:195) ==9296== by 0x738C092: std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::str(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (sstream:649) ==9296== by 0x65383A: Log::beginLog[abi:cxx11](char const*) (Log.cpp:141) ==9296== by 0x551823: Admin::~Admin() (Admin.cpp:381) ==9296== by 0x7D9ECF7: __run_exit_handlers (exit.c:83) ==9296== by 0x7D9ED49: exit (exit.c:105) ==9296== by 0x7D86F50: (below main) (libc-start.c:342) ==9296== Address 0x8ba41c0 is 0 bytes inside a block of size 513 free'd ==9296== at 0x4C2FA1D: operator delete(void*) (vg_replace_malloc.c:576) ... ==9296== by 0x738784A: ~basic_stringbuf (sstream:65) ==9296== by 0x738784A: std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream() (sstream:591) ==9296== by 0x7D9F27E: __call_tls_dtors (cxa_thread_atexit_impl.c:155) ==9296== by 0x7D9EC0A: __run_exit_handlers (exit.c:41) ==9296== by 0x7D9ED49: exit (exit.c:105) ==9296== by 0x7D86F50: (below main) (libc-start.c:342) Good to log during shutdown / exit. This reverts commit c315d219d5967f23fb1769e78021f61b8f9da6ec. This reverts commit ce78fec310ab5ab6aecabb73cad7d782afcb885f. Change-Id: Ia4a15be336d89d8d883530943724d48e4b0ec9fe Reviewed-on: https://gerrit.libreoffice.org/71444 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-04-27Reset the stringstream properly.Michael Meeks2-4/+5
Avoids some N^2 log-line explosion; also make the method name more findable. Change-Id: I3ee8c521f1ac98a939cd4d758c720b577d3bfa57 Reviewed-on: https://gerrit.libreoffice.org/71443 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2019-04-23wsd: reuse ostringstream when loggingAshod Nakashian2-17/+33
This is faster and reduces memory fragmentation. Also, cleans up the logging macros and implementation. Change-Id: I7fb00da041d1261c694c4b48b67a3c66ad0cbf8d Reviewed-on: https://gerrit.libreoffice.org/71020 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-04-23wsd: use thread_local instead of __threadAshod Nakashian1-2/+2
The former is the standard C++ approach and is reportedly faster than __thread (at least with gcc). Change-Id: Ibdefd32172774a280637f73dd062282b7bf62025 Reviewed-on: https://gerrit.libreoffice.org/71019 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-04-23wsd: use fast deflate level for pngAshod Nakashian1-0/+6
The default deflate level of 6 is quite slow and the benefits are hardly worth the high latency that users experience. Tested on a writer document with some small images and a few pages of text: Level 4 gives virtually identical compression ratio to level 6, but is between 5-10% faster. Level 3 runs almost twice as fast as level 6, but the output is typically 2-3x larger. Perhaps this should be exposed via config so it would be possible to reduce latency due to compression when CPU is scarce but network bandwidth ample, and vice versa. Change-Id: Iba88eea8f180d11458b33c68389e797234df1a60 Reviewed-on: https://gerrit.libreoffice.org/71018 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-04-23wsd: logging, comments, and const correctnessAshod Nakashian1-1/+3
Change-Id: Ibfbef282e951a80fb145239df4bbcc9f3e4c8e13 Reviewed-on: https://gerrit.libreoffice.org/71017 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2019-03-30Switch local prisoner sockets to abstract UDSMichael Meeks2-3/+4
Unix Domain Sockets are inaddressable remotely, and more efficient, as well as allowing future SCM_CREDENTIALS / SCM_RIGHTS. Change-Id: Ia2472260f75feb43e9022cdfa0fe005ccd489454
2019-03-22For iOS, generate the data: URLs for the PNG tiles already in the Online codeTor Lillqvist1-0/+18
(What we cache is also the textual data: URLs even if we store them using .png file names.) This avoids the current back-and-forth-encoding: First we base64-encode the complete binary "tile:" message (one text line followed by a newline and the binary PNG) to pass to WebKit, then in the JavaScript snippet passed to WebKit we decode the base64 and turn it into an ArrayBuffer, and then we unpack the ArrayBuffer and encode the PNG part to use as a data: URL.
2019-03-15Anonymization: don't log when it is disabled.Michael Meeks1-2/+6
Also fix unexpected concatenation error in Poco::URI::encode generating eg. authorid=localhost0 xauthorid=localhost0localhost0 in the output. Change-Id: I560e47e31884eeb1c662f468436ed7541cfb082d
2019-03-06Fix -Werror=stringop-truncation: Make sure FatalGdbString is NUL-terminatedTor Lillqvist1-1/+2
(Note that when I say 'NUL' I mean the ASCII character called NUL, i.e. a zero byte. Not to be confused with 'NULL'.) Why FatalGdbString has to be a C style fixed size char array I don't know. Or wait, I do know. Because SPEED!!! And using C strings safely is trivial. Change-Id: Id28b00a6e3219cf6f015c4209732f33216f83b22
2019-02-14TileCache: re-factor API to work in terms of vectors, not file references.Michael Meeks3-8/+5
Change-Id: Ia9d48773121ab965b79ddb16b55b5d3fdcd7fd5c