From 0c40a0275ec90fdc1f5ca50854ad251063dfe8a6 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Thu, 21 Sep 2017 05:58:49 +0200 Subject: [PATCH] [fix] ask cron to flush bind cache on key migration situation --- dynette.cron.py | 6 ++++++ dynette.rb | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/dynette.cron.py b/dynette.cron.py index cdf542d..77dfe74 100755 --- a/dynette.cron.py +++ b/dynette.cron.py @@ -119,3 +119,9 @@ else: os.system('/usr/sbin/rndc reload') print("An error occured ! Please check daemon.log and your conf.bad") exit(1) + +# mein got this is so awful +if os.path.exists('/tmp/dynette_flush_bind_cache'): + os.system('/usr/sbin/rndc flush') + os.system('/usr/sbin/rndc reload') + os.system('rm /tmp/dynette_flush_bind_cache') diff --git a/dynette.rb b/dynette.rb index 08d1dab..0529e64 100755 --- a/dynette.rb +++ b/dynette.rb @@ -228,12 +228,13 @@ put '/migrate_key_to_sha512/' do halt 412, { :error => "A problem occured during key algo migration" }.to_json end - # need to regenerate bind9 stuff - # yes this is awful - `python /root/dynette/dynette.cron.py` - # flush this idiotic bind cache because he doesn't know how to do that - # himself - `/usr/sbin/rndc flush` + # I don't have any other way of communicating with this dynette.cron.py + # this is awful + File.open("/tmp/dynette_flush_bind_cache", "w").close + + # assume that the dynette.cron.py runs every minute like on prod and add a + # bit of security margin. I hate that. + sleep(90) halt 201, { :public_key => entry.public_key, :subdomain => entry.subdomain, :current_ip => entry.current_ip }.to_json end