1#! /usr/bin/env python3
3"""Manage external signature requests
5@contact: Debian FTPMaster <ftpmaster@debian.org>
6@copyright: 2018, Ansgar Burchardt <ansgar@debian.org>
8"""
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.
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.
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
24################################################################################
26import apt_pkg
27import sys
29from daklib import daklog
30from daklib.dbconn import *
31from daklib.config import Config
32from daklib.externalsignature import *
34################################################################################
36Options = None
37Logger = None
39################################################################################
42def usage(exit_code=0):
43 print("""Usage: dak manage-external-signature-requests [OPTIONS]
44Manage external signature requests such as requests to sign EFI binaries or
45kernel modules.
47 -h, --help show this help and exit""")
49 sys.exit(exit_code)
51################################################################################
54def main():
55 global Options, Logger
57 cnf = Config()
59 for i in ["Help"]:
60 key = "Manage-External-Signature-Requests::Options::{}".format(i)
61 if key not in cnf: 61 ↛ 59line 61 didn't jump to line 59, because the condition on line 61 was never false
62 cnf[key] = ""
64 Arguments = [('h', "help", "Manage-External-Signature-Requests::Options::Help")]
66 apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
67 Options = cnf.subtree("Manage-External-Signature-Requests::Options")
69 if Options["Help"]:
70 usage()
72 Logger = daklog.Logger('manage-external-signature-requests')
74 if 'External-Signature-Requests' not in cnf: 74 ↛ 75line 74 didn't jump to line 75, because the condition on line 74 was never true
75 print("DAK not configured to handle external signature requests")
76 return
78 config = cnf.subtree('External-Signature-Requests')
80 session = DBConn().session()
82 export_external_signature_requests(session, config['Export'])
84 if 'ExportSigningKeys' in config: 84 ↛ 85line 84 didn't jump to line 85
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)
93 session.close()
95 Logger.close()
97#######################################################################################
100if __name__ == '__main__':
101 main()