diff options
author | Mike Crute <mike@crute.us> | 2017-11-29 17:55:03 +0000 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2017-11-29 18:03:35 +0000 |
commit | 7e807f7d8c347b35d145cb6b98827489b7afaa19 (patch) | |
tree | a8aa4d25fcdaf9489d5ac3311e7fea4a43be1d85 /bugzilla | |
parent | 41fe37ee1eda082f1ab247b25e09b1f0c300040c (diff) | |
download | dockerfiles-7e807f7d8c347b35d145cb6b98827489b7afaa19.tar.bz2 dockerfiles-7e807f7d8c347b35d145cb6b98827489b7afaa19.tar.xz dockerfiles-7e807f7d8c347b35d145cb6b98827489b7afaa19.zip |
Move scripts around
Diffstat (limited to 'bugzilla')
-rw-r--r-- | bugzilla/Dockerfile | 5 | ||||
-rwxr-xr-x | bugzilla/usr/bin/bugzilla_fetch.py (renamed from bugzilla/bin/bugzilla_fetch.py) | 0 | ||||
-rwxr-xr-x | bugzilla/usr/bin/dumb-init (renamed from bugzilla/bin/dumb-init) | bin | 857208 -> 857208 bytes | |||
-rwxr-xr-x | bugzilla/usr/bin/su-exec (renamed from bugzilla/bin/su-exec) | bin | 15752 -> 15752 bytes | |||
-rwxr-xr-x | bugzilla/usr/sbin/sendmail | 108 |
5 files changed, 109 insertions, 4 deletions
diff --git a/bugzilla/Dockerfile b/bugzilla/Dockerfile index 065c3f2..1a4850c 100644 --- a/bugzilla/Dockerfile +++ b/bugzilla/Dockerfile | |||
@@ -136,11 +136,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ | |||
136 | rm -rf /var/lib/apt/lists/* && \ | 136 | rm -rf /var/lib/apt/lists/* && \ |
137 | rm -rf /tmp/* | 137 | rm -rf /tmp/* |
138 | 138 | ||
139 | ADD bin/ /usr/bin/ | 139 | ADD usr/ /usr/ |
140 | ADD sbin/ /usr/sbin/ | ||
141 | ADD etc/ /etc/ | 140 | ADD etc/ /etc/ |
142 | 141 | ||
143 | EXPOSE 80 | ||
144 | VOLUME "/srv/bugzilla" | ||
145 | STOPSIGNAL SIGHUP | 142 | STOPSIGNAL SIGHUP |
146 | CMD [ "/usr/bin/dumb-init", "/usr/bin/runsvdir", "/etc/service" ] | 143 | CMD [ "/usr/bin/dumb-init", "/usr/bin/runsvdir", "/etc/service" ] |
diff --git a/bugzilla/bin/bugzilla_fetch.py b/bugzilla/usr/bin/bugzilla_fetch.py index b4a9805..b4a9805 100755 --- a/bugzilla/bin/bugzilla_fetch.py +++ b/bugzilla/usr/bin/bugzilla_fetch.py | |||
diff --git a/bugzilla/bin/dumb-init b/bugzilla/usr/bin/dumb-init index 4a41698..4a41698 100755 --- a/bugzilla/bin/dumb-init +++ b/bugzilla/usr/bin/dumb-init | |||
Binary files differ | |||
diff --git a/bugzilla/bin/su-exec b/bugzilla/usr/bin/su-exec index 940f452..940f452 100755 --- a/bugzilla/bin/su-exec +++ b/bugzilla/usr/bin/su-exec | |||
Binary files differ | |||
diff --git a/bugzilla/usr/sbin/sendmail b/bugzilla/usr/sbin/sendmail new file mode 100755 index 0000000..69e5816 --- /dev/null +++ b/bugzilla/usr/sbin/sendmail | |||
@@ -0,0 +1,108 @@ | |||
1 | #!/usr/bin/python | ||
2 | |||
3 | import os | ||
4 | import re | ||
5 | import sys | ||
6 | import email | ||
7 | import boto3 | ||
8 | import socket | ||
9 | import argparse | ||
10 | from botocore.exceptions import NoRegionError | ||
11 | |||
12 | # These are all the sendmail options we don't support but have to accept so we | ||
13 | # can ignore them without messing up the command line. | ||
14 | # | ||
15 | # Format is (argument, takes parameters) | ||
16 | IGNORED = ( | ||
17 | ("-4", False), ("-6", False), ("-au", True), ("-ap", True), | ||
18 | ("-am", True), ("-ba", False), ("-bd", False), ("-bi", False), | ||
19 | ("-bm", False), ("-bp", False), ("-bs", False), ("-bt", False), | ||
20 | ("-bv", False), ("-bz", False), ("-C", True), ("-d", True), | ||
21 | ("-E", False), ("-h", True), ("-m", False), ("-M", True), | ||
22 | ("-N", True), ("-n", False), ("-oA", True), ("-oc", False), | ||
23 | ("-od", True), ("-oD", False), ("-oe", False), ("-oF", True), | ||
24 | ("-of", False), ("-og", True), ("-oH", True), ("-oi", False), | ||
25 | ("-oL", True), ("-om", False), ("-oo", False), ("-oQ", True), | ||
26 | ("-or", True), ("-oS", True), ("-os", False), ("-oT", True), | ||
27 | ("-ot", False), ("-ou", True), ("-q", True), ("-R", True), | ||
28 | ("-v", False), ("-F", True), ("-t", True), | ||
29 | ) | ||
30 | |||
31 | # A rough approximation of an email address but should be good enough to pick | ||
32 | # emails out of a command line | ||
33 | SORTA_EMAIL = re.compile("\S+@\S+\.\S+") | ||
34 | |||
35 | if os.path.exists("/etc/mailname"): | ||
36 | with open("/etc/mailname", "r") as fp: | ||
37 | MAIL_DOMAIN = fp.read().strip() | ||
38 | else: | ||
39 | MAIL_DOMAIN = socket.getfqdn() | ||
40 | |||
41 | # Configuration comes from the environment or metadata service | ||
42 | try: | ||
43 | client = boto3.client("ses") | ||
44 | except NoRegionError: | ||
45 | # TODO: Handle this better | ||
46 | boto3.setup_default_session( | ||
47 | aws_access_key_id="AKIAJSJZAZDLGRZVT6ZQ", | ||
48 | aws_secret_access_key="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", | ||
49 | region_name="us-west-2") | ||
50 | client = boto3.client("ses") | ||
51 | |||
52 | |||
53 | |||
54 | def parse_args(): | ||
55 | parser = argparse.ArgumentParser(add_help=False) | ||
56 | parser.add_argument("-V", action="store_true", dest="display_version") | ||
57 | parser.add_argument("-f", nargs=1, dest="sender_addr") | ||
58 | parser.add_argument("-r", nargs=1, dest="sender_addr") | ||
59 | |||
60 | for arg, nargs in IGNORED: | ||
61 | parser.add_argument(arg, nargs="?" if nargs else None) | ||
62 | |||
63 | opts, args = parser.parse_known_args() | ||
64 | addresses = [a for a in args if SORTA_EMAIL.match(a)] | ||
65 | |||
66 | return opts, addresses | ||
67 | |||
68 | |||
69 | def main(): | ||
70 | opts, addresses = parse_args() | ||
71 | |||
72 | if opts.display_version: | ||
73 | print("SES raw mail sender (definitely not sendmail)") | ||
74 | sys.exit(0) | ||
75 | |||
76 | try: | ||
77 | sender = opts.sender_addr[0] | ||
78 | except (IndexError, TypeError): | ||
79 | sender = None | ||
80 | |||
81 | msg = email.message_from_string(sys.stdin.read().encode("us-ascii")) | ||
82 | |||
83 | # Fix up cron emails | ||
84 | if 'Cron Daemon' in msg.get("From"): | ||
85 | msg.replace_header("From", "cron-no-reply@{}".format(MAIL_DOMAIN)) | ||
86 | |||
87 | ses_args = {"RawMessage": {"Data": msg.as_string()}} | ||
88 | |||
89 | if sender and not SORTA_EMAIL.match(sender): | ||
90 | raise Exception("Sender email does not look like an email") | ||
91 | |||
92 | if sender: | ||
93 | ses_args["Source"] = sender | ||
94 | |||
95 | if addresses: | ||
96 | ses_args["Destinations"] = addresses | ||
97 | |||
98 | client.send_raw_email(**ses_args) | ||
99 | |||
100 | |||
101 | if __name__ == "__main__": | ||
102 | try: | ||
103 | main() | ||
104 | sys.exit(0) | ||
105 | except Exception as e: | ||
106 | print("Error during sending:") | ||
107 | print(e) | ||
108 | sys.exit(1) | ||