File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ sub doInventory {
47
47
# attempt to deduce the actual domain from the host name
48
48
# and fallback on the domain search list
49
49
my $hostname = getHostname(fqdn => 1);
50
- my $pos = index $hostname , ' .' ;
50
+ my $pos = empty( $hostname ) ? 0 : index $hostname , ' .' ;
51
51
52
52
if ($pos > 0) {
53
53
$hostname =~ s /\. +$// ;
Original file line number Diff line number Diff line change @@ -60,8 +60,11 @@ sub _getHostnameUnix {
60
60
61
61
if ($params {fqdn }) {
62
62
Net::Domain-> require();
63
- $hostname = Net::Domain::hostfqdn();
64
- $hostname =~ s /\. $// ; # the module may return a trailing dot
63
+ my $fqdn = Net::Domain::hostfqdn();
64
+ unless (empty($fqdn )) {
65
+ $fqdn =~ s /\. $// ; # the module may return a trailing dot
66
+ $hostname = $fqdn ;
67
+ }
65
68
} else {
66
69
Sys::Hostname-> require();
67
70
$hostname = Sys::Hostname::hostname();
You can’t perform that action at this time.
0 commit comments