Exemple #1
0
    def validate_signature(self, keyrings):
        '''
        Validate the GPG signature of a .changes file.
        '''

        cmd = ['gpg', '--batch', '--status-fd', '1', '--no-default-keyring']
        for k in keyrings:
            cmd.extend(['--keyring', k])
        cmd.extend(['--verify', self.get_dud_file()])

        (gpg_output, gpg_output_stderr, exit_status) = run_command(cmd)

        if exit_status == -1:
            raise DudFileException('Unknown problem while verifying signature')

        if gpg_output.count('[GNUPG:] GOODSIG'):
            pass
        elif gpg_output.count('[GNUPG:] BADSIG'):
            raise DudFileException('Bad signature')
        elif gpg_output.count('[GNUPG:] ERRSIG'):
            raise DudFileException('Error verifying signature')
        elif gpg_output.count('[GNUPG:] NODATA'):
            raise DudFileException('No signature')
        else:
            raise DudFileException('Unknown problem while verifying signature')

        key = None
        for line in gpg_output.split('\n'):
            if line.startswith('[GNUPG:] VALIDSIG'):
                key = line.split()[2]
        return key
Exemple #2
0
    def _run_dak(self, args):
        from laniakea.utils import run_command

        cmd = [self._dak_exe]
        cmd.extend(args)

        out, err, ret = run_command(cmd, capture_output=not get_verbose())
        if ret != 0:
            raise Exception('Failed to run dak: {}\n{}'.format(
                out if out else '', err if err else ''))
        return out
Exemple #3
0
    def _run_germinate(self, wdir, args):
        from laniakea.utils import run_command, cd

        ge_args = [self._germinate_exe]
        ge_args.extend(args)

        with cd(wdir):
            out, err, ret = run_command(ge_args, capture_output=not get_verbose())
            if ret != 0:
                return False, '{}\n{}'.format(out, err)
            return True, out
Exemple #4
0
    def _run_germinate(self, wdir, args):
        from laniakea.utils import run_command, cd

        ge_args = [self._germinate_exe]
        ge_args.extend(args)

        with cd(wdir):
            out, err, ret = run_command(ge_args,
                                        capture_output=not get_verbose())
            if ret != 0:
                return False, '{}\n{}'.format(out, err)
            return True, out
Exemple #5
0
    def _run_dak(self, args, input_data=None, check=True):
        from laniakea.utils import run_command

        cmd = [self._dak_exe]
        cmd.extend(args)

        out, err, ret = run_command(cmd,
                                    input=input_data,
                                    capture_output=not get_verbose())
        out = out if out else ''
        err = err if err else ''
        if check and ret != 0:
            raise Exception('Failed to run dak: {}\n{}'.format(out, err))
        return ret, out + err
Exemple #6
0
    def _run_git(self, command, args, clone_dir=None, throw_error=True):

        git_cmd = [self._git_exe]
        if command == 'clone':
            git_cmd.append(command)
        elif clone_dir:
            git_cmd.extend(['-C', clone_dir, command])
        if args:
            git_cmd.extend(args)

        out, err, ret = run_command(git_cmd)
        if ret == 0:
            return True
        elif throw_error:
            raise Exception('Failed to run Git ({}): {}\n{}'.format(
                ' '.join(git_cmd), out, err))
Exemple #7
0
    def _run_git(self, command, args, clone_dir=None, throw_error=True):

        git_cmd = [self._git_exe]
        if command == 'clone':
            git_cmd.append(command)
        elif clone_dir:
            git_cmd.extend(['-C', clone_dir, command])
        if args:
            git_cmd.extend(args)

        out, err, ret = run_command(git_cmd)
        if ret == 0:
            return True
        elif throw_error:
            raise Exception('Failed to run Git ({}): {}\n{}', ' '.join(git_cmd), out, err)
            return False
Exemple #8
0
    def validate_signature(self, keyrings):
        '''
        Validate the GPG signature of a .changes file.
        '''

        cmd = ['gpg',
               '--batch',
               '--status-fd', '1',
               '--no-default-keyring']
        for k in keyrings:
            cmd.extend(['--keyring', k])
        cmd.extend(['--verify', self.get_dud_file()])

        (gpg_output, gpg_output_stderr, exit_status) = run_command(cmd)

        if exit_status == -1:
            raise DudFileException(
                'Unknown problem while verifying signature')

        if gpg_output.count('[GNUPG:] GOODSIG'):
            pass
        elif gpg_output.count('[GNUPG:] BADSIG'):
            raise DudFileException('Bad signature')
        elif gpg_output.count('[GNUPG:] ERRSIG'):
            raise DudFileException('Error verifying signature')
        elif gpg_output.count('[GNUPG:] NODATA'):
            raise DudFileException('No signature')
        else:
            raise DudFileException(
                'Unknown problem while verifying signature'
            )

        key = None
        for line in gpg_output.split('\n'):
            if line.startswith('[GNUPG:] VALIDSIG'):
                key = line.split()[2]
        return key