diff options
author | Aravinda VK <avishwan@redhat.com> | 2015-03-01 11:48:12 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-03-05 18:27:40 -0800 |
commit | 1a2c1e9bf8d711d821fbd166ed6d7f7d9bcce69d (patch) | |
tree | 270ce9137524ecd1b58f7b5229114164712caf17 /geo-replication/src | |
parent | 2452d284b38061981d7fbd7e5a7bd15808d13c21 (diff) |
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 <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/9776
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kotresh HR <khiremat@redhat.com>
Reviewed-by: Saravanakumar Arumugam <sarumuga@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'geo-replication/src')
-rw-r--r-- | geo-replication/src/peer_add_secret_pub.in | 11 |
1 files changed, 9 insertions, 2 deletions
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; |