Package dak :: Module manage_external_signature_requests
[hide private]
[frames] | no frames]

Source Code for Module dak.manage_external_signature_requests

  1  #! /usr/bin/env python3 
  2   
  3  """Manage external signature requests 
  4   
  5  @contact: Debian FTPMaster <ftpmaster@debian.org> 
  6  @copyright: 2018, Ansgar Burchardt <ansgar@debian.org> 
  7   
  8  """ 
  9   
 10  # This program is free software; you can redistribute it and/or modify 
 11  # it under the terms of the GNU General Public License as published by 
 12  # the Free Software Foundation; either version 2 of the License, or 
 13  # (at your option) any later version. 
 14   
 15  # This program is distributed in the hope that it will be useful, 
 16  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 17  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 18  # GNU General Public License for more details. 
 19   
 20  # You should have received a copy of the GNU General Public License 
 21  # along with this program; if not, write to the Free Software 
 22  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 23   
 24  ################################################################################ 
 25   
 26  import apt_pkg 
 27  import sys 
 28   
 29  from daklib import daklog 
 30  from daklib.dbconn import * 
 31  from daklib.config import Config 
 32  from daklib.externalsignature import * 
 33   
 34  ################################################################################ 
 35   
 36  Options = None 
 37  Logger = None 
 38   
 39  ################################################################################ 
 40   
 41   
42 -def usage(exit_code=0):
43 print("""Usage: dak manage-external-signature-requests [OPTIONS] 44 Manage external signature requests such as requests to sign EFI binaries or 45 kernel modules. 46 47 -h, --help show this help and exit""") 48 49 sys.exit(exit_code)
50 51 ################################################################################ 52 53
54 -def main():
55 global Options, Logger 56 57 cnf = Config() 58 59 for i in ["Help"]: 60 key = "Manage-External-Signature-Requests::Options::{}".format(i) 61 if key not in cnf: 62 cnf[key] = "" 63 64 Arguments = [('h', "help", "Manage-External-Signature-Requests::Options::Help")] 65 66 apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) 67 Options = cnf.subtree("Manage-External-Signature-Requests::Options") 68 69 if Options["Help"]: 70 usage() 71 72 Logger = daklog.Logger('manage-external-signature-requests') 73 74 if 'External-Signature-Requests' not in cnf: 75 print("DAK not configured to handle external signature requests") 76 return 77 78 config = cnf.subtree('External-Signature-Requests') 79 80 session = DBConn().session() 81 82 export_external_signature_requests(session, config['Export']) 83 84 if 'ExportSigningKeys' in config: 85 args = { 86 'pubring': cnf.get('Dinstall::SigningPubKeyring') or None, 87 'secring': cnf.get('Dinstall::SigningKeyring') or None, 88 'homedir': cnf.get('Dinstall::SigningHomedir') or None, 89 'passphrase_file': cnf.get('Dinstall::SigningPassphraseFile') or None, 90 } 91 sign_external_signature_requests(session, config['Export'], config.value_list('ExportSigningKeys'), args) 92 93 session.close() 94 95 Logger.close()
96 97 ####################################################################################### 98 99 100 if __name__ == '__main__': 101 main() 102