From b17506ea41e3e1a28df2e1e5abfee6d81d6e48b7 Mon Sep 17 00:00:00 2001 From: Atanas Zhelev Date: Nov 09 2017 15:24:40 +0000 Subject: [PATCH 1/2] Add smtp authentication support --- diff --git a/builder/kojid b/builder/kojid index e5f7196..6375fad 100755 --- a/builder/kojid +++ b/builder/kojid @@ -4647,6 +4647,8 @@ Status: %(status)s\r message = koji.fixEncoding(message) server = smtplib.SMTP(self.options.smtphost) + if self.options.smtp_user is not None and self.options.smtp_pass is not None: + server.login(self.options.smtp_user, self.options.smtp_pass) #server.set_debuglevel(True) server.sendmail(from_addr, recipients, message) server.quit() @@ -4852,6 +4854,8 @@ Build Info: %(weburl)s/buildinfo?buildID=%(build_id)i\r message = koji.fixEncoding(message) server = smtplib.SMTP(self.options.smtphost) + if self.options.smtp_user is not None and self.options.smtp_pass is not None: + server.login(self.options.smtp_user, self.options.smtp_pass) # server.set_debuglevel(True) server.sendmail(from_addr, recipients, message) server.quit() @@ -5596,6 +5600,8 @@ def get_options(): 'distribution': 'Koji', 'mockhost': 'koji-linux-gnu', 'smtphost': 'example.com', + 'smtp_user': None, + 'smtp_pass': None, 'from_addr': 'Koji Build System ', 'krb_principal': None, 'host_principal_format': 'compile/%s@EXAMPLE.COM', diff --git a/builder/kojid.conf b/builder/kojid.conf index 3d2f3ce..1abde37 100644 --- a/builder/kojid.conf +++ b/builder/kojid.conf @@ -64,6 +64,10 @@ allowed_scms=scm.example.com:/cvs/example git.example.org:/example svn.example.o ; The mail host to use for sending email notifications smtphost=example.com +; SMTP user and pass (uncomment and fill in if your smtp server requires authentication) +;smtp_user=user@example.com +;smtp_pass=CHANGEME + ; The From address used when sending email notifications from_addr=Koji Build System From fe8afab5a1f932a60ba2be30600850187966bff0 Mon Sep 17 00:00:00 2001 From: Atanas Zhelev Date: Nov 13 2017 17:58:57 +0000 Subject: [PATCH 2/2] Add smtp authentication support to koji-gc --- diff --git a/util/koji-gc b/util/koji-gc index 9c20cdb..8519fc6 100755 --- a/util/koji-gc +++ b/util/koji-gc @@ -76,6 +76,10 @@ def get_options(): help=_("show xmlrpc debug output")) parser.add_option("--smtp-host", metavar="HOST", help=_("specify smtp server for notifications")) + parser.add_option("--smtp-user", dest="smtp_user", metavar="USER", + help=_("specify smtp username for notifications")) + parser.add_option("--smtp-pass", dest="smtp_pass", metavar="PASSWORD", + help=optparse.SUPPRESS_HELP) # do not allow passwords on a command line parser.add_option("--no-mail", action='store_false', default=True, dest="mail", help=_("don't send notifications")) parser.add_option("--send-mail", action='store_true', dest="mail", @@ -147,6 +151,8 @@ def get_options(): ['server', None, 'string'], ['weburl', None, 'string'], ['smtp_host', None, 'string'], + ['smtp_user', None, 'string'], + ['smtp_pass', None, 'string'], ['from_addr', None, 'string'], ['email_domain', None, 'string'], ['mail', None, 'boolean'], @@ -424,6 +430,8 @@ refer to the document linked above for instructions.""" print("Sending warning notice to %s" % msg['To']) try: s = smtplib.SMTP(options.smtp_host) + if options.smtp_user is not None and options.smtp_pass is not None: + s.login(options.smtp_user, options.smtp_pass) s.sendmail(msg['From'], msg['To'], msg.as_string()) s.quit() except: diff --git a/util/koji-gc.conf b/util/koji-gc.conf index dea8880..59361f2 100644 --- a/util/koji-gc.conf +++ b/util/koji-gc.conf @@ -23,6 +23,10 @@ weburl = https://koji.fedoraproject.org/koji # when creating email notifications #email_domain = fedoraproject.org +# SMTP user and pass (uncomment and fill in if your smtp server requires authentication) +#smtp_user=user@example.com +#smtp_pass=CHANGEME + [prune] policy = #stuff to protect