Project

General

Profile

Bug #4382

Spoof by hostname does not work if there is a host without an IP address

Added by Lukas Zapletal over 5 years ago. Updated over 5 years ago.

Status:
Duplicate
Priority:
Normal
Category:
Unattended installations
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

If there is at least one host that has no IP address set, hostname spoofing cannot work:

  def find_host_by_spoof
    ip, name = params.delete('spoof'), params.delete('hostname')
    return nil if ip.blank? && name.blank?
    @spoof = true
    Host.find_by_ip(ip) || Host.find_by_name(name)
  end

Beacause this query always succeeds:

Host::Managed Load (0.2ms)  SELECT "hosts".* FROM "hosts" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."ip" IS NULL LIMIT 1

and returns "random" host according to the order in index or memory or whatever (SQL database magic).

Tiny little nasty bug that made me scratching my head for a LOOONG time today when I was working on puppet-unattended. I think I will fix this as this blocks my dev setup right now. So many undeletable hosts :-)


Related issues

Is duplicate of Foreman - Bug #4268: Spoof by hostname still searches by an empty IP and returns the wrong hostClosed2014-02-05

History

#1 Updated by Dominic Cleal over 5 years ago

  • Is duplicate of Bug #4268: Spoof by hostname still searches by an empty IP and returns the wrong host added

#2 Updated by Dominic Cleal over 5 years ago

  • Status changed from Assigned to Duplicate
  • Target version deleted (1.9.1)

git rebase develop :)

Also available in: Atom PDF