Bug 479567 - gpgtar broken pipe
Summary: gpgtar broken pipe
Status: REPORTED
Alias: None
Product: kleopatra
Classification: Applications
Component: general (show other bugs)
Version: 3.1.28.230804
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Ingo Klöcker
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-09 09:48 UTC by Daniel
Modified: 2025-02-01 16:31 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
The error message (76.20 KB, image/png)
2024-01-09 09:48 UTC, Daniel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel 2024-01-09 09:48:35 UTC
Created attachment 164773 [details]
The error message

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Select a number of files to encypt
2. Encrypt them altogether. (gpgtar)
3. Receive the error 'Broken pipe'

OBSERVED RESULT

gpg: Atención: "--ttytype=xterm" no se considera una opción
gpg: Atención: "--always-trust" no se considera una opción
uso: gpg [opciones] --sign --encrypt [filename]
gpgtar: error writing '[?]': Tubería rota
gpgtar: creating tarball '/home/user/folder/archivo comprimido.S3sLyJ9d.tar.gpg.part' failed: Tubería rota

The result can see in the screenshot attached

EXPECTED RESULT

If a run gpgtar -e -s -o file.pgp -r 'my key id' file1 file2... in Konsole, it works. 

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Andreas Hartmann 2024-10-11 04:10:00 UTC
Hi,
I am experiencing the same problem here (version 3.1.28.230805 using X11) and tracked it down. Problem is the call to gpgtar, which is generated by kleopatra to build the tar.gpg file. It is just broken:

gpgtar --batch --status-fd 23 --gpg-args --no-tty --gpg-args --charset=utf8 --gpg-args --enable-progress-filter --gpg-args --exit-on-status-write-error --gpg-args --display=:0 --gpg-args --ttyname=kein Terminal --gpg-args --ttytype=xterm --encrypt --sign --gpg-args --always-trust -r .... -u ... --output /tmp/test.tar.gpg --directory /tmp --files-from - --null --utf8-strings

The culprit is the option --gpg-args --ttyname=kein Terminal
kein and Terminal are separated - but they must be one part. Maybe a problem of the translation - don't know what name is used in English for the option --ttyname.

I "fixed" it by adding an own gpgtar file, which repairs the broken call before it is passed to gpgtar:

#!/bin/sh
tmp=`echo "$@" | sed -e "s/ --gpg-args --ttyname=kein Terminal//" -e "s/ --gpg-args --ttytype=xterm//"`
exec /usr/bin/gpgtar.bin $tmp

But there are many more problems:
- If you encrypt a tar.gpg file, the timestamps of all encrypted files are lost. They all have the actual timestamp. An error which has been fixed some time ago and now is there again.
- The directory structure is broken through decrypt. A given directory structure in tar of /1/2 is decrypted to /1/1/2
- Filenames seam to be interpreted during decryption. Therefore, some filenames can't be written to disk, because it's data garbage.

gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: warning: name not terminated by a nul
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: header block 2 is corrupt (size=0 type=10 nrec=0)
gpgtar: error creating '/raid/daten3/Transfer/Grafik/Sync/kleopatra-BRGyuw/Vattenfall/%PDF-1.7\n%����\n3 0 obj\n<</Length 2 0 R/Filter/FlateDecode/N 3/Range[0 1 0 1 0 1 ]>>\nstream\nx���wTS�\x16': Datei oder Verzeichnis nicht gefunden
gpg: error writing to '-': Datenübergabe unterbrochen (broken pipe)
gpg: handle plaintext failed: Datenübergabe unterbrochen (broken pipe)

Filenames leading to the above error are:
Arc_S_AUSWILL12226500100000DP20025020160103sapi2pci_I2P_401708914001236_3_Q1e6-1146.pdf.pdf
Arc_S_BLANK12226500100000DP20025020160103sapi2pci_I2P_401690808701147_Q4zk-20.pdf
Arc_S_BLANK12226500100000DP20025020160103sapi2pci_I2P_401721227200945_Q1-1180.pdf.pdf
Arc_ZVFE_JS_EZE01K650011251005222DP20024620160103sapi2pci_I2P_401723144142381_Q3m-352.pdf.pdf
Arc_ZVFE_JS_VBESTK650011251005222DP20024620160103sapi2pci_I2P_401704151142473_4_Q33k-432.pdf

The encrypt path seams to be working - I couldn't see any problem there so far.
kggpg can be always used to decrypt the tar.gpg files. It doesn't show the above described errors.
Comment 2 Ingo Klöcker 2024-11-05 13:58:17 UTC
Andreas, thanks for identifying the cause of the original report.

Some remarks for the additional issues mentioned by Andreas Hartmann in comment #1:
> - If you encrypt a tar.gpg file, the timestamps of all encrypted files are
> lost. They all have the actual timestamp. An error which has been fixed some
> time ago and now is there again.

I doubt this ever worked with gpgtar, but in the past we have used tar+gpg instead of gpgtar and tar does preserve timestamps. Unfortunately, gpgtar doesn't. That's tracked by https://dev.gnupg.org/T5054.

> - The directory structure is broken through decrypt. A given directory
> structure in tar of /1/2 is decrypted to /1/1/2

This might be intentional. gpgtar never extracts to an existing non-empty directory. If that's not what you are seeing then file a ticket at https://dev.gnupg.org/.

> - Filenames seam to be interpreted during decryption. Therefore, some
> filenames can't be written to disk, because it's data garbage.

This looks like https://dev.gnupg.org/T4554. I created an archive with the filenames you listed (with gpgtar --create and copies of a random PDF file), but I could extract it without problems (with gpgtar --extract). Maybe encryption/decryption is required to trigger the problem.
Comment 3 Ingo Klöcker 2024-11-05 16:24:41 UTC
I have no idea why on your systems ttyname is "kein Terminal" (or maybe the Spanish equivalent). The only explanation I have is that for some reason the environment variable GPG_TTY is set to this invalid value. If GPG_TTY is set then it must be set to a valid ttyname (i.e. a pathname like /dev/tty or /dev/pts/42) or the empty string, but it must not be set to "kein Terminal", "ningún terminal" or whatever.

Please check what value the environment variable GPG_TTY is set to.
Comment 4 Andreas Hartmann 2024-11-06 04:26:46 UTC
Hello Ingo,
GPG_TTY is set to something like /dev/pts/[number] - that's the expected value. Tested in a pure konsole or in the konsole of dolphin.  Don't know where to search the origin of "kein Terminal".
I added a echo $GPG_TTY to my gpgtar helper bash script. At this point, the GPG_TTY env variable contains "kein Terminal". Don't know where it comes from.

The problem with directories during decryption can be seen, too, if the target directory doesn't exist at all. It's always directoryname/directoryname/ . For me, this behavior is just broken and doesn't make any sense.
Comment 5 Bug Janitor Service 2024-11-21 03:46:32 UTC
🐛🧹 ⚠️ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Ingo Klöcker 2024-11-21 10:35:48 UTC
Andreas, thanks for the feedback. How do you start Kleopatra? Does the problem also occur if you start Kleopatra from Konsole? Make sure that Kleopatra is not still running (minimized in the system tray) when you try running it from Konsole.
Comment 7 Andreas Hartmann 2024-11-21 13:57:27 UTC
The problem doesn't happen., if kleopatra is started in konsole before it is used. "Used" means: I do a right click to a file in dolphin, go to action and select decrypt / check e.g.
If I'm directly using the action decrypt / check before starting kleopatra manually, the problem comes up. Same problem happens, if  kleopatra is started via krunner before instead of via konsole.
Comment 8 Christian (Fuchs) 2025-02-01 16:31:39 UTC
I can reproduce the very same thing with kleopatra Version 4.0.0.241201 (24.12.1). GnuPG 2.4.5, Libgcrypt 1.11.0-unknown in Fedora 41.

If I try to pack and encrypt a folder from the dolphin service menu, I get the same error.
If I start kleopatra manually beforehand and then do the very same action from the dolphin service menu, it works.

Locale is also German, but I assume this happens with every locale where that translation contains a space.