Skip to content

Commit 937c0ce

Browse files
committed
fix: Fix minor perl errors on linux when no domain has been setup
1 parent 6e60580 commit 937c0ce

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/GLPI/Agent/Task/Inventory/Generic/Domains.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ sub doInventory {
4747
# attempt to deduce the actual domain from the host name
4848
# and fallback on the domain search list
4949
my $hostname = getHostname(fqdn => 1);
50-
my $pos = index $hostname, '.';
50+
my $pos = empty($hostname) ? 0 : index $hostname, '.';
5151

5252
if ($pos > 0) {
5353
$hostname =~ s/\.+$//;

lib/GLPI/Agent/Tools/Hostname.pm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ sub _getHostnameUnix {
6060

6161
if ($params{fqdn}) {
6262
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+
}
6568
} else {
6669
Sys::Hostname->require();
6770
$hostname = Sys::Hostname::hostname();

0 commit comments

Comments
 (0)