From: Peter Palfrader Date: Wed, 29 May 2013 13:57:06 +0000 (+0000) Subject: Use something that will hopefully be more stable in the future X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=cf5ca6f6942ed9b46e05a0cdc8f43a54e5190044;p=mirror%2Fdsa-puppet.git Use something that will hopefully be more stable in the future --- diff --git a/modules/portforwarder/templates/authorized_keys.erb b/modules/portforwarder/templates/authorized_keys.erb index 1ffd9e849..063312a2f 100644 --- a/modules/portforwarder/templates/authorized_keys.erb +++ b/modules/portforwarder/templates/authorized_keys.erb @@ -4,6 +4,13 @@ ## <%= + +require 'digest/sha1' +def get_local_ip_addr(host) + hash = Digest::SHA1.digest(host) + return '127.101.%d.%d'%[hash[0].ord, hash[1].ord] +end + def getportforwarderkey(host) key = nil begin @@ -30,7 +37,7 @@ config.each_pair do |sourcehost, services| if allowed_ports.length > 0 sshkey = getportforwarderkey(sourcehost) remote_ip = scope.lookupvar('site::allnodeinfo')[sourcehost]['ipHostNumber'].join(',') - local_bind = '127.101.%d.%d'%[ (sourcehost.hash / 256 % 256), sourcehost.hash % 256 ] + local_bind = get_local_ip_addr(sourcehost) lines << "# from #{sourcehost}" if sshkey.nil? or remote_ip.nil? or local_bind.nil?