Commit graph

396 commits

Author SHA1 Message Date
Tor Lillqvist
0092414470 Handle LOK_CALLBACK_DOCUMENT_SIZE_CHANGED callbacks more cleverly
When a child process sends a documentsizechanged: message to the parent, to be
forwarded to the client, parse it and update a cached status of the doucment,
if available, and send an updated status: message to the client instead.

Note that clients should not rely on getting only status: messages and never
documentsizechanged: messages, though; the cache might be cleaned at any time
even while the server is running. If there is no cached status of the document
to update and re-use, we have to forward the documentsizechanged: message as
such to the client.
2015-05-28 12:53:14 +03:00
Tor Lillqvist
8166e9494f Post-release bump to 1.0.23 2015-05-28 10:35:07 +03:00
Tor Lillqvist
5150db06b9 Adapt to work with either 5.0 or 5.1 packages from TDF 2015-05-28 10:31:39 +03:00
Tor Lillqvist
fd7f83df92 Update from master 2015-05-28 10:27:43 +03:00
Tor Lillqvist
84819b6f0c Improve error handling 2015-05-27 21:44:39 +03:00
Miklos Vajna
d8d054fa47 LOOLSession: PAGE_COUNT -> DOCUMENT_SIZE 2015-05-27 17:34:10 +02:00
Tor Lillqvist
d54acdd6fb Post-release bump to 1.0.21 2015-05-27 16:48:32 +03:00
Tor Lillqvist
3747129da5 Bump version to 1.0.20 2015-05-27 16:47:50 +03:00
Tor Lillqvist
2e6719faaf Tweak where the systemplate and child-root directories are put
They must be on the same file system where LO is installed, and the TDF
tarballs puts that in /opt, and on some Linuxes in default configuration /opt
is on a different file system from /home, so we should not really use
/home/lool.
2015-05-27 16:28:36 +03:00
Tor Lillqvist
86b846d137 Accept URI on the command line 2015-05-27 16:27:52 +03:00
Tor Lillqvist
05c6505325 Post-release bump to 1.0.19 2015-05-27 15:13:25 +03:00
Tor Lillqvist
4109d1cb5d Avoid "cannot create directory: File exists" issues 2015-05-27 15:12:21 +03:00
Tor Lillqvist
7e5f0afcee Post-release bump to 1.0.17 2015-05-27 14:38:41 +03:00
Tor Lillqvist
b3ea72955d Update from LO master 2015-05-27 14:06:50 +03:00
Miklos Vajna
6453f130c0 LOOLSession: handle LOK_CALLBACK_SET_PART 2015-05-27 11:36:21 +02:00
Jan Holesovsky
029a41ba81 Fix non-debug build. 2015-05-26 10:11:06 +02:00
Henry Castro
d33d1afcf3 Added missing rectangle to invalidate cursor. 2015-05-25 00:40:08 -04:00
Tor Lillqvist
c97b4d4994 Mention the 'help' command, too 2015-05-23 12:02:05 +01:00
Tor Lillqvist
54d1ee6d42 Take the part number too in the 'tile' command and switch to it 2015-05-23 12:01:24 +01:00
Tor Lillqvist
0053f18e2d Handle LOK_CALLBACK_PAGE_COUNT_CHANGED 2015-05-23 11:26:11 +01:00
Tor Lillqvist
25ecb6ce16 Update from latest master 2015-05-23 11:25:42 +01:00
Tor Lillqvist
f7d001ed45 Bin the uid debug output 2015-05-22 17:43:45 +01:00
Tor Lillqvist
180f8fcba0 Pass the --uid option to the child too 2015-05-22 17:42:36 +01:00
Tor Lillqvist
94e29dab1e This approach will not work...
The amount of system frameworks (both public and private) needed by
the LO libraries is staggering. It will not work to try to list them
here. If you are crazy enough to want to run this on OS X, use some
other tool than this script to set up the system template for the
chroot jail. Like mkjail from https://github.com/glvnst/shlibs.
2015-05-22 16:55:05 +01:00
Tor Lillqvist
73505aa550 On OS X libsofficeap.dylib is in Frameworks 2015-05-22 14:40:09 +01:00
Tor Lillqvist
9af39d189a Add some fairly hackish things to make this run better on OS X 2015-05-22 14:34:21 +01:00
Tor Lillqvist
99b7fcdfa8 Include dynamic loader and more system libraries on OS X 2015-05-22 14:34:13 +01:00
Tor Lillqvist
0440a908fa For some reason linking the PkgInfo file fails in OS X
No idea. Does not even work from the command line...  But after
"fixing" this, we run into other weird problems anyway. (Maybe one
needs to use lower-level (Mach) APIs for esoteric stuff like chroot?)
So, getting loolwsd to work on OS X seems unexpectedly hard even
before considering what changes might be needed to LibreOfficeKit. Oh
well.
2015-05-22 12:43:00 +01:00
Tor Lillqvist
6b12d9e1a8 Make the script work on OS X
Note: No idea yet whether this stuff will work on OS X.
2015-05-22 11:37:40 +01:00
Tor Lillqvist
8612aab7c4 Make this build on OS X
Note that I said build, not work.
2015-05-22 10:57:17 +01:00
Tor Lillqvist
f44b2b4471 Add configure options for where to look for libpng, too 2015-05-22 10:53:43 +01:00
Tor Lillqvist
c3e48af0fa Bump version to 1.0.15
Accidentally committed the bump to 1.0.14 on the master branch, too.
2015-05-20 20:14:47 +03:00
Tor Lillqvist
2721706168 Generate the "upstream" loolwsd.spec here from an .in file
So that the version doesn't need to be manually maintained. Downstream
packagers will then have to add release information etc.
2015-05-20 20:12:54 +03:00
Mihai Varga
c62ee92519 Search not found callback handler 2015-05-20 16:54:40 +03:00
Tor Lillqvist
3e9531f90a Create a 'lool' user and run the systemplate setup script upon installation
Not sure if this is the right thing to do, but should work for our purposes
for now. If and when somebody else wants to fine-tune this stuff, feel free.
2015-05-19 17:04:24 +03:00
Tor Lillqvist
70c934dd6d Forgot to rename the script in one place 2015-05-19 14:17:46 +03:00
Tor Lillqvist
316a9e8151 Add a spec file, works for openSUSE 13.2 at least
Wonder if it would be good style to expand the spec file from a .in one by the
configury, so that one could use autoconf expansions for the version number in
it?
2015-05-19 14:04:51 +03:00
Tor Lillqvist
d40ba38f9f Build 1.0.12 tarball and bump version to 1.0.13 2015-05-19 13:59:55 +03:00
Tor Lillqvist
92d7256b5d Use dist_bin_SCRIPTS, not bin_SCRIPTS
Otherwise we won't get loolwsd-systemplate-setup in the tarball.
2015-05-19 13:58:53 +03:00
Tor Lillqvist
1459b6956f Build 1.0.10 tarball and bump version to 1.0.11 2015-05-19 13:55:03 +03:00
Tor Lillqvist
bc49cccee2 Log the capabilities after dropping one 2015-05-19 13:54:12 +03:00
Tor Lillqvist
707f7f7f64 Build 1.0.8 tarball and bump version to 1.0.9 2015-05-19 13:51:25 +03:00
Tor Lillqvist
65ab397d34 We need CAP_FOWNER, too, on newer Linuxes to be able to hardlink the LO files
At least when not running as the owner of those files. Refactor the capability
dropping so that we can separately drop the CAP_FOWNER and CAP_SYS_CHROOT
capabilities. The child process never needs CAP_FOWNER and the parent process
never needs CAP_SYS_CHROOT.
2015-05-19 13:48:20 +03:00
Tor Lillqvist
0857397352 Rename the systemplate setup script to better name and install it
It was a bit misleading to have "chroot" in the name of the script as it isn't
a chroot jail as such that the script is setting up, but a *template* that
will be copied (hardlinked) into each chroot jail.

The script should be installed, so that a loolwsd package can include it. We
don't want to loolwsd use to depend on having the sources available,
obviously.
2015-05-19 13:20:16 +03:00
Tor Lillqvist
5cb5c1a935 Build 1.0.6 tarball and bump version to 1.0.7 2015-05-19 10:02:20 +03:00
Tor Lillqvist
e50f243897 Let's not over-complicate this 2015-05-19 07:52:42 +03:00
Tor Lillqvist
058416b9d7 Handle arbitrarily large tile: messages from child to parent
The parent currently uses a fixed-size 100000 byte buffer to receive
messages. Even with a tile size of 256x256 pixels, that is not enough for some
tiles that compress badly as PNG. Add a nextmessage: message that gives the
size of the immediately following message. Send a such before each tile:
message, and handle it appropriately. The nextmessage: message is used only
from child to parent process, it is never sent to the Websocket client.

Once Poco 1.6.1 is released, this will not be necessary.
2015-05-18 11:24:32 +03:00
Tor Lillqvist
2d9c526ed0 Build 1.0.4 tarball and bump version to 1.0.5 2015-05-15 14:37:48 +03:00
Tor Lillqvist
230e0ff451 Check whether we need to explicitly link with -lpcre
For instance on Debian, poco is built to use the system pcre.
2015-05-15 14:37:48 +03:00
Tor Lillqvist
7cb553841c Build 1.0.2 tarball and bump version to 1.0.3 2015-05-15 13:39:10 +03:00
Tor Lillqvist
f4eccc714a Include also headers in the tarball 2015-05-15 13:39:10 +03:00
Tor Lillqvist
5c6cb156f9 Delete those bundled LOKit headers we don't actually use 2015-05-15 13:39:10 +03:00
Tor Lillqvist
d1b7bfeaae Bump loolwsd version to 1.0.1
I have made a pseudo-release tarball (for internal testing purposed) with the
version 1.0.0.

Use the following policy for versioning: When doing a release tarball, bump
the version in configure.ac so that the third (micro) version number is
even. Don't commit that to git, but do run make dist. After you have the
tarball, bump the micro version number again to an odd number. Commit. This
way, anything from git will always have an odd micro version number.
2015-05-15 10:18:48 +03:00
Tor Lillqvist
4bff5fef73 Include LibreOfficeKit headers from today for optional use
Useful when building loolwsd on a system that doesn't have new enough
LibreOfficeKit headers available. (It makes sense to use them only if the
resulting loolwsd will then be run on a system with a new enough LibreOffice
installation anyway.)

Pass the --with-lokit-path=bundled/include configure option to use them.
2015-05-15 10:12:50 +03:00
Mihai Varga
7122e97382 Fixed an unused result compiler error 2015-05-15 09:23:21 +03:00
Tor Lillqvist
e2dc523b11 Bin one pointless line of debugging output 2015-05-13 17:52:20 +03:00
Tor Lillqvist
6d5fb333ee It's url=, not uri= 2015-05-13 17:52:20 +03:00
Tor Lillqvist
1e17966bb9 Drop super-user privileges if using sudo by necessity when debugging
It doesn't work to debug a program that has file capabilities set, it seems,
so to debug the loolwsd master process, one in practice needs to run sudo gdb
on it. But it is not necessarily a good idea to run all of the code as
root. When configured for debugging (--enable-debug), reset real and effective
uid to a non-root one, either one given with an --uid option (typically that
of the developer), or "nobody".
2015-05-13 17:52:20 +03:00
Tor Lillqvist
efd750d2ee Add ENABLE_DEBUG to the config.h 2015-05-13 17:52:20 +03:00
Tor Lillqvist
60801cd014 Be less verbose: don't log messages received 2015-05-13 17:52:20 +03:00
Tor Lillqvist
72304b1593 Send the part number, too (always 0 for now) 2015-05-13 17:52:20 +03:00
Tor Lillqvist
5ea8efe602 Loop through tiles in x direction, too 2015-05-13 17:52:20 +03:00
Mihai Varga
1f073e6219 Fixed unused result compile error 2015-05-13 13:00:33 +03:00
Tor Lillqvist
b6c36e23f3 Improve error handling for documents that can't be opened
Catch IOException when trying to copy the document and send error message.
Otherwise, the exception will just propagate up to handleRequest() and the
connection will be silently closed. Closing the connection is fine as such, I
think, but we need to send an error message first.
2015-05-12 12:44:19 +03:00
Tor Lillqvist
c91d77c684 Check that the POCO version used is the one we want
Currently we require the current version, 1.6.0, and as soon as 1.6.1 is out,
I will start requiring that, because I want to use a feature I submitted to
it.

Surround most of configure.ac with AC_LANG_PUSH([C++]) while at it, as this is
all C++ code anyway.
2015-05-11 11:24:27 +03:00
Tor Lillqvist
6393cbfd7d Improve help for --port a bit
It must bit be the port number used for listening for the child processes
contacting the master process.
2015-05-08 21:30:32 +03:00
Tor Lillqvist
3e9c4d4bf3 Use a separate HTTPServer listening for child processes connnecting
Otherwise, if we use the same port number and same HTTPServer, if enough
clients try to contact us and, we won't be able to accept child processes
having been spawned.

Also add some temporary debugging output here and there to debug lifecycle
management issues.
2015-05-08 21:30:32 +03:00
Tor Lillqvist
5b1233bdb4 Be sure avoid global object dtors when exiting a child process
The LO ones have a tendency to crash anyway on Solar Mutex assertions (in a
build where assertions are active, obviously).
2015-05-08 21:30:32 +03:00
Tor Lillqvist
3a23186217 If we run out of pre-spawned children, spawn one more
Just a stopgap measure so far. Clearly will need some logic to get rid of too
many children if they are just hanging around with no clients incoming. Also,
we need some sanity check not to spawn an unlimited number of children.
2015-05-08 21:30:17 +03:00
Tor Lillqvist
aa40335328 Include also the childId in this (temporary) log output 2015-05-08 21:29:45 +03:00
Tor Lillqvist
e22e1da038 Must use thread-local storage for the variables used by the nftw callback
Otherwise two or more linkOrCopy() functions running simultaneously will lead
to a mess.

Actually nftw() is not guaranteed to be thread-safe, I think, so we should
really use something that is, like Poco's SimpleRecursiveDirectoryIterator.
2015-05-07 20:24:14 +03:00
Tor Lillqvist
c69fc09a1b Use just one RNG for the MasterProcessSession objects
It probably is not a good idea to keep depleting the entropy source needlessly
by having a separate RNG in the preSpawn(). Use just one shared RNG and
protect access to it with a mutex.
2015-05-07 20:24:06 +03:00
Tor Lillqvist
de52608a35 Drop setuid-root on Linux too, if we for some reason have it 2015-05-07 18:31:59 +03:00
Tor Lillqvist
caea0f9986 Try to make the server more stable when heavily loaded by connections
Use an explicit backlog parameter to the ServerSocket, and an explicit max number
of threads to use for the HTTPServer's thread pool.
2015-05-07 18:26:03 +03:00
Tor Lillqvist
0ca7f3129b Add code to wait for a child session to become available
Not sure it is completely correct. Lots of testing needed.
2015-05-07 16:29:36 +03:00
Tor Lillqvist
5aec1fc2f8 Register for callbacks from the LibreOfficeKit object, too
They are used for statgus indicator callbacks while loading a document. (This
is a fresh feature in LO master.)
2015-05-06 17:58:00 +03:00
Tor Lillqvist
cb65bbbc36 Include <string> for completeness
Sure, it seems to get included indirectly already, but we can't be sure that
holds for all compilers.
2015-05-06 17:58:00 +03:00
Tor Lillqvist
9bce431eea We have setcap only on Linux
Use setuid root otherwise. (But note that the portablity to other
Unixes is a work in progress, and for instance it is known that this
doesn't work on OS X yet.)
2015-05-04 21:00:02 +03:00
Tor Lillqvist
295e8305f9 Use the Linux capability API only on Linux 2015-05-04 21:00:02 +03:00
Tor Lillqvist
580c99d76c Add SIGPIPE which was missing by mistake, and make it compile on OS X 2015-05-04 20:54:46 +03:00
Tor Lillqvist
8a3dfa4936 The ld -rpath switch means a different thing on OS X 2015-05-04 20:52:05 +03:00
Tor Lillqvist
4ecc431159 Look for setcap and libcap only on Linux 2015-05-04 20:17:41 +03:00
Tor Lillqvist
af1821bb3b Temporarily bypass modification time things for actual URLs
The code works only for pathnames currently. Need to fix soon.
2015-04-30 21:12:33 +03:00
Tor Lillqvist
dce8e0870e Just _Exit() in childMain
Otherwise various LO global objects will try to run dtors and whatnot, often
crashing.
2015-04-30 21:06:52 +03:00
Tor Lillqvist
600b5bc4d8 Log also when copying of the document is done 2015-04-30 21:05:16 +03:00
Tor Lillqvist
af400fcef4 This is cleaner 2015-04-30 18:44:27 +03:00
Tor Lillqvist
f7375bb5ba Try to be a little more robust 2015-04-30 18:03:00 +03:00
Tor Lillqvist
59055b975e Use Poco::StreamCopier, just because it looks nicer
A test program did not show any performance difference between using the
std::copy() thing, Poco::StreamCopier, or std output << input.rdbuf() trick.
2015-04-30 18:01:21 +03:00
Tor Lillqvist
8b43cd25b0 Handle file: and http: URLs 2015-04-30 15:58:13 +03:00
Tor Lillqvist
847ce0442e Add the part parameter to the example tile message here, too 2015-04-30 15:19:29 +03:00
Tor Lillqvist
e48ba86eb9 Mention using actual URLs 2015-04-30 13:50:10 +03:00
Tor Lillqvist
3ea260f972 Portability improvements
Allow the directory parameters to be relative paths; turn them into absolute
ones for later use in the script as we change directories back and forth.

Use cpio instead of cp --parent for each file separately. (The latter has the
problem that parent directories are created using the protection the
corresponding source directory has, and tht might not permit you to copy other
files later into the same directory.)

Also copy usr/share/liblangtag, for the (common) case when LibreOffice is
built to use a system liblangtag.

Don't bother with the special handling of /usr/share/fonts/ghostscript unless
it exists and is a symlink.

With these changes, it worked for CentOS 7, too.
2015-04-29 15:06:18 +03:00
Tor Lillqvist
19276ed5d8 Actually drop the chroot capability also in the child process
I forgot to do it in childMain() in 28c9561722.
2015-04-28 11:24:00 +03:00
Tor Lillqvist
25575961ed We need to check for cache dir access only in the master process 2015-04-28 11:17:26 +03:00
Tor Lillqvist
4d6dfebf8e Expand on debugging details 2015-04-28 11:14:46 +03:00
Tor Lillqvist
2110aef06a No need for this member to be public 2015-04-28 11:02:29 +03:00
Tor Lillqvist
6df6a5d58b Spawn just one child in the --test case 2015-04-28 11:01:18 +03:00
Tor Lillqvist
88cb21867b Spawn children only after starting to listen on the server port
Otherwise some children, especially when there are more than just a few of
them to spawn, might try to contact the server before it is listening.
2015-04-28 10:57:05 +03:00
Tor Lillqvist
9251fefe94 Clarify remaining need for part parameter in messages 2015-04-27 21:58:54 +03:00
Tor Lillqvist
28c9561722 Get rid of the CHROOT capability after using it, or when not needing it 2015-04-27 21:55:36 +03:00
Tor Lillqvist
1b06290d2b Add a part parameter to the tile messages
The JS code always passes in 0 for now. The server parses the parameter and
calls LibreOfficeKitDocument::setPart() before calling paintTile().

Probably also the status, key, mouse and selection messages will need a part
number. The intent is after all that the protocol is as stateless as
possible. (So maybe we should also pass the document URL in each message?)
2015-04-27 21:30:26 +03:00
Tor Lillqvist
389815ac63 Introduce LOLProtocol::getTokenKeyword() and use it
The new function takes a map from keywords to integer values, and accepts
parameters in the form of either name=keyword, or for backward compatibility,
name='keyword'. Use it to parse the type parameter of the key, mouse,
selecttext and selectgraphic messages. This restricts the accepted keywords to
those actually valid for each message.
2015-04-27 21:12:20 +03:00
Tor Lillqvist
5267753b82 Add mention that MasterProcessSession::dispatchChild() should wait 2015-04-27 18:03:52 +03:00
Tor Lillqvist
b2f34b0c3d Maybe /usr/share/fonts/ghostscript is also good to have 2015-04-27 16:01:11 +03:00
Tor Lillqvist
0019dc4943 Preserve timestamp of directories created in the jail
Needed for /usr/share/fonts so that fontconfig trusts its cache, but no harm
doing it for all directories. (Except a slight slowdown, need to see it if
has any significant impact if we would do the utime() only for directories
under /usr/share/fonts.)

Thus we need to pass the FTW_DEPTH flag to nftw() and handle FTP_DP instead of
FTP_D. We also need to make sure the directory is created also in the case of
an empty directory, for which no FTW_F callback of files inside it has been
received.

It is safest to not exit the nftw() in the FTW_SLN case.
2015-04-27 15:57:18 +03:00
Tor Lillqvist
074a54dd6c Make sure the fontconfig cache works for the sys-template
Need to copy /var/cache/fontconfig, too. For it to be valid, the directory
timestamps in /usr/share/fonts must be preserved.
2015-04-27 15:49:25 +03:00
Tor Lillqvist
be2bb356c3 Add seconds.milliseconds to the log prefix 2015-04-27 14:16:37 +03:00
Michael Meeks
6b17e8b022 Update README, and install ld.so.* into the jail. 2015-04-27 10:00:31 +01:00
Michael Meeks
1317941b5a Use shell variables to make it more cut/paste-able. 2015-04-27 09:44:59 +01:00
Tor Lillqvist
68d15726c4 Rephrase statement more logically 2015-04-27 11:27:29 +03:00
Tor Lillqvist
bced6a0771 Clarification 2015-04-27 11:26:00 +03:00
Miklos Vajna
0615ce950f LOOLSession: log error if nftw() fails
Should help finding out the problem if --lotemplate is given a
non-existing directory by mistake.
2015-04-25 01:40:16 +02:00
Tor Lillqvist
7d25ffada6 Remove part that is not relevant any longer
I don't see the busy looping any more, and child porcesses are indeed now
pre-spawned as needed (not just "re-started").
2015-04-24 18:56:24 +03:00
Tor Lillqvist
d6005eb524 Mention we need a part number parameter in many places 2015-04-24 18:54:50 +03:00
Miklos Vajna
4a7265ae76 Makefile: fix autoreconf warning
Makefile.am:18: warning: deprecated feature: target 'SETCAP' overrides 'SETCAP$(EXEEXT)'
Makefile.am:18: change your target to read 'SETCAP$(EXEEXT)'
/usr/share/automake-1.13/am/program.am: target 'SETCAP$(EXEEXT)' was defined here
Makefile.am:1:   while processing program 'SETCAP'
2015-04-24 17:27:21 +02:00
Tor Lillqvist
e9f3e815fe Don't try to run the 'display' program if there is no $DISPLAY 2015-04-24 18:18:56 +03:00
Tor Lillqvist
3ff60eaea1 Mention that the tile cache directory needs to be created 2015-04-24 17:46:01 +03:00
Tor Lillqvist
3ee29053aa Add a section about coding style 2015-04-24 14:34:43 +03:00
Tor Lillqvist
4eaffc74f0 Log the exit status of a child process, or the signal that killed it 2015-04-24 13:14:57 +03:00
Tor Lillqvist
00da867e97 Cosmetics 2015-04-24 12:49:47 +03:00
Tor Lillqvist
4782d05852 Add Util::signalName() 2015-04-24 12:49:19 +03:00
Tor Lillqvist
91d0e9329c Fix the waitpid() use
We don't want to use WNOHANG, not sure where I got that idea from. That leads
to busy looping. The loop is in a thread of its own, so it is fine to just
wait ("hang") for some child to die.
2015-04-24 11:26:41 +03:00
Tor Lillqvist
4f9739854a s/localhost/127.0.0.1/
Makes the chrooted child process more reliable on diverse distros/versions.
Let's use 127.0.0.1 in all cases for consistency.
2015-04-23 18:52:19 +03:00
Jan Holesovsky
5f2de45584 Update README with debugging hints. 2015-04-23 17:29:56 +02:00
Jan Holesovsky
2d23eaff6d Add the debug suffix to Poco libs only when self-built. 2015-04-23 17:29:56 +02:00
Jan Holesovsky
8be550056b SLEEPFORDEBUGGER is still useful for debugging, re-introduce that.
This reverts commit af3545b897.
2015-04-23 17:29:56 +02:00
Tor Lillqvist
ed07f1a4e1 Avoid accessing string out of bounds 2015-04-23 17:16:44 +03:00
Tor Lillqvist
4d717182ad Look for setcap during configury 2015-04-23 16:00:48 +03:00
Jan Holesovsky
bf929d5618 Add libcap-progs to the README as dependency. 2015-04-23 14:54:14 +02:00
Tor Lillqvist
ae500514f5 Forgot to actually have the --test switch in the example of its use 2015-04-23 15:51:10 +03:00
Tor Lillqvist
a181692255 Simplify
Just use find ... -type f instead of a for loop.

One note: I wonder how text rendering by the LO code in the child process
works even if we haven't copied any actual fonts into the sys template (and
thus chroot jail)? Is FreeType (or whatever it) already present in the
process, and font files open, even before the chroot? Weird.
2015-04-23 15:24:20 +03:00
Tor Lillqvist
d970d327b9 Don't exit if cp fails
It might be that for instance there is no /lib64/ld-*, as on a 32-bit system.
2015-04-23 15:18:22 +03:00
Tor Lillqvist
b8f2ce741e Fix thinko 2015-04-23 14:44:41 +03:00
Tor Lillqvist
b49d4d8885 Use shared_ptr and weak_ptr in attempt to make the pointer dance more robust
It was obviously very wrong to use both a unique_ptr to the
MasterProcessSession in WebSocketRequestHandler::handleRequest(), and then a
bare pointers to the peer object in the MasterProcessSession object. We got
crashes here and there related to the destructors.

Let's see if we can manage without mutexes.
2015-04-22 21:50:17 +03:00
Tor Lillqvist
eade187ebb Bin pointless logging
We logged effectively the same information a few lines earlier.
2015-04-22 21:50:04 +03:00
Tor Lillqvist
59bd08299c _childId is used only in MasterProcessSession 2015-04-22 21:49:53 +03:00
Tor Lillqvist
08f53df08a _childIdToChildSession[childId] is not used 2015-04-22 21:49:37 +03:00
Tor Lillqvist
e83559795d Mention that sudo is used 2015-04-22 21:49:23 +03:00
Tor Lillqvist
8534aebf8e Only the MasterProcessSession class uses a tile cache 2015-04-22 21:49:12 +03:00
Tor Lillqvist
d94b494c0c Check if the peer MasterProcessSession has a tile cache yet 2015-04-22 21:48:48 +03:00
Tor Lillqvist
54d106f47b Factor out WebSocket::shutdown() ignoring IOException 2015-04-22 21:48:42 +03:00
Tor Lillqvist
6b7dcdb544 Typo 2015-04-22 21:48:35 +03:00
Tor Lillqvist
520236fb7e Updates 2015-04-22 21:48:27 +03:00
Tor Lillqvist
a0292468da Catch (and ignore) Poco::IOException in a couple of places
There probably are more places where I should catch those and act
appropriately. At least in these places, where the websocket connection is
already closed, or being closed, anyway, the right thing to do is just to
ignore exceptions, which are generated from attempts to write to an already
closed Poco WebSocket, for instance.
2015-04-22 21:48:14 +03:00
Tor Lillqvist
fcea475bb5 Use separate classes derived from LOOLSession for parent and child processes
Work in progress. Does not work properly yet.
2015-04-22 21:48:04 +03:00
Tor Lillqvist
fda13c6c74 Tweak temporary timing parameters a bit while hacking 2015-04-22 21:47:53 +03:00
Tor Lillqvist
84eff99fde Add --help option 2015-04-22 21:47:38 +03:00
Tor Lillqvist
faec3cd961 We indeed don't need the signalfd stuff, I hope
As such it worked, but if we can manage with simpler code, no need to use it.
2015-04-22 21:47:20 +03:00
Tor Lillqvist
a63f797fff Call shutdown on the peer's websocket when the session to the client dies
Also, seems that calling LOKitDocument::destroy() (in the child process's
LOOLSession dtor) causes crashes, avoid that. The can be little need for any
cleanup as the process is about to exit anyway, and the user profile is a
temporary one that will be binned.
2015-04-22 21:47:13 +03:00
Tor Lillqvist
02f12402bf This was what I meant
But actually I wonder why I thought I would need signalfd at all; wouldn't it
be enough to just loop in the undertaker thread, calling waitpid(), as long as
there are child processes? I'll try after this commit.

(Besides, I now notice that when I client disconnects, we don't close the
websocket to the child process, so it never goes away. Will fix that.)
2015-04-22 21:46:56 +03:00
Tor Lillqvist
59e4d4d25d This is done 2015-04-22 21:46:50 +03:00
Tor Lillqvist
39b6258aa9 Clean up the jail after the prisoner has died 2015-04-22 21:46:33 +03:00
Tor Lillqvist
291710cc1c Typo 2015-04-22 21:46:23 +03:00
Tor Lillqvist
af3545b897 No need for the SLEEPFORDEBUGGER thing any more
As the child processes are pre-spawned and just hang around waiting, there is
ample time to attach one in a debugger in a controlled debugging scenario
anyway.
2015-04-22 21:46:04 +03:00
Tor Lillqvist
27a680457e Pre-spawn a new child when we take one into use 2015-04-22 21:45:57 +03:00
Tor Lillqvist
1b32383875 Improve help messages 2015-04-22 21:45:47 +03:00
Tor Lillqvist
b760359bda Terminology change: s/fork/spawn
We aren't doing any fork-but-not-exec trick anyway, just a straightforward
start of a child process.
2015-04-22 21:45:31 +03:00
Tor Lillqvist
a2e2102ad1 Call dispatchChild() only if needed 2015-04-22 21:45:22 +03:00
Tor Lillqvist
c33d3a3aae Add a couple of items 2015-04-22 21:45:06 +03:00
Tor Lillqvist
acbad93ac7 Update README 2015-04-22 21:44:53 +03:00
Tor Lillqvist
d513536cfe Must seed the RNG explicitly
Otherwise it uses a timestamp with one-second granularity as seed, and thus
most of the child processes pre-spawned at start will use the same seed, which
causes breakage.
2015-04-22 21:44:42 +03:00
Tor Lillqvist
3abb6d0307 Now the chroot etc re-work is getting closer to working
Works now for the trivial 'connect' test program. Still need to add
pre-spawning of a new child process as soon as an existing one from the pool
has been taking into use. And need to test with the actual JS client.
2015-04-22 21:44:17 +03:00
Tor Lillqvist
8800dd46e1 Fix typo and bin leftover FOO debug output 2015-04-22 21:43:55 +03:00
Tor Lillqvist
652580a761 Another intermediate commit, code still in a non-working state 2015-04-22 21:43:44 +03:00
Tor Lillqvist
a4480e2a8e Add "sleep <n>" pseudo-request 2015-04-22 21:43:32 +03:00
Tor Lillqvist
0a60ea9dcc Bump Emacs fill-column to 100
The default 70 is so last century.
2015-04-22 21:43:11 +03:00
Tor Lillqvist
7f50f06bf4 Add some comments 2015-04-22 21:42:47 +03:00
Tor Lillqvist
4c7b5a39e3 master LibreOffice no longer does the "restart required" thing when used from LOKit 2015-04-22 21:42:28 +03:00
Tor Lillqvist
f9d93ea57c Work in progress: "pre-forking", chroot, etc. Non-working state
Lots of changes to the server code, LOOLWSD and LOOLSession mainly. This is an
intermediate commit.
2015-04-22 21:42:17 +03:00
Tor Lillqvist
defbb6a809 Remove write of superfluous empty line 2015-04-22 21:42:09 +03:00
Tor Lillqvist
6950f7d841 Adapt to changed LibreOfficeKitDocument::postUnoCommand() API 2015-04-22 21:41:49 +03:00
Jan Holesovsky
44553f82c0 loolwsd: Don't even start when the cache dir is not available. 2015-04-21 15:51:28 +02:00
Jan Holesovsky
4715df9587 Reformatted loolwsd README. 2015-04-21 12:48:17 +02:00
Tor Lillqvist
c72f197e71 Handle LOK_CALLBACK_STATE_CHANGED 2015-04-14 14:51:36 +03:00
Tor Lillqvist
32ec786180 Update 2015-04-14 12:54:41 +03:00
Mihai Varga
7d66119532 Command type handler for selectText, selectGraphic, key, mouse 2015-04-13 20:42:44 +03:00
Tor Lillqvist
803ace146b Some compilers seem very picky about ignoring return values 2015-04-10 12:51:42 +03:00
Tor Lillqvist
e6ddb042cd WaE: ignoring return value 2015-04-10 12:40:13 +03:00
Tor Lillqvist
bf709edf08 Adapt for older libpng 2015-04-10 12:39:12 +03:00
Tor Lillqvist
aedea4229f Call LibreOfficeKitDocument::initializeForRendering() 2015-04-10 12:21:28 +03:00
Tor Lillqvist
06d98ec0b7 This is C++ 2015-04-10 01:25:48 +03:00
Michael Meeks
abec49b4bc memcpy in string.h 2015-04-09 14:38:20 +01:00
Tor Lillqvist
ceae121b16 Can remove this, too 2015-03-28 13:58:15 +02:00
Tor Lillqvist
6d9f298ee9 Prefer C++ std headers 2015-03-28 13:57:10 +02:00
Tor Lillqvist
41f41f7af5 Have lokitclient display tiles using ImageMagick's 'display' if available
Refactor the PNG encoding of a pixmap out to Util.
2015-03-28 13:57:03 +02:00
Tor Lillqvist
c5a8104c4f Add a new minimal non-GUI LOKit test program
For easier debugging of the LO code invoked through LibreOfficeKit, with is no
GUI stuff complicating debugging.
2015-03-28 13:56:03 +02:00
Tor Lillqvist
56f3678b36 Add a separate include file for some helper functions 2015-03-28 13:22:15 +02:00
Tor Lillqvist
7cb0449b8e More hacking 2015-03-27 18:25:06 +02:00
Tor Lillqvist
6e36de4534 For debugging, sleep a bit before initialising LOKit if requested
Set the SLEEPFORDEBUGGER environment variable to the number of seconds a child
process should sleep before calling lok_init(), so that you have time to
attach the process in a debugger.
2015-03-27 18:23:27 +02:00
Tor Lillqvist
cec37456ef Set no receive timeout 2015-03-27 16:53:51 +02:00
Tor Lillqvist
58f00ca165 Remove the dead "migratory socket" stuff 2015-03-27 16:26:33 +02:00
Tor Lillqvist
bb162a6ba7 Add trivial test program for sending commands to the LOOL server 2015-03-27 16:23:20 +02:00
Tor Lillqvist
022592e65c Do remove also the first level of subdirectories 2015-03-27 14:52:30 +02:00
Tor Lillqvist
70f175c9a7 Make Util a namespace instead of a class with just static member functions
This is not Java or C#.
2015-03-26 17:07:52 +02:00
Tor Lillqvist
422dfd1767 Start on load testing
Add a new program, loadtest, that runs a requested number of client sessions
in parallel to a loolwsd server. A client session loads one of a list of test
documents, and does some operations on it.

Move the getTokenInteger() and getTokenString() functions out from LOOLSession
into a new namespace LOOLProtocol, as they are neeeded also in the loadtest
program.

Add, also in LOOLProtocol, functions to parse some of the messages from the
server. (In general that is done in client JavaScript code, of course; only
for testing purposes needed in C++ code.)
2015-03-26 17:04:08 +02:00
Tor Lillqvist
425cae6b29 No need for <unistd.h> as far as I see 2015-03-26 17:04:08 +02:00
Tor Lillqvist
eb695513de Use const reference parameter 2015-03-26 17:04:08 +02:00
Tor Lillqvist
3cb43839ea Cosmetics 2015-03-26 17:04:08 +02:00
Tor Lillqvist
df95739819 Make DEFAULT_PORT_NUMBER public 2015-03-26 17:04:08 +02:00
Tor Lillqvist
b7c08d373e WaE: private field '_helpRequested' is not used 2015-03-26 14:37:38 +02:00