summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2012-05-08 08:22:03 +0200
committerByron Jones <bjones@mozilla.com>2012-05-08 08:22:03 +0200
commitc8f114b57e4ecd998ba367d761c5b28670cd68b5 (patch)
treeaae34021c1eb515746a985f58a44f126136e9c8f
parent3fb6876e63df886778f1ff6144866e180cd88107 (diff)
downloadbugzilla-c8f114b57e4ecd998ba367d761c5b28670cd68b5.tar.gz
bugzilla-c8f114b57e4ecd998ba367d761c5b28670cd68b5.tar.xz
Bug 729001: reverse resolve the ip address in account lockout notifications
-rw-r--r--Bugzilla/Auth.pm9
-rw-r--r--template/en/default/email/lockout.txt.tmpl4
2 files changed, 11 insertions, 2 deletions
diff --git a/Bugzilla/Auth.pm b/Bugzilla/Auth.pm
index 45034e166..ab741965a 100644
--- a/Bugzilla/Auth.pm
+++ b/Bugzilla/Auth.pm
@@ -38,6 +38,7 @@ use Bugzilla::User::Setting ();
use Bugzilla::Auth::Login::Stack;
use Bugzilla::Auth::Verify::Stack;
use Bugzilla::Auth::Persist::Cookie;
+use Socket;
sub new {
my ($class, $params) = @_;
@@ -215,10 +216,18 @@ sub _handle_login_result {
my $default_settings = Bugzilla::User::Setting::get_defaults();
my $template = Bugzilla->template_inner(
$default_settings->{lang}->{default_value});
+ my $address = $attempts->[0]->{ip_addr};
+ # Note: inet_aton will only resolve IPv4 addresses.
+ # For IPv6 we'll need to use inet_pton which requires Perl 5.12.
+ my $n = inet_aton($address);
+ if ($n) {
+ $address = gethostbyaddr($n, AF_INET) . " ($address)"
+ }
my $vars = {
locked_user => $user,
attempts => $attempts,
unlock_at => $unlock_at,
+ address => $address,
};
my $message;
$template->process('email/lockout.txt.tmpl', $vars, \$message)
diff --git a/template/en/default/email/lockout.txt.tmpl b/template/en/default/email/lockout.txt.tmpl
index ac6525779..94e9c74cb 100644
--- a/template/en/default/email/lockout.txt.tmpl
+++ b/template/en/default/email/lockout.txt.tmpl
@@ -22,10 +22,10 @@
From: [% Param('mailfrom') %]
To: [% Param('maintainer') %]
-Subject: [[% terms.Bugzilla %]] Account Lock-Out: [% locked_user.login %] ([% attempts.0.ip_addr %])
+Subject: [[% terms.Bugzilla %]] Account Lock-Out: [% locked_user.login %] ([% address %])
X-Bugzilla-Type: admin
-The IP address [% attempts.0.ip_addr %] failed too many login attempts (
+The address [% address %] failed too many login attempts (
[%- constants.MAX_LOGIN_ATTEMPTS +%]) for
the account [% locked_user.login %].