From 1a2c1e9bf8d711d821fbd166ed6d7f7d9bcce69d Mon Sep 17 00:00:00 2001 From: Aravinda VK Date: Sun, 1 Mar 2015 11:48:12 +0530 Subject: geo-rep: Avoid duplicate entries in authorized_keys file When Georep create(force) command is run multiple times it appends master nodes public keys to Slave nodes without checking the existence of the key. With this patch, create push-pem force adds pub key only if not available in authorized_keys. BUG: 1197433 Change-Id: Iad57f6c45698e258ad1a547fa7a2e376a315f0cd Signed-off-by: Aravinda VK Reviewed-on: http://review.gluster.org/9776 Tested-by: Gluster Build System Reviewed-by: Kotresh HR Reviewed-by: Saravanakumar Arumugam Reviewed-by: Vijay Bellur --- geo-replication/src/peer_add_secret_pub.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'geo-replication/src') diff --git a/geo-replication/src/peer_add_secret_pub.in b/geo-replication/src/peer_add_secret_pub.in index a297dd09754..1fc31642c8a 100644 --- a/geo-replication/src/peer_add_secret_pub.in +++ b/geo-replication/src/peer_add_secret_pub.in @@ -60,5 +60,12 @@ if [ ! -d $authorized_keys_file ]; then fi pub_file=${mastervol}_${slavevol}_common_secret.pem.pub -cat "$GLUSTERD_WORKDIR"/geo-replication/$pub_file >> \ - $authorized_keys_file; + +# Add to authorized_keys file only if not exists already +while read line +do + grep -Fxq "$line" $authorized_keys_file; + [ $? -ne 0 ] && echo "$line" >> $authorized_keys_file; +done < "$GLUSTERD_WORKDIR"/geo-replication/$pub_file; + +exit 0; -- cgit