From 5dcca55f481da5b65e989a2d5712325bd32fe736 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Sun, 11 May 2014 19:10:01 +0200 Subject: [PATCH] Avoid KeyError when uid > max_uid_logged_in We were getting KeyError for a given user who hasn't logged in a long time and whose uid is bigger than the max uid in lastlog. Avoid this by falling back to a value of 0 if the user is missing from lastlog. --- modules/porterbox/files/mail-big-homedirs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/porterbox/files/mail-big-homedirs b/modules/porterbox/files/mail-big-homedirs index 98774fe8e..421180553 100755 --- a/modules/porterbox/files/mail-big-homedirs +++ b/modules/porterbox/files/mail-big-homedirs @@ -225,7 +225,7 @@ class HomedirReminder(object): realname = pwd.getpwnam(username).pw_gecos.decode('utf-8').split(',', 1)[0] except: realname = username - lastlog_time = self.lastlog_times[username] + lastlog_time = self.lastlog_times.get(username, 0) days_ago = int( (current_time - lastlog_time) / 3600 / 24 ) kwargs = { 'hostname': platform.node(), -- 2.20.1