CollaboraOnline / online

Collabora Online is a collaborative online office suite based on LibreOffice technology. This is also the source for the Collabora Office apps for iOS and Android.
https://collaboraonline.com
Other
1.88k stars 710 forks source link

PDF export fails on collabora online #5088

Open durdin85 opened 2 years ago

durdin85 commented 2 years ago

Describe the bug Trying to export PDF or Print just fails. Otherwise everything works fine. Seems the PDF export from CODE is still buggy.

To Reproduce Steps to reproduce the behavior:

  1. Try downloading file as PDF or printing.

Expected behavior File downloaded as PDF

Actual behavior Error stating "Document cannot be exported. Please contact the storage server administrator."

Additional context I run self hosted CODE, installed from deb/ubuntu packages (22.05.4-1) on VM (no docker involved, so I believe it's different from #2041), and I haven't tampered with links, so I believe #5039 is also not a case, even though all of these are very similar.

Checking logs, looks like the same function is being called for both doc and pdf export, but pdf fails, but doc succeedes:

Jul 31 13:56:26 x coolwsd[7892]: kit-07943-07917 2022-07-31 13:56:26.808692 +0200 [ kitbroker_001 ] DBG  ToMaster-003: Calling LOK's saveAs with: url='/tmp/user/docs/<long string>/<file>.pdf', format='pdf', ' filterOptions=(nullptr)'.| kit/ChildSession.cpp:1075

Jul 31 13:56:48 x coolwsd[7892]: kit-07943-07917 2022-07-31 13:56:48.950972 +0200 [ kitbroker_001 ] DBG  ToMaster-003: Calling LOK's saveAs with: url='/tmp/user/docs/<long string>/<file>.docx', format='docx', ' filterOptions=(nullptr)'.| kit/ChildSession.cpp:1075

I've tried running collabora with debug and trace logs, but nothing helpful is found in them except the above mentioned line.

All the times same getLOKitDocument->saveAs is being called https://github.com/CollaboraOnline/online/blob/a149398e971e094960b1355fe203b2ba181fa71b/kit/ChildSession.cpp#L1078 but as I don't know the code much I wasn't able to track it down to some reasonable point.

I've checked if there might be some problem with the jail of the collabora for the /dev/random issue. Symlinks are fine even though I am not sure if they are needed any more as they point to ../tmp/dev/random, which is empty and as the cool have the cap_mknod+ep it's able to create the devices directly in /dev/ jail, and in my case there are real dev created in /opt/cool/child-roots/tmp/somestring/dev ). Also, I've noticed the coolwsd-systemplate-setup https://github.com/CollaboraOnline/online/blob/a149398e971e094960b1355fe203b2ba181fa71b/coolwsd-systemplate-setup#L75 searches for the xpdfimport, but neither in my installation or in docker image this file exists, so no extra libraries are being pulled into jail, but I assume this is fine.

I've tried attaching gdb to running processes, but I am not sure which is actually doing the export as none brought any results.

Alternativend commented 2 years ago

I can confirm that. Im running CODE on Debian 11 VM, no docker and no LXC. PDF export is not working.

coolwsd: 22.05.5.3 Collabora OfficeDev 22.05.5.3

Maybe this xpdfimport is meant (https://sources.debian.org/src/libreoffice/1%3A7.4.0~beta1-3/sysui/desktop/apparmor/program.xpdfimport/)?

timur-g commented 1 year ago

I assume this report is for Export to PDF of any file in native CODE. durdin85 said: CODE 22.05.4-1 on which-OS? VM Alternativend said: CODE 22.05.5.3 on Debian 11.

Not clear why would this be different from https://github.com/CollaboraOnline/online/issues/5039? There is explanation which is not related only to links. Please test convert-to from https://www.collaboraoffice.com/document-conversion/ to see if Export to PDF works that way? In my case it works. Also please test if Export to PDF works for filename with no spaces? Needinfo on that.

Alternativend commented 1 year ago

Also please test if Export to PDF works for filename with no spaces? Needinfo on that.

No it´s not working without spaces. At the moment we are on COOLWSD Version: 22.05.10.1 git hash: [719ae9bf] and Collabora OfficeDev 22.05.10.5 on Debian 11 VM, Proxmox host.

timur-g commented 1 year ago

Please retest with new COOLWSD version: 22.05.12.2.

DmDS commented 1 year ago

22.05.12.3 when exporting, I get "The server encountered a failure error when parsing the exportas command". "download as" I get the same error.

syslog:

Mar 21 09:26:21 cloud coolwsd[1261475]: kit-1261475-1261432 2023-03-21 09:26:21.998547 +0300 [ kitbroker_003 ] ERR  ToMaster-00f: error: cmd=exportas kind=failure| common/Session.hpp:165
Mar 21 09:26:21 cloud coolwsd[1261423]: wsd-1261423-1261711 2023-03-21 09:26:21.999373 +0300 [ docbroker_003 ] ERR  ToClient-00f: exportas error failure: failure| wsd/ClientSession.cpp:1597

it doesn't work without spaces either. tried it "https://www.collaboraoffice.com/document-conversion " - it works.

if set "mount_jail_tree" to false, then the export works like this: изображение but the pdf appears in the file list only after the page is refreshed. "download as" does not work. after clicking "export" nothing happens.

Debian GNU/Linux 11 (bullseye) COOLWSD 22.05.12.3 Collabora Office 22.05.12.3 no docker and no LXC

Alternativend commented 1 year ago

I have the same setup as @DmDS and got the exact same results.

timur-g commented 1 year ago

There were some fixes for export to PDF which should be in 23.05.1 to be released today so it would be good if you can test later.

Traktormaster commented 1 year ago

It is still not working, I've tried 23.05.1-2 and 23.05.2-2 built locally.

Download attempt logs:

kit-3867488-3867394 2023-07-25 16:50:34.374300 +0200 [ kitbroker_002 ] ERR  ToMaster-002: error: cmd=exportas kind=failure| common/Session.hpp:165
wsd-3867380-3867551 2023-07-25 16:50:34.374361 +0200 [ docbroker_002 ] ERR  ToClient-002: exportas error failure: failure| wsd/ClientSession.cpp:1623

Print attempt logs:

kit-3867488-3867394 2023-07-25 16:50:25.458001 +0200 [ kitbroker_002 ] ERR  ToMaster-002: SaveAs Failed for id=print [/tmp/user/docs/hX5PVYQkSQxXbMw1iy8E7s1rbJKKFGyKIAv2TrlC0eeyIxHHrxsPebbRvfb7Qeok/print.pdf]. error= exception: SfxBaseModel::impl_store <file:///tmp/user/docs/hX5PVYQkSQxXbMw1iy8E7s1rbJKKFGyKIAv2TrlC0eeyIxHHrxsPebbRvfb7Qeok/print.pdf> failed: 0xc10(Error Area:Io Class:Write Code:16) at /home/admin/tmp/libreoffice/sfx2/source/doc/sfxbasemodel.cxx:3221 at /home/admin/tmp/libreoffice/sfx2/source/doc/sfxbasemodel.cxx:1792| kit/ChildSession.cpp:1085
kit-3867488-3867394 2023-07-25 16:50:25.458061 +0200 [ kitbroker_002 ] ERR  ToMaster-002: error: cmd=downloadas kind=saveasfailed| common/Session.hpp:165
wsd-3867380-3867551 2023-07-25 16:50:25.458110 +0200 [ docbroker_002 ] ERR  ToClient-002: downloadas error failure: saveasfailed| wsd/ClientSession.cpp:1623
kit-3867488-3867394 2023-07-25 16:50:25.458213 +0200 [ kitbroker_002 ] ERR  ToMaster-002: error: cmd=exportas kind=failure| common/Session.hpp:165
wsd-3867380-3867551 2023-07-25 16:50:25.458249 +0200 [ docbroker_002 ] ERR  ToClient-002: exportas error failure: failure| wsd/ClientSession.cpp:1623

If I turn off the capabilities security feature in coolwsd.xml, then both work.

Traktormaster commented 1 year ago

I've finished setting up another local build of 23.05.1-2 on a different machine and it works on it. I'm not sure how to investigate the effective difference. I'm pretty sure the build options and configuration are exactly the same.

Where it does not work: Arch Linux

# uname -a
Linux server0 6.1.37-1-lts #1 SMP PREEMPT_DYNAMIC Sat, 01 Jul 2023 17:31:09 +0000 x86_64 GNU/Linux
# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.1 20230429 (GCC)

Where it works: Armbian (Debian/Ubuntu)

# uname -a
Linux server1 6.1.30-meson64 #8 SMP PREEMPT Wed May 24 16:32:53 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/11/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.3.0-1ubuntu1~22.04.1' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04.1)

I'd be glad to provide more information if someone points me where to look.

DmDS commented 1 year ago

confirm. export doesn't work on debian 12 but works on ubuntu 22.04.

Uatschitchun commented 1 year ago

Also please test if Export to PDF works for filename with no spaces?

Am running v23.05.2.1 with udocker and Export to PDF fails with:

wsd-08248-24795 2023-08-04 12:31:55.407284 +0000 [ docbroker_02d ] ERR  Cannot access file [/opt/cool/child-roots/8248-4084118e/RKdKMm0XCThztBBr/tmp/user/docs/RKdKMm0XCThztBBr/Welcome%20to%20Nextcloud%20Hub%20test.pdf] to upload to wopi storage.| wsd/Storage.cpp:1234

wsd-08248-24795 2023-08-04 12:31:55.407719 +0000 [ docbroker_02d ] WRN  Failed to upload [https%3A%2F%2Fmyserver.exampe.com%3A443%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F12200_oc5lnyvuk3qj] asynchronously. Activity::None| wsd/DocumentBroker.cpp:1746

As you can see, this is filename with spaces! Welcome to Nextcloud Hub test.docx

When renaming the file to test.docx the export works nicely!

DmDS commented 1 year ago

COOLWSD: 23.05.2.2 LOKit: Collabora Office 23.05.2.3 Debian 12, Ubuntu 22.04

exporting to PDF works now

Alternativend commented 1 year ago

I still get the same error.

COOLWSD version: 23.05.2.2 (git hash: 91c166d2) LOKit version: Collabora Office 23.05.2.3 (git hash: b53934e) Served by: Debian GNU/Linux 12 (bookworm)

Maybe im missing some prerequisites?

Edit: That´s what the log says: wsd-72914-74198 2023-08-15 16:26:42.690585 +0200 [ docbroker_009 ] ERR ToClient-08b: exportas error failure: failure| wsd/ClientSession.cpp:1623

DmDS commented 1 year ago

it only worked for me after a clean install of debian 12.1

Alternativend commented 1 year ago

Could you share your coolswd.xml?

DmDS commented 1 year ago
coolwsd.xml ``` false de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru false false false 1 4 5 false 96 3600 30 300 false 0 8000 0 0 100 5 100 500 5000 10000 60 300 3072 85 120 true 120 900 true warning trace notice fatal false -INFO-WARN /var/log/coolwsd.log never timestamp true 10 days 10 true false false 82589933 false false /var/log/coolwsd.trace.json false false all any 192\.168\.[0-9]{1,3}\.[0-9]{1,3} ::ffff:192\.168\.[0-9]{1,3}\.[0-9]{1,3} 127\.0\.0\.1 ::ffff:127\.0\.0\.1 ::1 172\.1[6789]\.[0-9]{1,3}\.[0-9]{1,3} ::ffff:172\.1[6789]\.[0-9]{1,3}\.[0-9]{1,3} 172\.2[0-9]\.[0-9]{1,3}\.[0-9]{1,3} ::ffff:172\.2[0-9]\.[0-9]{1,3}\.[0-9]{1,3} 172\.3[01]\.[0-9]{1,3}\.[0-9]{1,3} ::ffff:172\.3[01]\.[0-9]{1,3}\.[0-9]{1,3} 10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ::ffff:10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} false true /etc/coolwsd/cert.pem /etc/coolwsd/key.pem /etc/coolwsd/ca-chain.cert.pem 1000 false 31536000 true true 1800 false 1 false false compact true 0 900 true true true false false log true https://help.collaboraoffice.com/help.html? ```
Alternativend commented 1 year ago

Im on 23.05.5.3 and the export still fails.

Edit: If i turn off the capabilities in coolwsd.xml exporting documents in pdf or epub mostly works. Sometimes it crashes my Firefox but most documents are working.

Alternativend commented 12 months ago

Im now on:

COOLWSD version: 23.05.5.3 (git hash: 5093121f) LOKit version: Collabora Office 23.05.6.1 (git hash: 67cdcf1) Served by: Debian GNU/Linux 12 (bookworm)

but still the export only works if i disable the capabilities.

caballinger commented 7 months ago

This is a problem that has plagued me for months, and I finally found a solution that hopefully others find useful. I'm running "linuxserver/nextcloud" and "collabora/code" in docker on a Synology NAS. Whenever I was trying to export/save a document as a pdf, I was getting this error in the log:

kit-3867488-3867394 2023-07-25 16:50:25.458213 +0200 [ kitbroker_002 ] ERR  ToMaster-002: error: cmd=exportas kind=failure| common/Session.hpp:165
wsd-3867380-3867551 2023-07-25 16:50:25.458249 +0200 [ docbroker_002 ] ERR  ToClient-002: exportas error failure: failure| wsd/ClientSession.cpp:1623

What FINALLY fixed the error for me was adding --o:security.capabilities=false to my extra_params. Now, I don't think that ALONE is all it takes to fix the issue, it was just the last missing ingredient for me. Here's what my collabora docker-compose looks like

  collabora:
    image: collabora/code
    environment:
      - aliasgroup1=https://mynextclouddomain.com
      - extra_params=--o:security.capabilities=false --o:security.seccomp=false
      - dictionaries=en_US
      - server_name=mycollaboradomain.com
    security_opt:
      - seccomp:unconfined
    privileged: true
    cap_add:
      - MKNOD

There was a lot of other tweaking I had to do originally to get things working with collabora, nextcloud, and my reverse proxy that I've long since forgotten, but I don't think they were relevant to this issue.

timur-g commented 7 months ago

Can you pleae try with 24.04.1.4? Random device was changed and rootless works now, may be that it will work also here.

muchachagrande commented 6 months ago

@caballinger, I followed your last step of adding --o:security.capabilities=false to docker and it solved the problem for me. I'm using Nextcloud on an Ubuntu 22.04 Server VM with Collabora CODE on Docker. In my case, Collabora 23.05 was working fine. The problem started with 24.04.

Migamix commented 6 months ago

did not add "--o:security.capabilities=false" exited tabbed mode, and used in compact mode... printing and exporting work as expected after above change, is it possible that someplace in code the command for function between the two modes is not carrying over, i dont know where to look in the code base, and frankly dont have the time. i do not get any errors, it just doesnt work.

using built in code version in nextcloud on truenas Dragonfish-24.04.0 App Version: 29.0.0 Chart Version: 2.0.5

COOLWSD version: 24.04.1.3 (git hash: 89a7742 (E)) LOKit version: Collabora Office 24.04.1.3 (git hash: 5d7910f) Served by: Debian GNU/Linux 12 (bookworm) Server ID: ecd556f2

caballinger commented 6 months ago

@timur-g Running 24.04.2.1, removed "-o:security.capabilities=false" from "extra_params" and the exporting pdf DOES seem to still work, but I'm not sure if that would be the case on a clean install, which I'm unable to do at this time. However, I have to leave "--o:security.seccomp=false" in extra_params still, otherwise the document fails to load entirely, but I think that's a different well known issue with synology hosts iirc.

timur-g commented 6 months ago

Note separete #8969 for "Print button in Tabbed view in Calc does not work in 24.04". Other than that, this does seem to work. It would be nice if some of earlier reporters also confirmed.

Alternativend commented 4 months ago

For me it is the same behavior in Coolwsd: 24.04.5-1.

It´s only working with the capabilities option turned off.

ianberinger commented 1 month ago

had the same issue after upgrading our docker image to 24.04.7-2 and initially worked around it with --o:security.capabilities=false.

after seeing https://github.com/CollaboraOnline/online/issues/7201#issuecomment-1705359254, i rebuilt LibreOffice/core with --with-tls=openssl which fixed it!