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 sys 
 27   
 28  import apt_pkg 
 29   
 30  from daklib import daklog 
 31  from daklib.config import Config 
 32  from daklib.dbconn import DBConn 
 33  from daklib.externalsignature import ( 
 34      export_external_signature_requests, 
 35      sign_external_signature_requests, 
 36  ) 
 37   
 38  ################################################################################ 
 39   
 40  Options = None 
 41  Logger = None 
 42   
 43  ################################################################################ 
 44   
 45   
46 -def usage(exit_code=0):
47 print( 48 """Usage: dak manage-external-signature-requests [OPTIONS] 49 Manage external signature requests such as requests to sign EFI binaries or 50 kernel modules. 51 52 -h, --help show this help and exit""" 53 ) 54 55 sys.exit(exit_code)
56 57 58 ################################################################################ 59 60
61 -def main():
62 global Options, Logger 63 64 cnf = Config() 65 66 for i in ["Help"]: 67 key = "Manage-External-Signature-Requests::Options::{}".format(i) 68 if key not in cnf: 69 cnf[key] = "" 70 71 Arguments = [("h", "help", "Manage-External-Signature-Requests::Options::Help")] 72 73 apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) 74 Options = cnf.subtree("Manage-External-Signature-Requests::Options") 75 76 if Options["Help"]: 77 usage() 78 79 Logger = daklog.Logger("manage-external-signature-requests") 80 81 if "External-Signature-Requests" not in cnf: 82 print("DAK not configured to handle external signature requests") 83 return 84 85 config = cnf.subtree("External-Signature-Requests") 86 87 session = DBConn().session() 88 89 export_external_signature_requests(session, config["Export"]) 90 91 if "ExportSigningKeys" in config: 92 args = { 93 "pubring": cnf.get("Dinstall::SigningPubKeyring") or None, 94 "secring": cnf.get("Dinstall::SigningKeyring") or None, 95 "homedir": cnf.get("Dinstall::SigningHomedir") or None, 96 "passphrase_file": cnf.get("Dinstall::SigningPassphraseFile") or None, 97 } 98 sign_external_signature_requests( 99 session, config["Export"], config.value_list("ExportSigningKeys"), args 100 ) 101 102 session.close() 103 104 Logger.close()
105 106 107 ####################################################################################### 108 109 110 if __name__ == "__main__": 111 main() 112