Commit 65a986bf authored by Jérôme Charaoui's avatar Jérôme Charaoui Committed by anarcat
Browse files

Ignore irrelevant gpg errors (closes #736548)

This will allow the expect_pattern() to skip gpg
errors which are not useful: KEYEXPIRED, SIGEXPIRED
and "gpg: moving a key signature to the correct place"

For descriptions of these errors, see GnuPG
documentation in doc/DETAILS
parent 9aea9fcb
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -225,8 +225,17 @@ class Context():

        this therefore looks only at the next line, but may also hang
        like seek_pattern()

        if the beginning of the line matches a pattern which is
        being ignored, it will skip it and look at the next line
        """
        line = fd.readline()
        ignored = ('[GNUPG:] KEYEXPIRED', '[GNUPG:] SIGEXPIRED', 'gpg: ')

        while line and line.startswith(ignored):
            if self.debug: print >>self.debug, "SKIPPED:", line,
            line = fd.readline()

        match = re.search(pattern, line)

        if self.debug:
@@ -470,15 +479,6 @@ class Keyring():
        except GpgProtocolError as e:
            if 'sign_uid.okay' in str(e):
                multiuid = False
            elif '[GNUPG:]' not in str(e):
                # this is not a protocol message, try again but skipping now
                # this was necessary in order to sign Zack's key, as it was spewing:
                # gpg: moving a key signature to the correct place
                # instead of a [GNUGPG:] message
                try:
                    multiuid = self.context.seek(proc.stderr, 'GET_BOOL keyedit.sign_all.okay')
                except GpgProtocolError as e:
                    raise GpgRuntimeError(self.context.returncode, _('cannot select uid for signing: %s') % e.found().decode('utf-8'))
            else:
                raise GpgRuntimeError(self.context.returncode, _('cannot select uid for signing: %s') % e.found().decode('utf-8'))
        if multiuid: