[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][ftp-team/dak][master] 3 commits: gpg.py: exit with status code `2` when failing to exec gpg



Title: GitLab

Ansgar pushed to branch master at Debian FTP Team / dak

Commits:

  • f74dfe7d
    by Ansgar at 2022-06-30T09:58:41+02:00
    gpg.py: exit with status code `2` when failing to exec gpg
    
    The `gpg` program uses `0` for no severe error, `1` if at least a
    signature was bad and other error codes for fatal errors.  Exiting
    with code `1` here might therefore be confusing.
    
  • 22f60fb5
    by Ansgar at 2022-06-30T10:00:24+02:00
    gpg.py: write error message when failing to exec gpg
    
  • d517ab99
    by Ansgar at 2022-06-30T10:00:49+02:00
    gpg.py: fail early if gpg indicated a fatal error
    

1 changed file:

Changes:

  • daklib/gpg.py
    ... ... @@ -138,6 +138,10 @@ class SignedFile:
    138 138
                         stderr = self.stderr.decode('ascii', errors='replace')
    
    139 139
                         raise GpgException("No status output from GPG. (GPG exited with status code %s)\n%s" % (exit_code, stderr))
    
    140 140
     
    
    141
    +                if exit_code not in (0, 1):
    
    142
    +                    stderr = self.stderr.decode('ascii', errors='replace')
    
    143
    +                    raise GpgException(f"GPG exited with a fatal error (exit code {exit_code})\n{stderr}")
    
    144
    +
    
    141 145
                     for line in self.status.splitlines():
    
    142 146
                         self._parse_status(line)
    
    143 147
     
    
    ... ... @@ -288,7 +292,13 @@ class SignedFile:
    288 292
     
    
    289 293
                 os.execvp(self.gpg, args)
    
    290 294
             finally:
    
    291
    -            os._exit(1)
    
    295
    +            try:
    
    296
    +                print("Failed to execute gpg.", file=sys.stderr)
    
    297
    +                sys.stderr.flush()
    
    298
    +            except:
    
    299
    +                # Ignore errors, we want to reach the `exit` call below.
    
    300
    +                pass
    
    301
    +            os._exit(2)
    
    292 302
     
    
    293 303
         def contents_sha1(self):
    
    294 304
             return apt_pkg.sha1sum(self.contents)
    


  • Reply to: