Bug 40244 - FILESAVE to ODF formats: read-only location gives wrong error message
Summary: FILESAVE to ODF formats: read-only location gives wrong error message
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All Linux (All)
: medium minor
Assignee: Justin L
URL:
Whiteboard: target:24.8.0
Keywords:
: 101673 115796 144298 (view as bug list)
Depends on:
Blocks: Error-Messages Save
  Show dependency treegraph
 
Reported: 2011-08-19 13:30 UTC by brookembecker
Modified: 2024-03-18 13:22 UTC (History)
10 users (show)

See Also:
Crash report or crash signature:


Attachments
saveWithoutFolderPermissions-xlsx.png: single, meaningful error message (10.12 KB, image/png)
2024-03-13 17:03 UTC, Justin L
Details
saveWithoutFolderPermissions-ods.png: ODF formats say "<path> does not exist" (7.37 KB, image/png)
2024-03-13 17:08 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description brookembecker 2011-08-19 13:30:55 UTC
Trying to save a file to a write-only folder on an ext3 disk mounted on /media/<volume name>/ gives error message "Error saving the document <document name>: <path>/<document name> does not exist". After changing folder permissions to read+write file saves ok without any errors. The error message could be more useful.

This is LibreOffice as packaged with Ubuntu 11.04. It reports itself as:
LibreOffice 3.3.3 
OOO330m19 (Build:301)
tag libreoffice-3.3.3.1, Ubuntu package 1:3.3.3-1ubuntu2
Comment 1 Jeffrey 2011-08-20 06:08:09 UTC
At first I thought that you meant the problem was that you could not save the file properly, which did not make sense because an unwritable file cannot be written to, but now I understand that you mean that instead of saying "Error saving... .odt does not exist", it should say "writing to a protected file" or something along that line, right?

I think this could possibly be an EasyHack.
Comment 2 brookembecker 2011-08-21 07:04:32 UTC
(In reply to comment #1)

Exactly - "Cannot write to read-only location" makes more sense than "Cannot write because file does not exist". To be clear, it was the whole directory that was read-only; there was not already an existing file of the same name.
Comment 3 noname 2011-08-21 07:58:33 UTC
Hmmmm. Difficult one. Might be that fopen() uses the mode WB+ (or RB+) instead of WB ?!
Comment 4 Björn Michaelsen 2011-12-23 12:38:30 UTC Comment hidden (noise)
Comment 5 Florian Reisinger 2012-08-14 13:59:40 UTC Comment hidden (noise)
Comment 6 Florian Reisinger 2012-08-14 14:00:50 UTC Comment hidden (noise)
Comment 7 Florian Reisinger 2012-08-14 14:05:34 UTC Comment hidden (noise)
Comment 8 Florian Reisinger 2012-08-14 14:07:35 UTC Comment hidden (noise, obsolete)
Comment 9 sasha.libreoffice 2012-10-08 12:31:20 UTC
reproduced in 3.6.2 on Fedora 64 bit
tried to save to /opt
Comment 10 leighman 2012-10-08 17:07:29 UTC
Reported confirmed.
Comment 11 Alexandr 2014-12-31 10:52:51 UTC
Reproducible with LibreOffice 4.3.3 and 4.4.0 beta2 on Debian. I tried to save a file to a read only folder in ext4 filesystem and to a NTFS filesystem mounted read only.
Comment 12 QA Administrators 2016-01-17 20:04:26 UTC Comment hidden (obsolete)
Comment 13 Buovjaga 2018-03-07 12:10:28 UTC
*** Bug 115796 has been marked as a duplicate of this bug. ***
Comment 14 Buovjaga 2018-03-07 12:11:06 UTC
I noticed that on Windows we get a system message that is not the same as on Linux.
Windows: "You don't have permission to save in this location" etc.
Linux: "Error saving the document Untitled 1: /path/to/Untitled 1.odt does not exist."

The weird thing is, according to these the message should be different: https://bugs.launchpad.net/ubuntu/+source/openoffice.org/+bug/257421
https://bbs.archlinux.org/viewtopic.php?id=197928

The error text seems to be here: https://opengrok.libreoffice.org/xref/core/svtools/inc/errtxt.hrc#33

Arch Linux 64-bit
Version: 6.1.0.0.alpha0+
Build ID: 856c57f20f9b07c686a854e0ccbb6ee3b0ee4791
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on March 7th 2018
Comment 15 QA Administrators 2019-10-08 02:28:08 UTC Comment hidden (noise)
Comment 16 QA Administrators 2021-10-08 03:52:43 UTC Comment hidden (noise, obsolete)
Comment 17 Stéphane Guillou (stragu) 2022-12-31 13:42:44 UTC
*** Bug 144298 has been marked as a duplicate of this bug. ***
Comment 18 Stéphane Guillou (stragu) 2022-12-31 15:01:48 UTC
With steps from bug 144298:

1.  mkdir /tmp/Testdir
2.  chmod -w /tmp/Testdir
3.  Attempt to save any file from LO into /tmp/Testdir/something

Repro on a recent master build:

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 12e8d57e791bb1befc0716d4d02af7d1d1ccb4ae
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded
Comment 19 Stéphane Guillou (stragu) 2022-12-31 15:06:21 UTC
*** Bug 101673 has been marked as a duplicate of this bug. ***
Comment 20 Justin L 2024-03-13 17:03:38 UTC
Created attachment 193093 [details]
saveWithoutFolderPermissions-xlsx.png: single, meaningful error message

fun fact: the error message is clear when saving to DOC/X, or XLS/X formats.
Comment 21 Justin L 2024-03-13 17:08:02 UTC
Created attachment 193094 [details]
saveWithoutFolderPermissions-ods.png: ODF formats say "<path> does not exist"

repro 24.8+

It is only with ODF formats that I can reproduce this complaint. As others have mentioned, there are three warnings. The first two say "does not exist" and the last message is "Write Error. The file could not be written."
Comment 22 Justin L 2024-03-14 00:04:52 UTC
The code in question is in SfxObjectShell::SaveTo_Impl.
The formats diverge because ODF is bStorageBasedTarget and therefore it tries to rMedium.GetOutputStorage().

The first thing that GetOutputStorage does is SfxMedium::CreateTempFileNoCopy() which just sets ERRCODE_IO_CANTWRITE when the temporary filename fails.
It then tries to return GetStorage() which makes two calls to GetMedium_Impl() which is the source of the first two error messages. The final error message is the expected one when SaveTo_Impl fails.
Comment 23 Commit Notification 2024-03-18 13:21:15 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5441ed518d36ac12a6bd0c517e2cfc24aff94d50

tdf#40244 tdf#160192: create tempFile elsewhere if LogicBase is RO

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.