Skip to content

Commit 83736ab

Browse files
committed
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> (cherry picked from commit 294503a) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent e3c04c7 commit 83736ab

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

systemvm/patches/debian/config/opt/cloud/bin/passwd_server_ip.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
passMap = {}
4141
secureToken = None
42+
listeningAddress = '127.0.0.1'
4243
lock = threading.RLock()
4344

4445
def getTokenFile():
@@ -133,7 +134,7 @@ def do_POST(self):
133134
self.send_response(200)
134135
self.end_headers()
135136
clientAddress = self.client_address[0]
136-
if clientAddress not in ['localhost', '127.0.0.1']:
137+
if clientAddress not in ['localhost', '127.0.0.1', listeningAddress]:
137138
syslog.syslog('serve_password: non-localhost IP trying to save password: %s' % clientAddress)
138139
self.send_response(403)
139140
return
@@ -162,7 +163,7 @@ def log_message(self, format, *args):
162163
def serve(HandlerClass = PasswordRequestHandler,
163164
ServerClass = ThreadedHTTPServer):
164165

165-
listeningAddress = '127.0.0.1'
166+
global listeningAddress
166167
if len(sys.argv) > 1:
167168
listeningAddress = sys.argv[1]
168169

systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ do
3030
;;
3131
esac
3232
done
33-
SERVER_IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
3433
TOKEN_FILE="/tmp/passwdsrvrtoken"
3534
TOKEN=""
3635
if [ -f $TOKEN_FILE ]; then
@@ -39,5 +38,9 @@ fi
3938
ps aux | grep passwd_server_ip.py |grep -v grep 2>&1 > /dev/null
4039
if [ $? -eq 0 ]
4140
then
42-
curl --header "DomU_Request: save_password" "http://$SERVER_IP:8080/" -F "ip=$VM_IP" -F "password=$PASSWORD" -F "token=$TOKEN"
41+
ips=$(ip addr show dev eth0 | grep inet | grep eth0 | awk '{print $2}')
42+
for ip in $ips; do
43+
server_ip=$(echo $ip | awk -F'/' '{print $1}')
44+
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 &
45+
done
4346
fi

0 commit comments

Comments
 (0)