diff options
author | Ray Strode <rstrode@redhat.com> | 2018-04-25 11:16:36 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2018-04-25 11:20:29 -0400 |
commit | 081a2b74712233f2515920a85315e6e0d4e73960 (patch) | |
tree | 9837bb86e8cbb95a8968c9e57791aace67d45e79 /src | |
parent | 883b9101ec21e4b7ad0522c9dcc1a87465a750cd (diff) |
wtmp-helper: don't call getpwnam()
The wtmp helper code examines /var/log/wtmp to determine which
users log in the most frequently.
That code calls getpwnam() once for every entry in /var/log/wtmp.
This is very inefficient, since getpwnam() can be quite slow, and
/var/log/wtmp will often have the same users repeated over and
over again.
Also, we don't actually use the result for anything other than verifying
the existence of the user! And we already verify the existence of
the user later later in the code in a more efficient way (by finding
the user in the users hashtable).
This commit just drops the unnecessary getpwnam() call.
https://bugs.freedesktop.org/show_bug.cgi?id=106240
Diffstat (limited to 'src')
-rw-r--r-- | src/wtmp-helper.c | 6 |
1 files changed, 0 insertions, 6 deletions
diff --git a/src/wtmp-helper.c b/src/wtmp-helper.c index a1edffe..01caa2e 100644 --- a/src/wtmp-helper.c +++ b/src/wtmp-helper.c @@ -75,7 +75,6 @@ wtmp_helper_update_login_frequencies (GHashTable *users) struct utmpx *wtmp_entry; GHashTableIter iter; gpointer key, value; - struct passwd *pwent; User *user; GVariantBuilder *builder, *builder2; GList *l; @@ -128,11 +127,6 @@ wtmp_helper_update_login_frequencies (GHashTable *users) continue; } - pwent = getpwnam (wtmp_entry->ut_user); - if (pwent == NULL) { - continue; - } - if (!g_hash_table_lookup_extended (login_hash, wtmp_entry->ut_user, &key, &value)) { |