diff options
Diffstat (limited to 'backend/raw_write.py')
-rwxr-xr-x | backend/raw_write.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/backend/raw_write.py b/backend/raw_write.py index a940199..7581fe1 100755 --- a/backend/raw_write.py +++ b/backend/raw_write.py @@ -162,15 +162,15 @@ class Dumper(object): gpg = gnupg.GPG() gpg.encoding = 'utf-8' # Use Mageia public key - sum_type = 'sha3' - sig_file = "{}.{}.gpg".format(source, sum_type) - source_file = "{}.{}".format(source, sum_type) + self.sum_type = 'sha3' + sig_file = "{}.{}.gpg".format(source, self.sum_type) + self.source_file = "{}.{}".format(source, self.sum_type) try: - gpg.recv_keys('pgp.mit.edu', 'EDCA7A90') + gpg.recv_keys('pool.sks-keyservers.net', 'EDCA7A90') self.sum_check_searched = True with open(sig_file, 'rb') as g: self.signature_found = True - verified = gpg.verify_file(g, source_file) + verified = gpg.verify_file(g, self.source_file) if verified.valid: self.signature_checked = True logging.debug("signature checked") @@ -181,12 +181,12 @@ class Dumper(object): logging.info(_("Signature file {} not found\n").format(sig_file)) try: # Look for sum files in the same directory as source - with open(source_file,'r') as fs: + with open(self.source_file,'r') as fs: # Read the sum in the file self.sum_check=(fs.readline()).split()[0] self.sum_file = True except: - logging.info(_("Sum file {} not found\n").format(source_file)) + logging.info(_("Sum file {} not found\n").format(self.source_file)) self.sum_file = False def _check_write(self, target, source): @@ -210,23 +210,28 @@ class Dumper(object): self._progress = indice indice +=1 checked+=1024 + logging.debug("last read %d"%(b-ncuts*1024)) block = f.read(b-ncuts*1024) sha512func.update(block) - sha512sumcalc=sha512func.hexdigest() + sha512sumcalc=sha512func.hexdigest().upper() f.close() + logging.info(_('SHA3 sum: {}').format(sha512sumcalc)) if self.signature_found and not self.signature_checked: #, keep the pourcent, this is the place for source file name - self.return_message = _('Invalid signature for %s')%source_file + self.return_message = _('Invalid signature for %s')%self.source_file if (self.sum_check == "") : # Can't get stored sum self.return_message += _('SHA3 sum: {}').format(sha512sumcalc) # compare the sums elif (sha512sumcalc == self.sum_check) : if self.signature_checked: #, keep the bracket, this is the place for sum type - self.return_message +="\n" + _("The {} sum check is OK and the sum is signed").format(sum_type) + self.return_message +="\n" + _("The {} sum check is OK and the sum is signed").format(self.sum_type) else : - #, keep the bracket, this is the place for sum type - self.return_message +="\n" + _("The {} sum check is OK but the signature can't be found").format(sum_type) + if self.signature_found: + self.return_message +="\n" + _("The signature of the sum is false !").format(self.sum_type) + else: + #, keep the bracket, this is the place for sum type + self.return_message +="\n" + _("The {} sum check is OK but the signature can't be found").format(self.sum_type) else: self.return_message +="\n" + _("/!\\The computed and stored sums don't match") #except: |