[Mageia-sysadm] [163] - do not let users take a username that is used by the system ( will be

root at mageia.org root at mageia.org
Mon Dec 6 02:15:53 CET 2010


Revision: 163
Author:   misc
Date:     2010-12-06 02:15:53 +0100 (Mon, 06 Dec 2010)
Log Message:
-----------
- 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 )

Modified Paths:
--------------
    identity/CatDap/trunk/lib/CatDap/Controller/register.pm

Modified: identity/CatDap/trunk/lib/CatDap/Controller/register.pm
===================================================================
--- identity/CatDap/trunk/lib/CatDap/Controller/register.pm	2010-11-27 19:49:21 UTC (rev 162)
+++ identity/CatDap/trunk/lib/CatDap/Controller/register.pm	2010-12-06 01:15:53 UTC (rev 163)
@@ -51,6 +51,16 @@
     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'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/mageia-sysadm/attachments/20101206/041b3b51/attachment.html>


More information about the Mageia-sysadm mailing list