Description: LibreOffice 6.4.7.2 40(Build:2) strace: rename("/tmp/vlAdXO", "/home/XXX/.config/libreoffice/4/user/pack/database/biblio/biblio.pack") = -1 EXDEV (Invalid cross-device link) Steps to Reproduce: with apparmor activated enforced, open an existing ods file, try save it with a different name. The same operation works with apparmor disabled Actual Results: unable to write file Expected Results: file created and written Reproducible: Always User Profile Reset: Yes OpenGL enabled: Yes Additional Info: though systemd.journald managed to lose or corrupt many logs, I suspect that the file-save operation worked after the last upgrade only because I hadn't rebooted since then, so the apparmor profiles weren't reloaded. 2020-07-17 14:52:01 status installed libreoffice-common:all 1:6.4.4-0ubuntu0.20.04.1 2020-08-28 17:08:29 status installed libreoffice-common:all 1:6.4.5-0ubuntu0.20.04.1 2020-09-26 02:27:58 status installed libreoffice-common:all 1:6.4.6-0ubuntu0.20.04.1 -rw------- 1 root root 922564 Apr 6 13:42 /var/cache/apparmor/635fae02.0/usr.lib.libreoffice.program.soffice.bin 2021-04-17 13:59:25 status installed libreoffice-common:all 1:6.4.7-0ubuntu0.20.04.1 I also did a manual reinstall of the usr.lib.libreoffice* apparmor scripts, as they didn't seem to have been changed after "apt install --reinstall libreoffice-common".
Created attachment 172033 [details] strace of problem reproduction # clear profile etc rm -rf ~/.config/libreoffice ~/.cache/pocl sudo aa-disable libreoffice-soffice # manual reinstall: apt download libreoffice-soffice mkdir x ; dpkg-deb -x libreoffice-soffice*.deb ./x sudo cp -a ./x/etc/apparmor.d/* /etc/apparmor.d/ # capture trace ~/projects/maps/IE/airbnb$ strace -o calc.trc -fe file libreoffice ./listings.ods # # do : - save file as '/home/jmullee/projects/maps/IE/airbnb/dfhogsidufhosgu.ods' (fails) - save file as '/tmp/try.ods' (success)
Thank you for reporting the bug. it seems you're using an old version of LibreOffice. Could you please try to reproduce it with the latest version of LibreOffice from https://www.libreoffice.org/download/libreoffice-fresh/ ? I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' if the bug is still present in the latest version.
It'll be one of these four places, none of which handle EXDEV (from fresh git clone) ./sal/osl/unx/file_misc.cxx:754: int nRet = rename(pszPath,pszDestPath); ./sal/osl/unx/file_misc.cxx:845: if (rename(pszDestFileName, tmpDestFile.getStr()) != 0) ./sal/osl/unx/file_misc.cxx:893: if (rename(tmpDestFile.getStr(), pszDestFileName) != 0) ./sal/osl/unx/profile.cxx:1720: bool result = rename( pProfile->m_FileName, pszBakFile ) == 0; ./sal/osl/unx/profile.cxx:1729: result = rename( pszTmpFile, pProfile->m_FileName ) == 0; ./codemaker/source/codemaker/global.cxx:198: if ( !rename(tmpFileName.getStr(), targetFileName.getStr()) ) ./codemaker/source/codemaker/global.cxx:207: if ( rename(tmpFileName.getStr(), targetFileName.getStr()) ) { sal/osl/unx/file_misc.cxx e994b3fc3b2c9 (Noel Grandin 2019-12-19 13:29:13 +0200 752) static oslFileError osl_psz_moveFile(const char* pszPath, const char* pszDestPath) b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 753) { acb0cdeedafc5 (Noel Grandin 2019-04-13 14:57:07 +0200 754) int nRet = rename(pszPath,pszDestPath); b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 755) 2de83d5ad256d (Chris Sherlock 2018-01-29 02:11:50 +1100 756) if (nRet < 0) b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 757) { sal/osl/unx/file_misc.cxx e994b3fc3b2c9 (Noel Grandin 2019-12-19 13:29:13 +0200 835) static oslFileError oslDoCopy(const char* pszSourceFileName, const char* pszDestFileName, mode _t nMode, size_t nSourceSize, bool DestFileExists) b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 836) { b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 837) int nRet=0; b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 838) 6f50961e69406 (Noel Grandin 2018-10-23 12:06:00 +0200 839) OString tmpDestFile; b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 840) if ( DestFileExists ) b76cb86eaa0ae (Oliver Bolte 2009-09-09 09:38:41 +0000 841) { 6edbcc1b231fe (Stephan Bergmann 2014-10-31 12:05:25 +0100 842) //TODO: better pick a temp file name instead of adding .osl-tmp: a2fb2cfd45452 (Michael Stahl 2016-03-07 18:53:55 +0100 843) // use the destination file to avoid EXDEV /* Cross-device link */ 7049328fb2d65 (Noel Grandin 2021-04-20 21:07:42 +0200 844) tmpDestFile = pszDestFileName + OString::Concat(".osl-tmp"); 30c9034c87b6c (Stephan Bergmann 2014-10-31 13:26:22 +0100 845) if (rename(pszDestFileName, tmpDestFile.getStr()) != 0) sal/osl/unx/profile.cxx ebb4ac785f9d5 (Stephan Bergmann 2014-03-06 14:31:10 +0100 1705) static bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile ^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1706) { e994b3fc3b2c9 (Noel Grandin 2019-12-19 13:29:13 +0200 1707) char pszBakFile[PATH_MAX]; e994b3fc3b2c9 (Noel Grandin 2019-12-19 13:29:13 +0200 1708) char pszTmpFile[PATH_MAX]; ad0bdc51df262 (mfe 2001-02-26 15:17:50 +0000 1709) ad0bdc51df262 (mfe 2001-02-26 15:17:50 +0000 1710) pszBakFile[0] = '\0'; ad0bdc51df262 (mfe 2001-02-26 15:17:50 +0000 1711) pszTmpFile[0] = '\0'; ^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1712) 8f210c26c53cf (Stephan Bergmann 2014-03-04 13:47:20 +0100 1713) osl_ProfileGenerateExtension(pProfile->m_FileName, "bak", pszB 8f210c26c53cf (Stephan Bergmann 2014-03-04 13:47:20 +0100 1714) osl_ProfileGenerateExtension(pProfile->m_FileName, "tmp", pszT ^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1715) 52066e4726436 (Norbert Thiebaud 2013-06-20 14:26:49 -0500 1716) /* unlink bak */ 52066e4726436 (Norbert Thiebaud 2013-06-20 14:26:49 -0500 1717) unlink( pszBakFile ); ^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1718) ebb4ac785f9d5 (Stephan Bergmann 2014-03-06 14:31:10 +0100 1719) // Rename ini -> bak, then tmp -> ini: f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1720) bool result = rename( pProfile->m_FileName, pszBakFile ) == 0; f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1721) if (!result) f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1722) { f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1723) int e = errno; 22a2ed832bae5 (Tor Lillqvist 2018-10-18 14:30:42 +0300 1724) SAL_INFO("sal.file", "rename(" << pProfile->m_FileName << f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1725) } f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1726) else f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1727) { f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1728) SAL_INFO("sal.file", "rename(" << pProfile->m_FileName << f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1729) result = rename( pszTmpFile, pProfile->m_FileName ) == 0; f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1730) if (!result) f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1731) { f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1732) int e = errno; 22a2ed832bae5 (Tor Lillqvist 2018-10-18 14:30:42 +0300 1733) SAL_INFO("sal.file", "rename(" << pszTmpFile << "," << f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1734) } f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1735) else f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1736) { f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1737) SAL_INFO("sal.file", "rename(" << pszTmpFile << "," << f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1738) } f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1739) } f8c77cf7ebaf6 (Tor Lillqvist 2018-10-12 03:06:27 +0300 1740) return result; ^9399c662f36c (Jens-Heiner Rech 2000-09-18 14:18:43 +0000 1741) } codemaker/source/codemaker/global.cxx 07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 192) bool makeValidTypeFile(const OString& targetFileName, const OString& tmpFileName, 07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 193) bool bFileCheck) d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 194) { d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 195) if (bFileCheck) { d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 196) if (checkFileContent(targetFileName, tmpFileName)) { b525a3115f545 (Jens-Heiner Rech 2000-09-18 14:29:57 +0000 197) if ( !unlink(targetFileName.getStr()) ) e57168966c81a (Juergen Schmidt 2001-11-15 12:00:46 +0000 198) if ( !rename(tmpFileName.getStr(), targetFileName.getStr()) ) 07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 199) return true; d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 200) } else d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 201) return removeTypeFile(tmpFileName); d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 202) } else { d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 203) if (fileExists(targetFileName)) d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 204) if (!removeTypeFile(targetFileName)) 07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 205) return false; d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 206) d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 207) if ( rename(tmpFileName.getStr(), targetFileName.getStr()) ) { d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 208) if (errno == EEXIST) 07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 209) return true; d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 210) } else 07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 211) return true; b525a3115f545 (Jens-Heiner Rech 2000-09-18 14:29:57 +0000 212) } 07d3807e99944 (Stephan Bergmann 2014-02-15 14:52:41 +0100 213) return false; d1982890f344f (Oliver Bolte 2003-10-20 12:09:10 +0000 214) }
Thank you for reporting the bug. I can not reproduce the bug in 7.5.4.2