Home | Trees | Indices | Help |
---|
|
1 #!/usr/bin/env python 2 3 # This software is provided 'as-is', without any express or implied 4 # warranty. In no event will the author be held liable for any damages 5 # arising from the use of this software. 6 # 7 # Permission is granted to anyone to use this software for any purpose, 8 # including commercial applications, and to alter it and redistribute it 9 # freely, subject to the following restrictions: 10 # 11 # 1. The origin of this software must not be misrepresented; you must not 12 # claim that you wrote the original software. If you use this software 13 # in a product, an acknowledgment in the product documentation would be 14 # appreciated but is not required. 15 # 2. Altered source versions must be plainly marked as such, and must not be 16 # misrepresented as being the original software. 17 # 3. This notice may not be removed or altered from any source distribution. 18 # 19 # Copyright (c) 2008 Greg Hewgill http://hewgill.com 20 # 21 # This has been modified from the original software. 22 # Copyright (c) 2011 William Grant <me@williamgrant.id.au> 23 # 24 # This has been modified from the original software. 25 # Copyright (c) 2016 Google, Inc. 26 # Contact: Brandon Long <blong@google.com> 27 # This has been modified from the original software. 28 # Copyright (c) 2017, 2018, 2019 Scott Kitterman <scott@kitterman.com> 29 # 30 # This has been modified from the original software. 31 # Copyright (c) 2017 Valimail Inc 32 # Contact: Gene Shuman <gene@valimail.com> 33 34 35 from __future__ import print_function 36 37 import logging 38 import re 39 import sys 40 41 import dkim 42 43 logging.basicConfig(level=10) 44 4547 if len(sys.argv) != 5: 48 print("Usage: arcsign.py selector domain privatekeyfile srv_id", file=sys.stderr) 49 sys.exit(1) 50 51 if sys.version_info[0] >= 3: 52 # Make sys.stdin and stdout binary streams. 53 sys.stdin = sys.stdin.detach() 54 sys.stdout = sys.stdout.detach() 55 56 selector = sys.argv[1].encode('ascii') 57 domain = sys.argv[2].encode('ascii') 58 privatekeyfile = sys.argv[3] 59 srv_id = sys.argv[4].encode('ascii') 60 61 message = sys.stdin.read() 62 63 # Pick a cv status 64 cv = dkim.CV_None 65 if re.search(b'arc-seal', message, re.IGNORECASE): 66 cv = dkim.CV_Pass 67 68 #try: 69 sig = dkim.arc_sign(message, selector, domain, open(privatekeyfile, "rb").read(), 70 srv_id, cv, linesep=dkim.util.get_linesep(message)) 71 for line in sig: 72 sys.stdout.write(line) 73 sys.stdout.write(message)74 #except Exception as e: 75 # print(e, file=sys.stderr) 76 #sys.stdout.write(message) 77 78 79 if __name__ == "__main__": 80 main() 81
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Dec 16 12:46:43 2019 | http://epydoc.sourceforge.net |