From 9e2e13c4300253c954181a37da2f5de11e314ee6 Mon Sep 17 00:00:00 2001 From: Jon Fautley Date: Tue, 27 Jul 2010 15:32:58 +0100 Subject: [PATCH] Support 'hostname=' spoofing parameter for unattended installs --- app/controllers/unattended_controller.rb | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/app/controllers/unattended_controller.rb b/app/controllers/unattended_controller.rb index 977c839..879d56a 100644 --- a/app/controllers/unattended_controller.rb +++ b/app/controllers/unattended_controller.rb @@ -53,6 +53,9 @@ class UnattendedController < ApplicationController 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 @@ -69,7 +72,11 @@ class UnattendedController < ApplicationController 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? -- 1.5.5.6