/usr/share/fusioninventory/lib/FusionInventory/Agent/Task/Inventory/Generic/Domains.pm is in fusioninventory-agent 1:2.3.10.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | package FusionInventory::Agent::Task::Inventory::Generic::Domains;
use strict;
use warnings;
use Sys::Hostname;
use FusionInventory::Agent::Tools;
sub isEnabled {
return -f "/etc/resolv.conf";
}
sub doInventory {
my (%params) = @_;
my $inventory = $params{inventory};
my $logger = $params{logger};
# first, parse /etc/resolv.conf for the DNS servers,
# and the domain search list
my %dns_list;
my %search_list;
my $handle = getFileHandle(
file => '/etc/resolv.conf',
logger => $logger
);
if ($handle) {
while (my $line = <$handle>) {
if ($line =~ /^nameserver\s+(\S+)/) {
$dns_list{$1} = 1;
} elsif ($line =~ /^(domain|search)\s+(\S+)/) {
$search_list{$2} = 1;
}
}
close $handle;
}
my $dns = join('/', keys %dns_list);
# attempt to deduce the actual domain from the host name
# and fallback on the domain search list
my $domain;
my $hostname = hostname();
my $pos = index $hostname, '.';
if ($pos >= 0) {
$domain = substr($hostname, $pos + 1);
} else {
$domain = join('/', keys %search_list);
}
$inventory->setHardware({
WORKGROUP => $domain,
DNS => $dns
});
}
1;
|