fix gpg update.
authorBaris Metin <bmetin@verivue.com>
Mon, 2 May 2011 21:54:15 +0000 (17:54 -0400)
committerS.Çağlar Onur <caglar@verivue.com>
Wed, 4 May 2011 19:47:50 +0000 (15:47 -0400)
this issue raises in gpg2 (hangs in SL6), but it's considered as a bug in gpg1
https://bugs.g10code.com/gnupg/issue1122

plc.d/gpg

index 304b1ea..3993f42 100755 (executable)
--- a/plc.d/gpg
+++ b/plc.d/gpg
@@ -86,12 +86,25 @@ EOF
            )
            IFS=$OLDIFS
 
-           # Add a new UID if appropriate. GPG will detect and merge duplicates.
-           gpg --homedir=$homedir --no-permission-warning --batch --no-tty --yes \
-               --no-default-keyring \
-               --secret-keyring=$PLC_ROOT_GPG_KEY \
-               --keyring=$PLC_ROOT_GPG_KEY_PUB \
-               --command-fd 0 --status-fd 1 --edit-key $fingerprint <<EOF
+
+           # Add a new UID if appropriate. GPG (v1) will detect and
+           # merge duplicates but this is considered as a bug in GPG2
+           # and we need to check for existence.
+            gpg --homedir=$homedir --no-permission-warning --batch --no-tty --yes \
+                --list-keys \
+                --no-default-keyring \
+                --secret-keyring=/etc/planetlab/secring.gpg \
+                --keyring=/etc/planetlab/pubring.gpg \
+                | grep "$PLC_NAME Central" \
+                | grep "$PLC_MAIL_SUPPORT_ADDRESS" \
+                | grep "http://$PLC_WWW_HOST/"
+            
+            if [ $? -ne 1 ]; then
+               gpg --homedir=$homedir --no-permission-warning --batch --no-tty --yes \
+                   --no-default-keyring \
+                   --secret-keyring=$PLC_ROOT_GPG_KEY \
+                   --keyring=$PLC_ROOT_GPG_KEY_PUB \
+                   --Command-Fd 0 --status-fd 1 --edit-key $fingerprint <<EOF
 adduid
 $PLC_NAME Central
 $PLC_MAIL_SUPPORT_ADDRESS
@@ -99,6 +112,8 @@ http://$PLC_WWW_HOST/
 save
 EOF
            check
+            fi
+
        fi
 
        # Install the key in the RPM database