From 313e64cbe4a7494fb91ed9f572c7bcefe6514b78 Mon Sep 17 00:00:00 2001 From: Frank Sweetser Date: Fri, 14 May 2010 10:48:26 -0400 Subject: [PATCH] Search for MAC addresses from all X-RHN-Provisioning-MAC headers, not just eth0 --- app/controllers/unattended_controller.rb | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/unattended_controller.rb b/app/controllers/unattended_controller.rb index 4d79935..e0fa19a 100644 --- a/app/controllers/unattended_controller.rb +++ b/app/controllers/unattended_controller.rb @@ -56,14 +56,23 @@ class UnattendedController < ApplicationController ip = request.env["HTTP_X_FORWARDED_FOR"] unless request.env["HTTP_X_FORWARDED_FOR"].nil? end + maclist = [] + maccond = "mac in (" unless request.env['HTTP_X_RHN_PROVISIONING_MAC_0'].nil? - mac=request.env['HTTP_X_RHN_PROVISIONING_MAC_0'].split[1].downcase.strip + request.env.keys.each { | header | + if header =~ /^HTTP_X_RHN_PROVISIONING_MAC_/ then + maccond << "?, " + maclist << request.env[header].split[1].downcase.strip + end + } end + maccond.sub!(/, $/, ')') - conditions = (mac and ip) ? ["mac = ? and ip = ?",mac, ip] : ["ip = ?",ip]; + conditions = (ip and (!maclist.empty?)) ? ["ip = ? and " + maccond, ip, *maclist] : ["ip = ?",ip]; + logger.info "#{controller_name}: conditions string: " + conditions.to_s @host = Host.find(:first, :include => [:architecture, :media, :operatingsystem, :domain], :conditions => conditions) if @host.nil? - logger.info "#{controller_name}: unable to find #{ip}#{"/"+mac unless mac.nil?}" + logger.info "#{controller_name}: unable to find ip/mac match for #{ip}" head(:not_found) and return end end -- 1.6.6.1