Project

General

Profile

Feature #359 » 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
if params.has_key? "spoof"
ip = params.delete("spoof")
@spoof = true
elsif params.has_key? "hostname"
hostname = params.delete("hostname")
@spoof = true
elsif (ip = request.env['REMOTE_ADDR']) =~ /127.0.0/
ip = request.env["HTTP_X_FORWARDED_FOR"] unless request.env["HTTP_X_FORWARDED_FOR"].nil?
end
......
end
maccond.sub!(/, $/, ')')
conditions = (ip and (!maclist.empty?)) ? ["ip = ? and " + maccond, ip, *maclist] : ["ip = ?",ip];
if hostname.nil?
conditions = (ip and (!maclist.empty?)) ? ["ip = ? and " + maccond, ip, *maclist] : ["ip = ?",ip];
else
conditions = ["name = ?", hostname];
end
logger.info "#{controller_name}: conditions string: " + conditions.to_s
@host = Host.find(:first, :include => [:architecture, :media, :operatingsystem, :domain], :conditions => conditions)
if @host.nil?
(2-2/2)