From: Tollef Fog Heen Date: Sun, 11 May 2014 17:10:01 +0000 (+0200) Subject: Avoid KeyError when uid > max_uid_logged_in X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=5dcca55f481da5b65e989a2d5712325bd32fe736;p=mirror%2Fdsa-puppet.git 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. --- 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(),