Brendan,

sorry for the delay in answering, but I just spotted this mail today. More 
inline.

On Mittwoch, 13. Juni 2018 19:59:05 CEST Brendan Coupe wrote:

> I'm running KMM built from 5 master on Fedora 28.
> 
> I cannot open my encrypted KMM file. It works fine on my Fedora 27 computer
> running KMM compiled from the 4.8 branch.
> 
> When I try to open my file I get the following error message:
> 
> Cannot open file as requested. Error was: Cannot read the file:
> /home/bcoupe/KMM/xxxxx.kmy


That is strange. My main datafile is encrypted ever since I developed the 
encryption support and I don't see this kind of problem her on my openSUSE 
system.


> I created a new file and encrypted it. When I try to open it I get the same
> error message.
> 
> I then created another file without encrypting it and it opens without a
> problem.

This reduces the problem to the encrypted path.

> Both my normal KMM file and the test file can be decrypted manually (gpg
> -d).
> 
> I just recompiled and got a more detailed error message:
> 
> Cannot open file as requested. Error was: Cannot read the file:
> /home/bcoupe/KMM/TestKMM5.kmy
> /usr/local/src/kmm/kmymoney-MASTER-2018.06.13-11.36.36/kmymoney/plugins/xml/xmlstorage.cpp:141

Ok, it tries to open the file for reading which fails. Since it uses a pointer 
to the object and works if it points to a regular (unencrypted) file, this 
leaves the conclusion that it has something to do with the KGPGFile object it 
points to.

The last change was in that area was to remove the virtual keyword from the 
KGPGFile::open() declaration. This should not be a problem, but one never knows.

Since you compile from source, can you apply the attached patch which will add 
the virtual keyword again and give some more trace output for those cases when 
KGPGFile::open() fails and report back?

Thanks in advance.

-- 

Regards

Thomas Baumgart

https://www.telegram.org/       Telegram, the better WhatsApp
-------------------------------------------------------------
"Hey! I could use Tex!" and I've only gotten to use it a little
so far but it's so far superiour to MS Words "be everywhere do
everything"-ness it's not even funny... (lordSauron)
-------------------------------------------------------------
diff --git a/libkgpgfile/kgpgfile.cpp b/libkgpgfile/kgpgfile.cpp
index 8efa03a3..803dc7ce 100644
--- a/libkgpgfile/kgpgfile.cpp
+++ b/libkgpgfile/kgpgfile.cpp
@@ -33,6 +33,7 @@
 #include <QSaveFile>
 #include <QDateTime>
 #include <QStringList>
+#include <QDebug>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -129,15 +130,18 @@ void KGPGFile::addRecipient(const QString& recipient)
 bool KGPGFile::open(OpenMode mode)
 {
   if (isOpen()) {
+    qDebug() << "File is already open";
     return false;
   }
 
   if (d->m_fn.isEmpty()) {
     setOpenMode(NotOpen);
+    qDebug() << "No filename provided";
     return false;
   }
 
   if (!d->ctx) {
+    qDebug() << "No context available";
     setOpenMode(NotOpen);
     return false;
   }
@@ -145,6 +149,7 @@ bool KGPGFile::open(OpenMode mode)
   setOpenMode(mode);
 
   if (!(isReadable() || isWritable())) {
+    qDebug() << "Unknown mode";
     setOpenMode(NotOpen);
     return false;
   }
@@ -170,12 +175,14 @@ bool KGPGFile::open(OpenMode mode)
   if (isReadable()) {
     d->m_fileRead->setFileName(d->m_fn);
     if (!d->m_fileRead->open(mode)) {
+      qDebug() << "Unable to open file" << d->m_fn;
       setOpenMode(NotOpen);
       return false;
     }
     GpgME::Data dcipher(d->m_fileRead->handle());
     d->m_lastError = d->ctx->decrypt(dcipher, d->m_data).error();
     if (d->m_lastError.encodedError()) {
+      qDebug() << "Decryption problem" << d->m_lastError.asString();
       return false;
     }
     d->m_data.seek(0, SEEK_SET);
diff --git a/libkgpgfile/kgpgfile.h b/libkgpgfile/kgpgfile.h
index 9781f5bd..efca4344 100644
--- a/libkgpgfile/kgpgfile.h
+++ b/libkgpgfile/kgpgfile.h
@@ -73,12 +73,12 @@ public:
 
   ~KGPGFile();
 
-  bool open(OpenMode mode) final override;
-  void close() final override;
+  virtual bool open(OpenMode mode) final override;
+  virtual void close() final override;
   virtual void flush();
 
-  qint64 readData(char *data, qint64 maxlen) final override;
-  qint64 writeData(const char *data, qint64 maxlen) final override;
+  virtual qint64 readData(char *data, qint64 maxlen) final override;
+  virtual qint64 writeData(const char *data, qint64 maxlen) final override;
 
   /**
     * Adds a recipient for whom the file should be encrypted.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to