logind: avoid shadow lookups when doing userdb client side
authorLennart Poettering <lennart@poettering.net>
Thu, 9 Apr 2020 12:28:56 +0000 (14:28 +0200)
committerMichael Biebl <biebl@debian.org>
Mon, 27 Jul 2020 21:24:47 +0000 (22:24 +0100)
Let's not trigger MACs needlessly.

Ideally everybody would turn on userdb, but if people insist in not
doing so, then let's not attempt to open shadow.

It's a bit ugly to implement this, since shadow information is more than
just passwords (but accound validity metadata), and thus userdb's own
"privieleged" scheme is orthogonal to this, but let's still do this for
the client side.

Fixes: #15105
(cherry picked from commit b062ca616c778358d4da008a2950615fac74aa24)

Gbp-Pq: Name logind-avoid-shadow-lookups-when-doing-userdb-client-side.patch

src/login/logind-core.c

index 22a42b077c0d6ff7a12f531382e1fa0c0f1b9401..a9006d746a0df4615d7ac232ef383852abab844c 100644 (file)
@@ -171,7 +171,7 @@ int manager_add_user_by_name(
         assert(m);
         assert(name);
 
-        r = userdb_by_name(name, 0, &ur);
+        r = userdb_by_name(name, USERDB_AVOID_SHADOW, &ur);
         if (r < 0)
                 return r;
 
@@ -189,7 +189,7 @@ int manager_add_user_by_uid(
         assert(m);
         assert(uid_is_valid(uid));
 
-        r = userdb_by_uid(uid, 0, &ur);
+        r = userdb_by_uid(uid, USERDB_AVOID_SHADOW, &ur);
         if (r < 0)
                 return r;