| | |
| | | |
| | | //TODO : change this when distribution information has been integrated into server record |
| | | $filespre = (file_exists('/etc/gentoo-release')) ? 'pri/' : 'pri.'; |
| | | |
| | | $soas = $app->db->queryAllRecords('SELECT * FROM dns_soa WHERE dnssec_wanted=\'Y\' AND dnssec_initialized=\'Y\' AND (dnssec_last_signed < ? OR dnssec_last_signed > ?', time()-(3600*24*5)+900, time()+900); //Resign zones every 5 days (expiry is 16 days so we have enough safety, 15 minutes tolerance) |
| | | echo "signing for ".intval($conf['server_id'])."\n"; |
| | | $soas = $app->db->queryAllRecords('SELECT id,serial,origin FROM dns_soa WHERE server_id=? AND active=\'Y\' dnssec_wanted=\'Y\' AND dnssec_initialized=\'Y\' AND (dnssec_last_signed < ? OR dnssec_last_signed > ?)', intval($conf['server_id']), time()-(3600*24*5)+900, time()+900); //Resign zones every 5 days (expiry is 16 days so we have enough safety, 15 minutes tolerance) |
| | | |
| | | foreach ($soas as $data) { |
| | | echo "Processing ".$data['origin']."\n"; |
| | | $domain = substr($data['origin'], 0, strlen($data['origin'])-1); |
| | | if (!file_exists($dns_config['bind_zonefiles_dir'].'/'.$filespre.$domain)) return false; |
| | | |
| | |
| | | $dnssecdata .= file_get_contents($keyfile)."\n\n"; |
| | | } |
| | | |
| | | if ($app->dbmaster !== $app->db) $app->dbmaster->query('UPDATE dns_soa SET dnssec_info=?, dnssec_initialized=\'Y\', dnssec_last_signed=? WHERE id=?', $dnssecdata, time(), $data['new']['id']); |
| | | $app->db->query('UPDATE dns_soa SET dnssec_info=?, dnssec_initialized=\'Y\', dnssec_last_signed=? WHERE id=?', $dnssecdata, time(), $data['new']['id']); |
| | | if ($app->dbmaster !== $app->db) $app->dbmaster->query('UPDATE dns_soa SET dnssec_info=?, dnssec_initialized=\'Y\', dnssec_last_signed=? WHERE id=?', $dnssecdata, intval(time()), intval($data['new']['id'])); |
| | | $app->db->query('UPDATE dns_soa SET dnssec_info=?, dnssec_initialized=\'Y\', dnssec_last_signed=? WHERE id=?', $dnssecdata, intval(time()), intval($data['new']['id'])); |
| | | } |
| | | |
| | | function soa_dnssec_update(&$data, $new=false) { |
| | |
| | | |
| | | if (!$new && !file_exists($dns_config['bind_zonefiles_dir'].'/dsset-'.$domain.'.')) $this->soa_dnssec_create($data); |
| | | |
| | | $dbdata = $app->db->queryOneRecord('SELECT id,serial FROM dns_soa WHERE id=?', $data['new']['id']); |
| | | $dbdata = $app->db->queryOneRecord('SELECT id,serial FROM dns_soa WHERE id=?', intval($data['new']['id'])); |
| | | exec('cd '.escapeshellcmd($dns_config['bind_zonefiles_dir']).';'. |
| | | 'named-checkzone '.escapeshellcmd($domain).' '.escapeshellcmd($dns_config['bind_zonefiles_dir']).'/'.$filespre.escapeshellcmd($domain).' | egrep -ho \'[0-9]{10}\'', $serial, $retState); |
| | | if ($retState != 0) { |
| | |
| | | unlink($dns_config['bind_zonefiles_dir'].'/'.$filespre.$domain.'.signed'); |
| | | unlink($dns_config['bind_zonefiles_dir'].'/dsset-'.$domain.'.'); |
| | | |
| | | if ($app->dbmaster !== $app->db) $app->dbmaster->query('UPDATE dns_soa SET dnssec_info=\'\', dnssec_initialized=\'N\' WHERE id=?', $data['new']['id']); |
| | | $app->db->query('UPDATE dns_soa SET dnssec_info=\'\', dnssec_initialized=\'N\' WHERE id=?', $data['new']['id']); |
| | | if ($app->dbmaster !== $app->db) $app->dbmaster->query('UPDATE dns_soa SET dnssec_info=\'\', dnssec_initialized=\'N\' WHERE id=?', intval($data['new']['id'])); |
| | | $app->db->query('UPDATE dns_soa SET dnssec_info=\'\', dnssec_initialized=\'N\' WHERE id=?', intval($data['new']['id'])); |
| | | } |
| | | |
| | | function soa_insert($event_name, $data) { |
| | |
| | | $zone = $data['new']; |
| | | $tpl->setVar($zone); |
| | | |
| | | $records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ? AND active = 'Y'", $zone['id']); |
| | | $records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ?? AND active = 'Y'", $zone['id']); |
| | | if(is_array($records) && !empty($records)){ |
| | | for($i=0;$i<sizeof($records);$i++){ |
| | | if($records[$i]['ttl'] == 0) $records[$i]['ttl'] = ''; |