Package: release.debian.org
Severity: normal
Tags: bookworm
User: release.debian....@packages.debian.org
Usertags: pu
X-Debbugs-Cc: libreoff...@packages.debian.org, k...@packages.debian.org
Control: affects -1 + src:libreoffice

Hi,

I'd like to fix 2 libreoffice bugs in stable. Most important is
the SMB fix (which - for kf5 - also needs a kio stable update, but those
can be done in parallel or kio later as there's no updated
(build)-dependency needed. Merely I added a Recommends: for
documentation purposes.

[ Reason ]
a) #1059158
   If using python3-uno, loadComponentFromURL apparently needs the
   internal libforuilo.so ("formula ui") library to actually open it
   since it tried to open that one.
   Unfortunately this file if left out in the -nogui packages because it
   is*ui.so. (In 32bit packages that is; in 64bit LO due to
   --enable-mergelibs this is already in a bigger library called
   libmergedlo.so)
b) 1069835
   We shouldn't leave people having documents on SMB shares loose their
   files :-)

[ Impact ]
a) opening calc files via python3-uno remaining broken
b) possible file loss for files on SMB shares

[ Tests ]
No test coverage. But a) is pretty straightforward abd b) was confirmed that it
fixes it by the submitter.

[ Risks ]
a) would be better fixed by upstream not requiring that but the bug I
filed upstream (https://bugs.documentfoundation.org/show_bug.cgi?id=158795)
didn't really get any serious attention.
b) more SMB surprises can be possible, though I have not seen any since
this is in unstable since 24.2.2 is there.
(And that exact patch caused a 32bit FTBFS which I backported the fix of which went into 24.2.2~rc1-2 packages and is upstream since 24.2.2 rc2 anyways, too.)

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
a) see above. It it just excluded from the find which removes *.ui.so.
b) patches from upstream applied verbatim (from 24.2.2)

[ Other info ]
kio needs one update, too for complete fix of 1069835 in libreoffice-kf5. I see https://salsa.debian.org/qt-kde-team/kde/kio/-/commi t/082a2b7e9208a9d0a552049aafd898960fc15998
(debian/patches/fix_cifs_file_locks.patch).
According to https://salsa.debian.org/qt-kde-team/kde/kio/-/commit/9db715803c0c87298dbf70644b98a95bb984322c
this was already supposed to be "released to bookworm" but I don't see a
release.debian.org bug nor the package in p-u either.

Debdiff attached.

Regards,

Rene
diff -Nru libreoffice-7.4.7/debian/changelog libreoffice-7.4.7/debian/changelog
--- libreoffice-7.4.7/debian/changelog	2024-04-01 11:05:27.000000000 +0200
+++ libreoffice-7.4.7/debian/changelog	2024-05-24 21:06:45.000000000 +0200
@@ -1,3 +1,18 @@
+libreoffice (4:7.4.7-1+deb12u3) bookworm; urgency=medium
+
+  * debian/patches/Fix-backup-copy-creation-for-files-on-mounted-samba-shares.diff:
+    as name says, from 24.2.2+ (closes: #1069835)
+  * debian/patches/fix-32bit-build.diff: as name says; fix 32bit build with
+    above
+
+  * debian/rules:
+    - don't remove libforuilo.so in -core-nogui. (closes: #1059158)
+      It's subsumed in libmerged on 64bit archs anyway which we definitely
+      need to keep anyway (similar as libuuilo.so).
+    - recommend kio >> 5.103.0-1 in -kf5
+
+ -- Rene Engelhard <r...@debian.org>  Fri, 24 May 2024 21:06:45 +0200
+
 libreoffice (4:7.4.7-1+deb12u2) bookworm-security; urgency=high
 
   * debian/patches/add-notify-for-script-use.diff: add fix for
diff -Nru libreoffice-7.4.7/debian/control libreoffice-7.4.7/debian/control
--- libreoffice-7.4.7/debian/control	2024-04-01 11:05:27.000000000 +0200
+++ libreoffice-7.4.7/debian/control	2024-05-22 18:16:51.000000000 +0200
@@ -5028,7 +5028,7 @@
          ${kf5-qt5-depends},
          ${misc:Depends},
          ${shlibs:Depends}
-Recommends: ${plasma-iconset-dep}
+Recommends: kio (>> 5.103.0-1), ${plasma-iconset-dep}
 Replaces: libreoffice-kde (<< 1:6.1.0~alpha1-1)
 Section: kde
 Enhances: libreoffice
diff -Nru libreoffice-7.4.7/debian/patches/fix-32bit-build.diff libreoffice-7.4.7/debian/patches/fix-32bit-build.diff
--- libreoffice-7.4.7/debian/patches/fix-32bit-build.diff	1970-01-01 01:00:00.000000000 +0100
+++ libreoffice-7.4.7/debian/patches/fix-32bit-build.diff	2024-05-22 09:46:59.000000000 +0200
@@ -0,0 +1,54 @@
+From 0f5dfaebd61b9cabbe9762865563c2296ebb0112 Mon Sep 17 00:00:00 2001
+From: Stephan Bergmann <stephan.bergm...@allotropia.de>
+Date: Fri, 8 Mar 2024 08:38:44 +0100
+Subject: [PATCH] Blind fix for Linux 32-bit builds
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+...which, according to
+<https://lists.freedesktop.org/archives/libreoffice/2024-March/091666.html> "32
+bit build failure (smb, narrowing)", started to fail with
+
+> /<<PKGBUILDDIR>>/sal/osl/unx/file.cxx: In function ‘void osl_file_adjustLockFlags(const rtl::OString&, int*, sal_uInt32*)’:
+> /<<PKGBUILDDIR>>/sal/osl/unx/file.cxx:71:26: error: narrowing conversion of ‘4283649346’ from ‘unsigned int’ to ‘int’ [-Wnarrowing]
+>     71 | #define CIFS_SUPER_MAGIC 0xFF534D42
+>        |                          ^~~~~~~~~~
+> /<<PKGBUILDDIR>>/sal/osl/unx/file.cxx:795:14: note: in expansion of macro ‘CIFS_SUPER_MAGIC’
+>    795 |         case CIFS_SUPER_MAGIC:
+>        |              ^~~~~~~~~~~~~~~~
+
+etc.  My Fedora 39 "Linux man-pages 6.05" statfs(2) man page explains about the
+struct statfs f_type field of __fsword_t type:  "The __fsword_t type used for
+various fields in the statfs structure definition is a glibc internal type, not
+intended for public use.  This leaves the programmer in a bit of a conundrum
+when trying to copy or compare these fields to local variables in a program.
+Using unsigned int for such variables suffices on most systems."  But the
+underlying __FSWORD_T_TYPE looks like it is actually defined as a signed type in
+/usr/include/bits/typesizes.h.
+
+Change-Id: Ida3ae84031c4e48b0d6e69d76b66b4e4facfa1ae
+---
+ sal/osl/unx/file.cxx | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
+index 03d685a997e9..5c4069cae2de 100644
+--- a/sal/osl/unx/file.cxx
++++ b/sal/osl/unx/file.cxx
+@@ -67,9 +67,9 @@
+ #ifdef LINUX
+ #include <sys/vfs.h>
+ // As documented by the kernel
+-#define SMB_SUPER_MAGIC  0x517B
+-#define CIFS_SUPER_MAGIC 0xFF534D42
+-#define SMB2_SUPER_MAGIC 0xFE534D42
++#define SMB_SUPER_MAGIC  static_cast<__fsword_t>(0x517B)
++#define CIFS_SUPER_MAGIC static_cast<__fsword_t>(0xFF534D42)
++#define SMB2_SUPER_MAGIC static_cast<__fsword_t>(0xFE534D42)
+ #endif
+ 
+ namespace {
+-- 
+2.39.2
+
diff -Nru libreoffice-7.4.7/debian/patches/Fix-backup-copy-creation-for-files-on-mounted-samba-shares.diff libreoffice-7.4.7/debian/patches/Fix-backup-copy-creation-for-files-on-mounted-samba-shares.diff
--- libreoffice-7.4.7/debian/patches/Fix-backup-copy-creation-for-files-on-mounted-samba-shares.diff	1970-01-01 01:00:00.000000000 +0100
+++ libreoffice-7.4.7/debian/patches/Fix-backup-copy-creation-for-files-on-mounted-samba-shares.diff	2024-05-22 09:49:16.000000000 +0200
@@ -0,0 +1,128 @@
+From 63efbc8ad8aae12b54e649c1495d1233c1a9b33f Mon Sep 17 00:00:00 2001
+From: Kevin Ottens <kevin.ott...@enioka.com>
+Date: Fri, 2 Feb 2024 15:39:36 +0100
+Subject: tdf#55004 Fix backup copy creation for files on mounted samba shares
+
+There is an unfortunate interaction between file locking and backup
+creation at save time.
+
+openFilePath has logic to lock a file when opening. This goes through
+fcntl to set a write lock on the file. Later on, when the user wants to
+save changes, a backup copy might be created (very likely now since this
+is the defaults in the settings). To create this backup, the file is
+opened again for reading. Unfortunately this open call fails due to the
+lock (even though it is a write lock).
+
+This commit changes the behavior. osl_file_adjustLockFlags now checks if
+the file is on a mounted samba share. If that's the case we force the
+osl_File_OpenFlag_NoLock flag. No issue is then exhibited at backup
+creation, allowing the save to proceed properly.
+
+Change-Id: Ieab252f9f68598834e13339fc5fcea440f0a4c2f
+Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162935
+Tested-by: Jenkins
+Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
+---
+ sal/osl/unx/file.cxx | 54 +++++++++++++++++++++++++++++++++++++++++++++-------
+ 1 file changed, 47 insertions(+), 7 deletions(-)
+
+diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
+index 5acfe2803189..03d685a997e9 100644
+--- a/sal/osl/unx/file.cxx
++++ b/sal/osl/unx/file.cxx
+@@ -64,6 +64,14 @@
+ #include <android/asset_manager.h>
+ #endif
+ 
++#ifdef LINUX
++#include <sys/vfs.h>
++// As documented by the kernel
++#define SMB_SUPER_MAGIC  0x517B
++#define CIFS_SUPER_MAGIC 0xFF534D42
++#define SMB2_SUPER_MAGIC 0xFE534D42
++#endif
++
+ namespace {
+ 
+ enum class State
+@@ -736,9 +744,11 @@ oslFileHandle osl::detail::createFileHandleFromFD(int fd)
+     return static_cast<oslFileHandle>(pImpl);
+ }
+ 
+-static int osl_file_adjustLockFlags(const OString& path, int flags)
++static void osl_file_adjustLockFlags(const OString& path, int *flags, sal_uInt32 *uFlags)
+ {
+ #ifdef MACOSX
++    (void) uFlags;
++
+     /*
+      * The AFP implementation of MacOS X 10.4 treats O_EXLOCK in a way
+      * that makes it impossible for OOo to create a backup copy of the
+@@ -751,20 +761,50 @@ static int osl_file_adjustLockFlags(const OString& path, int flags)
+     {
+         if(strncmp("afpfs", s.f_fstypename, 5) == 0)
+         {
+-            flags &= ~O_EXLOCK;
+-            flags |=  O_SHLOCK;
++            *flags &= ~O_EXLOCK;
++            *flags |=  O_SHLOCK;
+         }
+         else
+         {
+             /* Needed flags to allow opening a webdav file */
+-            flags &= ~(O_EXLOCK | O_SHLOCK | O_NONBLOCK);
++            *flags &= ~(O_EXLOCK | O_SHLOCK | O_NONBLOCK);
++        }
++    }
++#elif defined(LINUX)
++    (void) flags;
++
++    /* get filesystem info */
++    struct statfs aFileStatFs;
++    if (statfs(path.getStr(), &aFileStatFs) < 0)
++    {
++        int e = errno;
++        SAL_INFO("sal.file", "statfs(" << path << "): " << UnixErrnoString(e));
++    }
++    else
++    {
++        SAL_INFO("sal.file", "statfs(" << path << "): OK");
++
++        // We avoid locking if on a Linux CIFS mount otherwise this
++        // fill fail later on when opening the file for reading
++        // during backup creation at save time (even though this is a
++        // write lock and not a read lock).
++        // Fixes the following bug:
++        // https://bugs.documentfoundation.org/show_bug.cgi?id=55004
++        switch (aFileStatFs.f_type) {
++        case SMB_SUPER_MAGIC:
++        case CIFS_SUPER_MAGIC:
++        case SMB2_SUPER_MAGIC:
++            *uFlags |= osl_File_OpenFlag_NoLock;
++            break;
++        default:
++            break;
+         }
+     }
+ #else
+     (void) path;
++    (void) flags;
++    (void) uFlags;
+ #endif
+-
+-    return flags;
+ }
+ 
+ static bool osl_file_queryLocking(sal_uInt32 uFlags)
+@@ -981,7 +1021,7 @@ oslFileError openFilePath(const OString& filePath, oslFileHandle* pHandle,
+     }
+     else
+     {
+-        flags = osl_file_adjustLockFlags (filePath, flags);
++        osl_file_adjustLockFlags (filePath, &flags, &uFlags);
+     }
+ 
+     // O_EXCL can be set only when O_CREAT is set
+-- 
+cgit v1.2.3
+
diff -Nru libreoffice-7.4.7/debian/patches/series libreoffice-7.4.7/debian/patches/series
--- libreoffice-7.4.7/debian/patches/series	2024-04-01 11:03:29.000000000 +0200
+++ libreoffice-7.4.7/debian/patches/series	2024-05-22 09:47:52.000000000 +0200
@@ -59,3 +59,5 @@
 reuse-AllowedLinkProtocolFromDocument-2.diff
 work-around-expired-certificiate-in-test.diff
 add-notify-for-script-use.diff
+Fix-backup-copy-creation-for-files-on-mounted-samba-shares.diff
+fix-32bit-build.diff
diff -Nru libreoffice-7.4.7/debian/rules libreoffice-7.4.7/debian/rules
--- libreoffice-7.4.7/debian/rules	2024-04-01 11:04:55.000000000 +0200
+++ libreoffice-7.4.7/debian/rules	2024-05-22 18:16:11.000000000 +0200
@@ -2018,6 +2018,10 @@
 	perl -pi -e 's/%LO-DESKTOP-INTEGRATION%/libreoffice-gnome/' debian/control
 endif
 
+ifeq "$(ENABLE_KF5)" "y"
+	perl -pi -e 's/plasma-iconset-dep}/plasma-iconset-dep}, kio (>> 5.103.0-1)' debian/control.new
+endif
+
 ifeq (sk,$(findstring sk,$(HELPISOS)))
 	perl -pi -e 's/(Depends:.*)libreoffice-l10n-sk(.*)$$/\1libreoffice-l10n-sk, libreoffice-help-cs\2/' debian/control
 endif
@@ -3196,7 +3200,7 @@
 	done
 	# remove lib*uilo.so in -nogui
 	find debian/libreoffice-*-nogui/$(OODIR)/program -name "lib*uilo.so" -a ! -name "libuuilo.so" \
-		-exec rm {} \;
+		-a ! -name "libforuilo.so" -exec rm {} \;
 	rm -f debian/libreoffice-base-nogui/$(OODIR)/program/libdbulo.so
 	# and (no UI, so not needed) not needed .desktop and .ui files
 	# tabviewbar.ui is needed to make --convert-to work in impress... (#1028290)

Reply via email to