Project

General

Profile

0001-Support-hostname-spoofing-parameter-for-unattende.patch

The proper patch... - Jon Fautley, 07/29/2010 01:04 PM

View differences:

app/controllers/unattended_controller.rb
53 53
    if params.has_key? "spoof"
54 54
      ip = params.delete("spoof")
55 55
      @spoof = true
56
    elsif params.has_key? "hostname"
57
      hostname = params.delete("hostname")
58
      @spoof = true
56 59
    elsif (ip = request.env['REMOTE_ADDR']) =~ /127.0.0/
57 60
      ip = request.env["HTTP_X_FORWARDED_FOR"] unless request.env["HTTP_X_FORWARDED_FOR"].nil?
58 61
    end
......
69 72
    end
70 73
    maccond.sub!(/, $/, ')')
71 74

  
72
    conditions = (ip and (!maclist.empty?)) ? ["ip = ? and " + maccond, ip, *maclist] : ["ip = ?",ip];
75
    if hostname.nil?
76
      conditions = (ip and (!maclist.empty?)) ? ["ip = ? and " + maccond, ip, *maclist] : ["ip = ?",ip];
77
    else
78
      conditions = ["name = ?", hostname];
79
    end
73 80
    logger.info "#{controller_name}: conditions string: " + conditions.to_s
74 81
    @host = Host.find(:first, :include => [:architecture, :media, :operatingsystem, :domain], :conditions => conditions)
75 82
    if @host.nil?
76
-