]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
Avoid KeyError when uid > max_uid_logged_in
authorTollef Fog Heen <tfheen@err.no>
Sun, 11 May 2014 17:10:01 +0000 (19:10 +0200)
committerTollef Fog Heen <tfheen@err.no>
Sun, 11 May 2014 17:10:01 +0000 (19:10 +0200)
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

index 98774fe8edcd8de6f666e438606b2d228f60e5fe..4211805532d91a25e06f4f6db404eb60edf06071 100755 (executable)
@@ -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(),