[system-tools-backends-clone] Ignore invalid users from /etc/passwd



commit a66e3d065a3e7ea3f0a395f644bd5327092db68a
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Wed Mar 3 14:15:06 2010 +0100

    Ignore invalid users from /etc/passwd
    
    Returning users with no login or UID would lead to bugs and even crashes in the clients, since we rely on the login to identify users. Better detect it from the start.

 Users/Users.pm |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/Users/Users.pm b/Users/Users.pm
index 8f81d67..04a9637 100644
--- a/Users/Users.pm
+++ b/Users/Users.pm
@@ -264,6 +264,7 @@ my $logindefs_dist_map = {
   'users_read_profiledb_fail'    => ['warn', 'Profiles read failed.'],
   'users_read_users_success'     => ['info', 'Users read successfully.'],
   'users_read_users_fail'        => ['warn', 'Users read failed.'],
+  'users_read_users_invalid'     => ['warn', 'Invalid user found while reading (missing fields).'],
   'users_read_groups_success'    => ['info', 'Groups read successfully.'],
   'users_read_groups_fail'       => ['warn', 'Groups read failed.'],
   'users_read_shells_success'    => ['info', 'Shells read successfully.'],
@@ -361,6 +362,14 @@ sub get
 
     @line  = split ':', $_, -1;
     $login = $line[$LOGIN];
+
+    # skip invalid users, else they will create troubles
+    if (($line[$LOGIN] eq "") || ($line[$UID] eq ""))
+    {
+      &Utils::Report::do_report ("users_read_users_invalid");
+      next;
+    }
+
     @comment = split ',', $line[$COMMENT], 5;
 
     # we need to make sure that there are 5 elements



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]