Page MenuHome GnuPG

Kleopatra: Reports success when gpgtar is kill with SIGTERM or SIGKILL while folder is encrypted
Closed, ResolvedPublic

Description

Reproduce:

  • Start the encryption of a folder with Kleopatra
  • While the encryption is in progress, kill the gpgtar process (e.g. killall gpgtar).

Expected result:
Kleopatra reports an error.

Observed result:
Kleopatra reports success.

Additional info:
If gpgtar is killed with SIGTERM, then the "audit log" ends with

gpgtar: signal Terminated caught ... exiting

It seems gpgtar happily exits with 0 and forgets to remove the partially written encrypted archive. The easiest solution would be to exit with a non-zero error code. Then gpgme and Kleopatra notice the error and the latter can take care of removing the left-over file.

Or, maybe the problem is that gpgme doesn't notice that gpgtar was killed. We may need an explicit "success" status, so that it's absence signals an error to gpgme.

Event Timeline

ikloecker renamed this task from Kleopatra: Reports success when gpgtar is kill with SIGTERM while folder is encrypted to Kleopatra: Reports success when gpgtar is kill with SIGTERM or SIGKILL while folder is encrypted.Jun 22 2023, 4:29 PM
ikloecker updated the task description. (Show Details)
ikloecker added a project: gpgme.
werner triaged this task as Normal priority.Jun 22 2023, 4:30 PM
werner added a subscriber: werner.

Due to the double fork in gpgme we won't get the exit code which gpgtar emits. Possible actions in a signal handler are also limited; in particular we can't use stdio or estream. The only option to print a status line would we by using write directly. However, this might mess with the libassuan buffering. Thus, it is not a good idea to pkill gpgtar. Same is true for gpg and gpgsm.

Kleopatra could wait for a success status (not sure whether we emit it)

Yes, gpgtar emits a SUCCESS status. gpgme should probably check for this.

Interestingly, if one kills gpgtar, then gpgme receives an "END_ENCRYPTION" (emitted by gpg?) after gpgtar wrote "gpgtar: signal Terminated caught ... exiting".

Status messages on successful creation of signed & encrypted archive

2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 0 3<LF>
2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar s 0 62 B<LF>

2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 3 3<LF>
2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar s 62 62 B<LF>

2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] KEY_CONSIDERED 5F4C389C9265ABDE08B21CEA
2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: 41FAC215ADE1CB46 2<LF>
2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] KEY_CONSIDERED 8EB9CBACA389D28CAA3CA15C
2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: 1F5C8972CE8BFED7 0<LF>
2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] PROGRESS stdin ? 0 0 B<LF>

2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] BEGIN_ENCRYPTION 0 9 2<LF>
2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] BEGIN_SIGNING H10<LF>
2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] PROGRESS stdin ? 3584 0 B<LF>

2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] SIG_CREATED S 1 10 00 1726665693 5F4C38
2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: 9C9265ABDE08B21CEA41FAC215ADE1CB46<LF>

2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] END_ENCRYPTION<LF>

2024-09-18 15:21:33 gpgme[3250.d47]     _gpgme_io_read: check: [GNUPG:] SUCCESS<LF>

Status messages if gpgtar is killed during the creation of signed & encrypted archive

2024-09-18 15:27:36 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 5000 0<LF>

2024-09-18 15:27:36 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 10000 0<LF>

[...]

2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 0 50576<LF>
2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar s 0 1082 MiB<LF>

2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] KEY_CONSIDERED 5F4C389C9265ABDE08B21CEA
2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: 41FAC215ADE1CB46 2<LF>
2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] KEY_CONSIDERED 8EB9CBACA389D28CAA3CA15C
2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: 1F5C8972CE8BFED7 0<LF>
2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS stdin ? 0 0 B<LF>

2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] BEGIN_ENCRYPTION 0 9 2<LF>
2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] BEGIN_SIGNING H10<LF>

2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 100 50576<LF>

2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 200 50576<LF>

[...]

2024-09-18 15:27:37 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 800 50576<LF>

2024-09-18 15:27:38 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS stdin ? 31232 0 KiB<LF>

2024-09-18 15:27:38 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 900 50576<LF>

[...]

2024-09-18 15:27:40 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS gpgtar c 3700 50576<LF>

2024-09-18 15:27:40 gpgme[3502.e35]       _gpgme_io_read: check: <LF>
2024-09-18 15:27:40 gpgme[3502.e35]       _gpgme_io_read: check: gpgtar: signal Terminated caught ... exiting<LF>

2024-09-18 15:27:40 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] PROGRESS stdin ? 130432 0 KiB<LF>

2024-09-18 15:27:41 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] SIG_CREATED S 1 10 00 1726666060 5F4C38
2024-09-18 15:27:41 gpgme[3502.e35]     _gpgme_io_read: check: 9C9265ABDE08B21CEA41FAC215ADE1CB46<LF>

2024-09-18 15:27:41 gpgme[3502.e35]     _gpgme_io_read: check: [GNUPG:] END_ENCRYPTION<LF>
ikloecker moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.
ikloecker changed the task status from Open to Testing.Sep 20 2024, 10:10 AM

gpgme now checks for a SUCCESS status emitted by gpgtar when creating a signed and/or encrypted archive. If gpgtar is killed (or exits without emitting SUCCESS for some other reason) then the partially created archive is removed and Kleopatra reports a failure.

This change is also used for VSD 3.3

This is included in test installers since some time already.

ikloecker moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Nov 14 2024, 2:16 PM
ebo moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.
ebo added a subscriber: ebo.

tested with Gpg4win-Beta-75++

ok, definitevly no success message any more in that case.

If you cancel the encryption with the taskmanager you get ~"Encryption failed. EOF".
If it was a sign+encrypt operation ~"Signature failed. EOF".
And if you cancel the pinentry window which will pop up (if your password for the signature was not cached" after you killed gpgtar you will get ~"Operation cancelled".

ebo edited projects, added vsd33 (vsd-3.3.0); removed vsd33.