Pārlūkot izejas kodu

fixed update DNS by DHCP for domain's computer
cosmetic changes

root 1 gadu atpakaļ
vecāks
revīzija
4142b2d

+ 0 - 0
docs/addons/flow-save → docs/deprecated/flow-save


+ 0 - 0
docs/systemd/fprobe@.service → docs/deprecated/fprobe@.service


+ 0 - 0
docs/logrotate/iptraf-ng → docs/deprecated/iptraf-ng


+ 0 - 0
docs/nf_capd → docs/deprecated/nf_capd


+ 0 - 0
docs/systemd/nfcapd-1.6@.service → docs/deprecated/nfcapd-1.6@.service


+ 0 - 0
docs/systemd/nfcapd-1.7@.service → docs/deprecated/nfcapd-1.7@.service


+ 0 - 0
docs/systemd/nfcapd/office.conf → docs/deprecated/nfcapd/office.conf


+ 0 - 16
docs/flow-save

@@ -1,16 +0,0 @@
-#!/bin/bash -x
-
-YY=`date -d yesterday +%Y`
-MM=`date -d yesterday +%m`
-DD=`date -d yesterday +%d`
-
-SAVE_PATH=/mnt/md0/stat/${YY}/${MM}/${DD}/
-FLOW_DATA='/mnt/md0/stat/flow-data'
-
-[ ! -e "${SAVE_PATH}" ] && mkdir -p ${SAVE_PATH}
-
-find "${FLOW_DATA}" -name "nfcapd.${YY}${MM}${DD}*" -exec mv -f {} "${SAVE_PATH}" \;
-
-/sbin/service nfcapd restart >/dev/null
-
-exit 0

+ 12 - 4
scripts/eyelib/database.pm

@@ -942,13 +942,18 @@ sub is_ad_computer {
 my $hdb = shift;
 my $computer_name = shift;
 
+if (!$computer_name or $computer_name =~/UNDEFINED/i) { return 0; }
+
 my $ad_check = get_option($hdb,73);
 if (!$ad_check) { return 1; }
 
 my $ad_zone = get_option($hdb,33);
 
 if ($computer_name =~/\./) {
-    if ($computer_name!~/\.$ad_zone$/i) { return 0; }
+    if ($computer_name!~/\.$ad_zone$/i) { 
+        db_log_verbose($hdb,"The domain of the computer $computer_name does not match the domain of the organization $ad_zone. Skip update.");
+        return 0;
+        }
     }
 
 if ($computer_name =~/^(.+)\./) {
@@ -960,8 +965,11 @@ my $ad_computer_name = trim($computer_name).'$';
 my $name_in_cache = get_record_sql($hdb,"SELECT * FROM ad_comp_cache WHERE name='".$computer_name."'");
 if ($name_in_cache) { return 1; }
 
-my $name_found=do_exec('/usr/bin/getent passwd '.$ad_computer_name);
-if (!$name_found) { return 0; }
+my %name_found=do_exec_ref('/usr/bin/getent passwd '.$ad_computer_name);
+if (!$name_found{output} or $name_found{status} ne 0) {
+    db_log_verbose($hdb,"The computer ".uc($ad_computer_name)." was not found in the domain $ad_zone. Skip update.");
+    return 0;
+    }
 
 do_sql($hdb,"INSERT INTO ad_comp_cache(name) VALUES('".$computer_name."') ON DUPLICATE KEY UPDATE name='".$computer_name."';");
 return 1;
@@ -989,7 +997,7 @@ log_debug("Subnets: ".Dumper($subnets_dhcp->{$dhcp_record->{network}->{subnet}})
 log_debug("enable_ad_dns_update: ".$enable_ad_dns_update);
 log_debug("DNS update flags - zone: ".$ad_zone.",dns: ".$ad_dns.", update_hostname_from_dhcp: ".$update_hostname_from_dhcp.", enable_ad_dns_update: ".$enable_ad_dns_update);
 
-my $maybe_update_dns=(is_ad_computer($hdb,$dhcp_record->{hostname_utf8}) and ($dhcp_record->{type}=~/add/i or $dhcp_record->{type}=~/old/i) and $dhcp_record->{hostname_utf8} and $dhcp_record->{hostname_utf8} !~/UNDEFINED/i and $enable_ad_dns_update and $subnets_dhcp->{$dhcp_record->{network}->{subnet}}->{dhcp_update_hostname});
+my $maybe_update_dns=(is_ad_computer($hdb,$dhcp_record->{hostname_utf8}) and ($dhcp_record->{type}=~/add/i or $dhcp_record->{type}=~/old/i) and $enable_ad_dns_update and $subnets_dhcp->{$dhcp_record->{network}->{subnet}}->{dhcp_update_hostname});
 if (!$maybe_update_dns) {
     db_log_debug($hdb,"FOUND Auth_id: $auth_record->{id}. DNS update don't needed.");
     return 0;