
Jeff Silver wrote:
--- names/authority.py 2004-02-07 17:57:11.000000000 +0000 +++ names/authority.py.new 2005-02-25 09:34:02.725600288 +0000 @@ -161,6 +161,78 @@ add.extend(res[1][2]) return ans, auth, add
+ def _trySaveToOriginalFile(self): + '''Called after an update.''' + soa_rec = self.soa[1] + new_serial = int(time.strftime('%Y%m%d%H%M')) - 200000000000 + if new_serial <= soa_rec.serial: + new_serial = soa_rec.serial + 1 + old_serial = soa_rec.serial + soa_rec.serial = new_serial + if hasattr(self, 'filename'): + tmp_filename = self.filename + '.new' + save_filename = '%s.%d' % (self.filename, old_serial) + self.saveFile(tmp_filename) + os.rename(self.filename, save_filename) + os.rename(tmp_filename, self.filename)
While I am not going to comment on the rest of the patch (the feature does sound nice, altough lack of authentication makes using it pretty pointless IMHO), this is just unacceptable. If an exception is raised, the app crashes, or the machine loses power between those two renames, your original zone file has been renamed and your DNS server won't start. Do something like
f=open('foo', 'w') f.write('foo') f.close() import os os.link('foo', 'foo.old') f=open('bar', 'w') f.write('bar') os.fsync(f) f.close() os.rename('bar', 'foo')
Also, nice y2.043k trap there, I don't think many have been able to write ones targeting that exact date.