summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Bouchet-Valat <nalimilan@club.fr>2010-03-03 14:15:06 +0100
committerMilan Bouchet-Valat <nalimilan@club.fr>2010-03-08 23:29:22 +0100
commita66e3d065a3e7ea3f0a395f644bd5327092db68a (patch)
tree1905be01a9926be45867c35ec9ed44747a991aac
parent10cfe0d4dc59514bf021faadc1002e4f1f13440a (diff)
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.
-rw-r--r--Users/Users.pm9
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