Skip Menu |

This queue is for tickets about the Net-FTPServer CPAN distribution.

Report information
The Basics
Id: 29529
Status: stalled
Priority: 0/
Queue: Net-FTPServer

People
Owner: Nobody in particular
Requestors: BRONG [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.122
Fixed in: (no value)



Subject: [PATCH] Provide a reason for authentication failure back to the user
Hi, I emailed this and one other patch to the maintainer a few days ago and have not heard a response, so I thought I would post the patches here as well. I've also added some documentation to this patch. #################################### # Give a reason when rejecting login This patch allows the authentication_hook to return a string which will be presented to the user describing why their login was rejected.
Subject: reason.diff
Index: Net/FTPServer.pm =================================================================== --- Net.orig/FTPServer.pm 2007-09-12 23:06:40.000000000 -0400 +++ Net/FTPServer.pm 2007-09-12 23:06:59.000000000 -0400 @@ -4684,7 +4684,7 @@ } # OK, now the real authentication check. - my $fail_code = + my ($fail_code, $fail_reason) = $self->authentication_hook ($self->{user}, $rest, $self->{user_is_anonymous}) ; @@ -4699,7 +4699,7 @@ if ($self->{loginattempts} >= ($self->config ("max login attempts") || 3)) { - $self->log ("notice", "repeated login attempts from %s:%d", + $self->log ("notice", "repeated login attempts from %s:%d/$self->{user}/$rest", $self->{peeraddrstring}, $self->{peerport}); @@ -4709,7 +4709,7 @@ exit 0; } - $self->reply (530, "Login failed."); + $self->reply (530, "Login failed. " . ($fail_reason || 'Authentication failed')); return; }
Sorry - I didn't attach the latest patch. Here it is.
Index: Net/FTPServer.pm =================================================================== --- Net.orig/FTPServer.pm 2007-09-12 23:06:40.000000000 -0400 +++ Net/FTPServer.pm 2007-09-21 00:02:26.000000000 -0400 @@ -4684,7 +4684,7 @@ } # OK, now the real authentication check. - my $fail_code = + my ($fail_code, $fail_reason) = $self->authentication_hook ($self->{user}, $rest, $self->{user_is_anonymous}) ; @@ -4699,7 +4699,7 @@ if ($self->{loginattempts} >= ($self->config ("max login attempts") || 3)) { - $self->log ("notice", "repeated login attempts from %s:%d", + $self->log ("notice", "repeated login attempts from %s:%d/$self->{user}/$rest", $self->{peeraddrstring}, $self->{peerport}); @@ -4709,7 +4709,7 @@ exit 0; } - $self->reply (530, "Login failed."); + $self->reply (530, "Login failed. " . ($fail_reason || 'Authentication failed')); return; } @@ -8089,6 +8089,15 @@ succeeds, this should return 0 (or any positive integer E<gt>= 0). If the authentication fails, this should return -1. +If you return a list containing -1 and a string then it will be +returned to the user, for example: + + return(-1, "A maximum of three concurrent logins are permitted per user."); + +The user's client sees: + + 530 Login failed. A maximum of three concurrent logins are permitted per user. + Status: required. =cut