wsd/ClientSession.cpp  |   23 +++++++++++++++--------
 wsd/DocumentBroker.cpp |    1 -
 2 files changed, 15 insertions(+), 9 deletions(-)

New commits:
commit 7fdb0cf9607217bb19e7de51c1a3e339f488e7b1
Author:     Ashod Nakashian <[email protected]>
AuthorDate: Tue Aug 13 20:03:40 2019 -0400
Commit:     Jan Holesovsky <[email protected]>
CommitDate: Fri Nov 15 11:12:53 2019 +0100

    wsd: block save of read-only documents
    
    WSD is responsible for checking permissions,
    as we do with DisableCopy and DisablePrint,
    but until now we allowed saving even on
    read-only documents.
    
    The reason, it seems, was that when we failed
    to save a document due to disk space, we
    set documents as read-only. So presumably
    we still had to allow saving, so users
    preserve their latest changes when the disk
    has some free space. Meanwhile, we didn't
    let users make further changes. At least
    this seems to be a reasonable explanation.
    
    Unfortunately this meant that we allowed
    saving when the user had no permission,
    or the document was loaded as read-only.
    
    Now we no longer mark documents that fail
    to save due to disk-space limitation as
    read-only, and instead expect the client
    to notify the user and (possibly) block
    further edits. And read-only documents,
    or users without write permission, are
    no longer allowed to get saved.
    
    This change makes sure that the ctrl+s
    shortcut respects the read-only flag,
    while we allow clients to disable
    the default handler and decide what to
    do (although now they cannot force saving
    when the user has no permission, something
    they could do previously).
    
    Change-Id: I16c3b75fd3e54435d750948a25afd6f71c9f963b
    Reviewed-on: https://gerrit.libreoffice.org/77594
    Reviewed-by: Ashod Nakashian <[email protected]>
    Tested-by: Ashod Nakashian <[email protected]>
    (cherry picked from commit 6d94b35c35bd30e10963bc64bea9ca4e1e253a81)
    Reviewed-on: https://gerrit.libreoffice.org/82705
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Jan Holesovsky <[email protected]>

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index c898049d0..6f65f6fc9 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -261,16 +261,23 @@ bool ClientSession::_handleInput(const char *buffer, int 
length)
     }
     else if (tokens[0] == "save")
     {
-        int dontTerminateEdit = 1;
-        if (tokens.size() > 1)
-            getTokenInteger(tokens[1], "dontTerminateEdit", dontTerminateEdit);
+        if (isReadOnly())
+        {
+            LOG_WRN("The document is read-only, cannot save.");
+        }
+        else
+        {
+            int dontTerminateEdit = 1;
+            if (tokens.size() > 1)
+                getTokenInteger(tokens[1], "dontTerminateEdit", 
dontTerminateEdit);
 
-        // Don't save unmodified docs by default, or when read-only.
-        int dontSaveIfUnmodified = 1;
-        if (!isReadOnly() && tokens.size() > 2)
-            getTokenInteger(tokens[2], "dontSaveIfUnmodified", 
dontSaveIfUnmodified);
+            // Don't save unmodified docs by default.
+            int dontSaveIfUnmodified = 1;
+            if (tokens.size() > 2)
+                getTokenInteger(tokens[2], "dontSaveIfUnmodified", 
dontSaveIfUnmodified);
 
-        docBroker->sendUnoSave(getId(), dontTerminateEdit != 0, 
dontSaveIfUnmodified != 0);
+            docBroker->sendUnoSave(getId(), dontTerminateEdit != 0, 
dontSaveIfUnmodified != 0);
+        }
     }
     else if (tokens[0] == "savetostorage")
     {
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 0ddd086a1..cc634af80 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -954,7 +954,6 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
         // Make everyone readonly and tell everyone that storage is low on 
diskspace.
         for (const auto& sessionIt : _sessions)
         {
-            sessionIt.second->setReadOnly();
             sessionIt.second->sendTextFrame("error: cmd=storage 
kind=savediskfull");
         }
     }
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to