Page MenuHome GnuPG

Kleopatra: sign/encrypt folder results in general error
Closed, ResolvedPublic

Description

Debugview shows:

[7328] org.kde.pim.kleopatra: dirs ("C:/Users/g10code.WIN-TEST3/Documents/testordner/")
[7328] org.kde.pim.kleopatra: ArchiveDefinition[ "tar" ] ("C:\\Program Files (x86)\\GnuPG VS-Desktop\\GnuPG\\/bin/gpgtar", "--utf8-strings", "--openpgp", "--skip-crypto", "--output", "-", "--encrypt", "-T-", "--null", "--")
[7328] org.kde.pim.kleopatra: ArchiveDefinition[ "tar" ] find -print0 |  "C:/Program Files (x86)/GnuPG VS-Desktop/GnuPG//bin/gpgtar.exe" ("--utf8-strings", "--openpgp", "--skip-crypto", "--output", "-", "--encrypt", "-T-", "--null", "--")
[7328] org.kde.pim.kleopatra: ArchiveDefinition[ "tar" ] ("C:\\Program Files (x86)\\GnuPG VS-Desktop\\GnuPG\\/bin/gpgtar", "--utf8-strings", "--cms", "--skip-crypto", "--output", "-", "--encrypt", "-T-", "--null", "--")
[7328] org.kde.pim.kleopatra: ArchiveDefinition[ "tar" ] find -print0 |  "C:/Program Files (x86)/GnuPG VS-Desktop/GnuPG//bin/gpgtar.exe" ("--utf8-strings", "--cms", "--skip-crypto", "--output", "-", "--encrypt", "-T-", "--null", "--")
[7328] org.kde.pim.kleopatra: ArchiveDefinition[ "tar" ] ("C:\\Program Files (x86)\\GnuPG VS-Desktop\\GnuPG\\/bin/gpgtar", "--utf8-strings", "--openpgp", "--skip-crypto", "--set-filename", "%F", "--decrypt", "--", "-")
[7328] org.kde.pim.kleopatra: ArchiveDefinition[ "tar" ] "C:/Program Files (x86)/GnuPG VS-Desktop/GnuPG//bin/gpgtar.exe" ("--utf8-strings", "--openpgp", "--skip-crypto", "--set-filename", "%F", "--decrypt", "--", "-") "%f" ()
[7328] org.kde.pim.kleopatra: ArchiveDefinition[ "tar" ] ("C:\\Program Files (x86)\\GnuPG VS-Desktop\\GnuPG\\/bin/gpgtar", "--utf8-strings", "--cms", "--skip-crypto", "--set-filename", "%F", "--decrypt", "--", "-")
[7328] org.kde.pim.kleopatra: ArchiveDefinition[ "tar" ] "C:/Program Files (x86)/GnuPG VS-Desktop/GnuPG//bin/gpgtar.exe" ("--utf8-strings", "--cms", "--skip-crypto", "--set-filename", "%F", "--decrypt", "--", "-") "%f" ()
[7328] org.kde.pim.kleopatra: 0x7eac830
[7328] org.kde.pim.kleopatra: dirs ("C:/Users/g10code.WIN-TEST3/Documents/testordner/")
[7328] org.kde.pim.kleopatra: heuristicBaseDirectory( ("C:/Users/g10code.WIN-TEST3/Documents/testordner/Unterordner") ) -> "C:/Users/g10code.WIN-TEST3/Documents/testordner"
[7328] org.kde.pim.kleopatra: relative paths: std::vector("Unterordner")
[7328] org.kde.pim.kleopatra: Task:  "Unterordner"  has no total progress set. 
[7328] org.kde.pim.kleopatra: 0x7eac830
[7328] org.kde.pim.kleopatra: 0x7eac830
[7328] org.kde.pim.kleopatra: 
[7328] inputError : "" 
[7328] outputError: "Unbekannter Fehler"

Details

Version
VS-Desktop-3.1.27.0-beta44

Event Timeline

ebo triaged this task as High priority.Apr 3 2023, 4:36 PM
ebo created this task.

Only Sign results in the same error as Sign+Encrypt (which was the picture above)

Encrypt-only does not throw an error but does result in an empty folder Unterordner.tar.gpg:


-> overwrite

I could not reproduce the problem with a self-build gpg4win 4.1.1 (e5dee8abf3045c970f4ba7a0dd7ee5daf08fe7cb). Please list the content of the folder Unterordner.

Update: It seems my build does not use the new code.
Update: gpg4win packages gnupg-w32-2.4.0_20221216 which is way too old.

Verzeichnis von C:\Users\g10code.WIN-TEST3\Documents\testordner\Unterordner
05.04.2023  09:34    <DIR>          .
05.04.2023  09:34    <DIR>          ..
30.03.2023  15:18                36 Textdatei3.txt
               1 Datei(en),             36 Bytes
               2 Verzeichnis(se), 19.342.049.280 Bytes frei
ikloecker renamed this task from Kleopatra: sing/encrypt folder results in general error to Kleopatra: sign/encrypt folder results in general error.Apr 5 2023, 1:24 PM

The gpgme logs show that gpgtar is called with gpgtar [...] --status-fd 1 [...] --output - [...], i.e. fd 1 is used for status output and for the result output of gpgtar. This cannot work. To me this looks like a flawed implementation of _gpgme_io_pipe() resp. new_fd() in w32-io.c which happily returns 1 as FD on the first call.

Note that before the removal of GPA (and glib) the completely different implementation of _gpgme_io_pipe() in w32-glib-io.c was used. So this could be an unforseen regression caused by the removal of GPA and unused code in w32-io.c that suddenly gets used.

@werner Please have a look.

ebo moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Apr 12 2023, 2:46 PM
ebo moved this task from Backlog to WiP on the gnupg24 board.
ebo moved this task from Backlog to WiP on the gnupg22 board.

On Windows we always use --status-fd=1 but with gpg it is not a problem because we use a differenrt fd for output.

gpg_encrypt (engine-gpg.c) passes --output - to gpg, i.e. it reads the result of gpg --encrypt from stdout unless I misread this. Not sure, why this seems to work on Windows. The real problem is probably something completely different.

werner moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.

The actual error is in gpgme. CreateProcess is called with "gpgtar" but "gpgtar.exe" must be used.
This has been fixed with commit rM0c29119e061c. The reason why we didn't noticed the real cause of the problem is that the CreateProcess error shows up in the gpgme-w32spawn helper which has no good way for returning errors.

BTW, the --status-fd=1 was a false trail because under Windows the value is an index into an internal fd table. gpgme-w32spawn is given a mapping file which fixes this up to the real fd (actually a HANDLE) before actually calling gpgtar.exe or gpg.exe.

ebo changed the task status from Open to Testing.Apr 19 2023, 8:58 AM
ebo moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.

works now, Gpg4win-4.1.1-beta295