summaryrefslogtreecommitdiff
path: root/x11-misc/sddm/files/sddm-0.14.0-nsswitch_conf.patch
blob: 371df93e2b8dc523072441f8b5240679f1f6e5c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
From 1f39c7a91ea4bc9527628adb01cb49173f1e68be Mon Sep 17 00:00:00 2001
From: Palo Kisa <palo.kisa@gmail.com>
Date: Fri, 9 Jun 2017 10:13:01 +0200
Subject: [PATCH] UserModel: Check for duplicates from getpwent()

---
 src/greeter/UserModel.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/greeter/UserModel.cpp b/src/greeter/UserModel.cpp
index 94c492d0..33114d08 100644
--- a/src/greeter/UserModel.cpp
+++ b/src/greeter/UserModel.cpp
@@ -72,6 +72,13 @@ namespace SDDM {
             if (mainConfig.Users.HideShells.get().contains(QString::fromLocal8Bit(current_pw->pw_shell)))
                 continue;
 
+            // skip duplicates
+            // Note: getpwent() makes no attempt to suppress duplicate information
+            // if multiple sources are specified in nsswitch.conf(5).
+            if (d->users.cend()
+                != std::find_if(d->users.cbegin(), d->users.cend(), [current_pw](const UserPtr & u) { return u->uid == current_pw->pw_uid; }))
+                continue;
+
             // create user
             UserPtr user { new User() };
             user->name = QString::fromLocal8Bit(current_pw->pw_name);