mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	CLOUDSTACK-8331: savepassword should try all IPs on eth0
The logic is same as passwd_server_ip script which runs password server on all IPs on eth0 interface. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
		
							parent
							
								
									488625b193
								
							
						
					
					
						commit
						294503a025
					
				@ -39,6 +39,7 @@ from SocketServer     import ThreadingMixIn #, ForkingMixIn
 | 
			
		||||
 | 
			
		||||
passMap = {}
 | 
			
		||||
secureToken = None
 | 
			
		||||
listeningAddress = '127.0.0.1'
 | 
			
		||||
lock = threading.RLock()
 | 
			
		||||
 | 
			
		||||
def getTokenFile():
 | 
			
		||||
@ -133,7 +134,7 @@ class PasswordRequestHandler(BaseHTTPRequestHandler):
 | 
			
		||||
        self.send_response(200)
 | 
			
		||||
        self.end_headers()
 | 
			
		||||
        clientAddress = self.client_address[0]
 | 
			
		||||
        if clientAddress not in ['localhost', '127.0.0.1']:
 | 
			
		||||
        if clientAddress not in ['localhost', '127.0.0.1', listeningAddress]:
 | 
			
		||||
            syslog.syslog('serve_password: non-localhost IP trying to save password: %s' % clientAddress)
 | 
			
		||||
            self.send_response(403)
 | 
			
		||||
            return
 | 
			
		||||
@ -162,7 +163,7 @@ class PasswordRequestHandler(BaseHTTPRequestHandler):
 | 
			
		||||
def serve(HandlerClass = PasswordRequestHandler,
 | 
			
		||||
          ServerClass = ThreadedHTTPServer):
 | 
			
		||||
 | 
			
		||||
    listeningAddress = '127.0.0.1'
 | 
			
		||||
    global listeningAddress
 | 
			
		||||
    if len(sys.argv) > 1:
 | 
			
		||||
        listeningAddress = sys.argv[1]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -30,7 +30,6 @@ do
 | 
			
		||||
        ;;
 | 
			
		||||
  esac
 | 
			
		||||
done
 | 
			
		||||
SERVER_IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
 | 
			
		||||
TOKEN_FILE="/tmp/passwdsrvrtoken"
 | 
			
		||||
TOKEN=""
 | 
			
		||||
if [ -f $TOKEN_FILE ]; then
 | 
			
		||||
@ -39,5 +38,9 @@ fi
 | 
			
		||||
ps aux | grep passwd_server_ip.py |grep -v grep 2>&1 > /dev/null
 | 
			
		||||
if [ $? -eq 0 ]
 | 
			
		||||
then
 | 
			
		||||
    curl --header "DomU_Request: save_password" "http://$SERVER_IP:8080/" -F "ip=$VM_IP" -F "password=$PASSWORD" -F "token=$TOKEN"
 | 
			
		||||
    ips=$(ip addr show dev eth0 | grep inet | grep eth0 | awk '{print $2}')
 | 
			
		||||
    for ip in $ips; do
 | 
			
		||||
        server_ip=$(echo $ip | awk -F'/' '{print $1}')
 | 
			
		||||
        curl --header "DomU_Request: save_password" "http://$server_ip:8080/" -F "ip=$VM_IP" -F "password=$PASSWORD" -F "token=$TOKEN" >/dev/null 2>/dev/null &
 | 
			
		||||
    done
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user