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>
This commit is contained in:
Aravinda VK 2015-03-01 11:48:12 +05:30 committed by Vijay Bellur
parent 2452d284b3
commit 1a2c1e9bf8

View File

@ -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;