From 6ad3c9a761f11e674ec1506e9b65d854ffced7d5 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Tue, 8 May 2012 06:31:06 +0000 Subject: [PATCH] Bug 729001: Reverse resolves the IP address in account lockout notifications r=LpSolit, a=LpSolit git-svn-id: svn://10.0.0.236/trunk@263800 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/Bugzilla/Auth.pm | 9 +++++++++ .../bugzilla/template/en/default/email/lockout.txt.tmpl | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index 95355ef593e..e681fd998a3 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -8222 \ No newline at end of file +8223 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/Auth.pm b/mozilla/webtools/bugzilla/Bugzilla/Auth.pm index 93ee45b541b..477dbffaa83 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Auth.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Auth.pm @@ -22,6 +22,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) = @_; @@ -199,10 +200,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/mozilla/webtools/bugzilla/template/en/default/email/lockout.txt.tmpl b/mozilla/webtools/bugzilla/template/en/default/email/lockout.txt.tmpl index e30a4e94503..51153ea4537 100644 --- a/mozilla/webtools/bugzilla/template/en/default/email/lockout.txt.tmpl +++ b/mozilla/webtools/bugzilla/template/en/default/email/lockout.txt.tmpl @@ -8,10 +8,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 %].