Author: adam-guest
Date: 2008-03-30 18:27:41 +0000 (Sun, 30 Mar 2008)
New Revision: 1225
Modified:
trunk/README
trunk/conf.default.in
trunk/debian/changelog
trunk/debian/control
trunk/debian/postinst
trunk/scripts/bts.pl
Log:
* bts: Allow SMTP authentication to be used when sending e-mails
* README, debian/control: Add libsasl-authen-perl to Suggests and the
description of bts, to support SMTP authentication
Modified: trunk/README
===================================================================
--- trunk/README 2008-03-30 16:22:17 UTC (rev 1224)
+++ trunk/README 2008-03-30 18:27:41 UTC (rev 1225)
@@ -23,10 +23,10 @@
- archpath: Prints arch (tla/Bazaar) package names. Also supports
calculating the package names for other branches.
-- bts [www-browser, libsoap-lite-perl, libwww-perl, mailx | mailutils]:
- A command-line tool for accessing the BTS, both to send mails to
- [EMAIL PROTECTED] and to access the web pages and SOAP interface
- of the BTS.
+- bts [www-browser, libauthen-sasl-perl, libsoap-lite-perl, libwww-perl,
+ mailx | mailutils]: A command-line tool for accessing the BTS, both to
+ send mails to [EMAIL PROTECTED] and to access the web pages and
+ SOAP interface of the BTS.
- build-rdeps [dctrl-tools]:
Searches for all packages that build-depend on a given package.
Modified: trunk/conf.default.in
===================================================================
--- trunk/conf.default.in 2008-03-30 16:22:17 UTC (rev 1224)
+++ trunk/conf.default.in 2008-03-30 18:27:41 UTC (rev 1225)
@@ -84,6 +84,13 @@
# host will be used unless overridden by --sendmail on the command line
# BTS_SMTP_HOST=bugs.debian.org
#
+# If the SMTP host specified above requires authentication, the following
+# options may be used to specify the username and password to use.
+# If only a username is provided then the password will be prompted for
+# before sending the e-mail
+# BTS_SMTP_AUTH_USERNAME=user
+# BTS_SMTP_AUTH_PASSWORD=pass
+#
# Include resolved bugs when caching?
# BTS_INCLUDE_RESOLVED=yes
#
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-03-30 16:22:17 UTC (rev 1224)
+++ trunk/debian/changelog 2008-03-30 18:27:41 UTC (rev 1225)
@@ -1,5 +1,6 @@
devscripts (2.10.21) UNRELEASED; urgency=low
+ * bts: Allow SMTP authentication to be used when sending e-mails
* bug/script: Don't produce an error if either of the configuration files
doesn't exist (Closes: #472748)
* checkbashisms:
@@ -30,6 +31,8 @@
* tagpending: Allow the mail sent to the BTS to be displayed and (assuming
--noact is not in effect) confirmed before sending
* who-uploads: Mention the debian-maintainers keyring in --help
+ * README, debian/control: Add libsasl-authen-perl to Suggests and the
+ description of bts, to support SMTP authentication
-- Adam D. Barratt <[EMAIL PROTECTED]> Tue, 25 Mar 2008 18:51:59 +0000
Modified: trunk/debian/control
===================================================================
--- trunk/debian/control 2008-03-30 16:22:17 UTC (rev 1224)
+++ trunk/debian/control 2008-03-30 18:27:41 UTC (rev 1225)
@@ -21,10 +21,10 @@
Suggests: devscripts-el, at, build-essential, curl | wget, cvs-buildpackage,
cvs | subversion | svk | tla | bzr | git-core | mercurial, dctrl-tools,
debian-keyring, debian-maintainers, dupload (>=2.1) | dput,
- gnupg (>= 1.0.7), gnuplot, libcrypt-ssleay-perl, libdigest-md5-perl,
- libfile-desktopentry-perl, libsoap-lite-perl, libterm-size-perl,
- libtimedate-perl, liburi-perl, libwww-perl, lintian, lsb-release,
- mailx | mailutils, man-db, mutt, patch, patchutils, ssh, strace,
+ gnupg (>= 1.0.7), gnuplot, libauthen-sasl-perl, libcrypt-ssleay-perl,
+ libdigest-md5-perl, libfile-desktopentry-perl, libsoap-lite-perl,
+ libterm-size-perl, libtimedate-perl, liburi-perl, libwww-perl, lintian,
+ lsb-release, mailx | mailutils, man-db, mutt, patch, patchutils, ssh, strace,
unzip, wdiff, www-browser
Description: scripts to make the life of a Debian Package maintainer easier
Contains the following scripts, dependencies/recommendations shown in
@@ -34,7 +34,7 @@
E for stderr) for every line of output
- archpath: print tla/Bazaar package names [tla | bazaar]
- bts: a command-line tool for manipulating the BTS [www-browser,
- libsoap-lite-perl, libwww-perl, mailx | mailutils]
+ libauthen-sasl-perl, libsoap-lite-perl, libwww-perl, mailx | mailutils]
- build-rdeps: Searches for all packages that build-depend on a
given package [dctrl-tools]
- chdist: tool to easily play with several distributions [dctrl-tools]
Modified: trunk/debian/postinst
===================================================================
--- trunk/debian/postinst 2008-03-30 16:22:17 UTC (rev 1224)
+++ trunk/debian/postinst 2008-03-30 18:27:41 UTC (rev 1225)
@@ -460,6 +460,22 @@
EOF
fi
+
+ if dpkg --compare-versions "$2" lt 2.10.21
+ then
+ # Added in devscripts 2.10.21
+ cat >> /etc/devscripts.conf <<EOF
+##### bts options added in version 2.10.21
+#
+# If the SMTP host specified above requires authentication, the following
+# options may be used to specify the username and password to use.
+# If only a username is provided then the password will be prompted for
+# before sending the e-mail
+# BTS_SMTP_AUTH_USERNAME=user
+# BTS_SMTP_AUTH_PASSWORD=pass
+
+EOF
+ fi
fi
fi
Modified: trunk/scripts/bts.pl
===================================================================
--- trunk/scripts/bts.pl 2008-03-30 16:22:17 UTC (rev 1224)
+++ trunk/scripts/bts.pl 2008-03-30 18:27:41 UTC (rev 1225)
@@ -261,13 +261,22 @@
=item --smtp-host=SMTPHOST
-Specify an SMTP host. If given, bts will send mail by talking directly to
+Specify an SMTP host. If given, B<bts> will send mail by talking directly to
this SMTP host rather than by invoking a sendmail command.
Note that when sending directly via an SMTP host, specifying addresses in
--cc-addr that the SMTP host will not relay will cause the SMTP host to reject
the entire mail.
+=item --smtp-username=USERNAME, --smtp-password=PASSWORD
+
+Specify the credentials to use when connecting to the SMTP server
+specified by --smtp-host. If the server does not require authentication
+then these options should not be used.
+
+If a username is specified but not a password, B<bts> will prompt for
+the password before sending the mail.
+
=item -f, --force-refresh
Download a bug report again, even if it does not appear to have
@@ -344,6 +353,8 @@
my $mailreader='mutt -f %s';
my $sendmailcmd='/usr/sbin/sendmail';
my $smtphost='';
+my $smtpuser='';
+my $smtppass='';
my $noaction=0;
# regexp for mailers which require a -t option
my $sendmail_t='^/usr/sbin/sendmail$|^/usr/sbin/exim';
@@ -370,6 +381,8 @@
'BTS_SENDMAIL_COMMAND' => '/usr/sbin/sendmail',
'BTS_INCLUDE_RESOLVED' => 'yes',
'BTS_SMTP_HOST' => '',
+ 'BTS_SMTP_AUTH_USERNAME' => '',
+ 'BTS_SMTP_AUTH_PASSWORD' => '',
'BTS_SUPPRESS_ACKS' => 'no',
'BTS_INTERACTIVE' => 'no',
);
@@ -437,6 +450,8 @@
$mailreader = $config_vars{'BTS_MAIL_READER'};
$sendmailcmd = $config_vars{'BTS_SENDMAIL_COMMAND'};
$smtphost = $config_vars{'BTS_SMTP_HOST'};
+ $smtpuser = $config_vars{'BTS_AUTH_SMTP_USER'};
+ $smtppass = $config_vars{'BTS_AUTH_SMTP_PASS'};
$includeresolved = $config_vars{'BTS_INCLUDE_RESOLVED'} eq 'yes' ? 1 : 0;
$requestack = $config_vars{'BTS_SUPPRESS_ACKS'} eq 'no' ? 1 : 0;
$interactive = $config_vars{'BTS_INTERACTIVE'} eq 'no' ? 0 : 1;
@@ -449,6 +464,7 @@
my ($opt_help, $opt_version, $opt_noconf);
my ($opt_cachemode, $opt_mailreader, $opt_sendmail, $opt_smtphost);
+my ($opt_smtpuser, $opt_smtppass);
my $opt_cachedelay=5;
my $mboxmode = 0;
my $quiet=0;
@@ -469,6 +485,8 @@
"cc-addr=s" => \$ccemail,
"sendmail=s" => \$opt_sendmail,
"smtp-host|smtphost=s" => \$opt_smtphost,
+ "smtp-user|smtp-username=s" => \$opt_smtpuser,
+ "smtp-pass|smtp-password=s" => \$opt_smtppass,
"f" => \$refreshmode,
"force-refresh!" => \$refreshmode,
"only-new!" => \$updatemode,
@@ -502,6 +520,8 @@
}
$smtphost = $opt_smtphost if $opt_smtphost;
+$smtpuser = $opt_smtpuser if $opt_smtpuser;
+$smtppass = $opt_smtppass if $opt_smtppass;
if ($opt_sendmail) {
if ($opt_sendmail ne '/usr/sbin/sendmail'
@@ -1794,6 +1814,8 @@
--no-force-refresh Do not do so (default)
--sendmail=cmd Sendmail command to use (default /usr/sbin/sendmail)
--smtp-host=host SMTP host to use
+ --smtp-user=username Credentials to use when connecting to an SMTP
+ --smtp-pass=password server which requires authentication
--no-include-resolved Do not cache bugs marked as resolved
--include-resolved Cache bugs marked as resolved (default)
--no-ack Suppress BTS acknowledgment mails
@@ -1918,13 +1940,17 @@
return if not defined $body;
$message .= "$body\n";
-
if ($noaction) {
print "$message\n";
}
elsif (length $smtphost) {
my $smtp = Net::SMTP->new($smtphost)
or die "bts: failed to open SMTP connection to $smtphost\n";
+ if ($smtpuser) {
+ $smtppass = getpass() if not $smtppass;
+ $smtp->auth($smtpuser, $smtppass)
+ or die "bts: failed to authenticate to $smtphost\n";
+ }
$smtp->mail($fromaddress)
or die "bts: failed to set SMTP from address $fromaddress\n";
my @addresses = extract_addresses($to);
@@ -2089,6 +2115,20 @@
return $body;
}
+sub getpass() {
+ system "stty -echo cbreak </dev/tty";
+ die "bts: error disabling stty echo\n" if $?;
+ print "\a${smtpuser}";
+ print "[EMAIL PROTECTED]" if $smtpuser !~ /\@/;
+ print "'s SMTP password: ";
+ $_ = <STDIN>;
+ chomp;
+ print "\n";
+ system "stty echo -cbreak </dev/tty";
+ die "bts: error enabling stty echo\n" if $?;
+ return $_;
+}
+
# A simplified version of mailbtsall which sends one message only to
# a specified address using the specified email From: header
sub mailto {
@@ -3308,6 +3348,11 @@
Note that this option takes priority over BTS_SENDMAIL_COMMAND if both are
set, unless the --sendmail option is used.
+=item BTS_SMTP_AUTH_USERNAME, BTS_SMTP_AUTH_PASSWORD
+
+If these options are set, then it is the same as the --smtp-username and
+--smtp-password options being used.
+
=item BTS_INCLUDE_RESOLVED
If this is set to I<no>, then it is the same as the --no-include-resolved
--
To unsubscribe, send mail to [EMAIL PROTECTED]