From 0cb683bf2732d37d2c67a6f2e120e4fa08dbad9b Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 6 Dec 2010 01:15:53 +0000 Subject: - do not let users take a username that is used by the system ( will be completed with a 2nd configurable check, this one is just to take care of default users from the system ) --- lib/CatDap/Controller/register.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/CatDap/Controller/register.pm b/lib/CatDap/Controller/register.pm index c90032d..ed3075b 100644 --- a/lib/CatDap/Controller/register.pm +++ b/lib/CatDap/Controller/register.pm @@ -51,6 +51,16 @@ sub check : Local { if (! $c->validate_captcha($c->req->param('validate'))){ push @errors, $c->loc('Incorrect validation text, please try again'); } + + if ( ! open( my $etcpasswd, "/etc/passwd")) { + push @errors, $c->loc('Cannot check /etc/passwd, please warn system administrators'); + } else { + if ( grep { /^$username:/ } <$etcpasswd> ) { + push @errors, $c->loc('Invalid username, already used by system'); + } + close($etcpasswd); + } + if ($c->request->params->{gn} !~ /^\p{IsAlnum}+$/) { push @errors, $c->loc( 'The first name supplied contains illegal characters' -- cgit v1.2.1