the rsync call in an flock wrapper that acquires a shared lock on
ud-generate's lock. This prevents syncing while ud-generate runs.
* ud-lock: support supplying a status to set instead of 'retiring'.
+ * ud-generate: Also rebuild if one of our keyrings has changed, even if
+ ldap has not.
[ Stephen Gran ]
* Fix deprecation warnings for sha module by using hashlib module instead
- add webPasswords
- add mailPreserveSuffixSeperator
- -- Peter Palfrader <weasel@debian.org> Thu, 29 Mar 2012 23:44:56 +0200
+ -- Peter Palfrader <weasel@debian.org> Wed, 11 Apr 2012 10:55:17 +0200
userdir-ldap (0.3.79) unstable; urgency=low
return last
+def getLastKeyringChangeTime():
+ krmod = 0
+ for k in Keyrings:
+ mt = os.path.getmtime(k)
+ if mt > krmod:
+ krmod = mt
+
+ return krmod
+
def getLastBuildTime(gdir):
- cache_last_mod = 0
+ cache_last_ldap_mod = 0
+ cache_last_unix_mod = 0
try:
fd = open(os.path.join(gdir, "last_update.trace"), "r")
cache_last_mod=fd.read().split()
try:
- cache_last_mod = cache_last_mod[0]
- except IndexError:
+ cache_last_ldap_mod = cache_last_mod[0]
+ cache_last_unix_mod = int(cache_last_mod[1])
+ except IndexError, ValueError:
pass
fd.close()
except IOError, e:
else:
raise e
- return cache_last_mod
-
+ return (cache_last_ldap_mod, cache_last_unix_mod)
def ud_generate():
parser = optparse.OptionParser()
l = make_ldap_conn()
+ time_started = int(time.time())
ldap_last_mod = getLastLDAPChangeTime(l)
- cache_last_mod = getLastBuildTime(generate_dir)
- need_update = ldap_last_mod > cache_last_mod
+ unix_last_mod = getLastKeyringChangeTime()
+ cache_last_ldap_mod, cache_last_unix_mod = getLastBuildTime(generate_dir)
+
+ need_update = (ldap_last_mod > cache_last_ldap_mod) or (unix_last_mod > cache_last_unix_mod)
if not options.force and not need_update:
fd = open(os.path.join(generate_dir, "last_update.trace"), "w")
- fd.write("%s\n%s\n" % (ldap_last_mod, int(time.time())))
+ fd.write("%s\n%s\n" % (ldap_last_mod, time_started))
fd.close()
sys.exit(0)
tracefd = open(os.path.join(generate_dir, "last_update.trace"), "w")
generate_all(generate_dir, l)
- tracefd.write("%s\n%s\n" % (ldap_last_mod, int(time.time())))
+ tracefd.write("%s\n%s\n" % (ldap_last_mod, time_started))
tracefd.close()