* gpgkeys_ldap.c (send_key): List pgpCertID as one of the deleted
authorDavid Shaw <dshaw@jabberwocky.com>
Thu, 26 Feb 2004 01:29:26 +0000 (01:29 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Thu, 26 Feb 2004 01:29:26 +0000 (01:29 +0000)
attributes.  This guarantees that if something goes wrong, we won't be
able to complete the transaction, thus leaving any key already existing on
the server intact.

keyserver/ChangeLog
keyserver/gpgkeys_ldap.c

index c0f8eb3..4d6522a 100644 (file)
@@ -1,3 +1,10 @@
+2004-02-25  David Shaw  <dshaw@jabberwocky.com>
+
+       * gpgkeys_ldap.c (send_key): List pgpCertID as one of the deleted
+       attributes.  This guarantees that if something goes wrong, we
+       won't be able to complete the transaction, thus leaving any key
+       already existing on the server intact.
+
 2004-02-23  David Shaw  <dshaw@jabberwocky.com>
 
        * gpgkeys_ldap.c (delete_one_attr): Removed.
index af82498..42003b4 100644 (file)
@@ -541,6 +541,9 @@ send_key(int *eof)
   make_one_attr(&modlist,0,"pgpSubKeyID",NULL);
   make_one_attr(&modlist,0,"pgpKeySize",NULL);
   make_one_attr(&modlist,0,"pgpKeyExpireTime",NULL);
+  make_one_attr(&modlist,0,"pgpCertID",NULL);
+  /* Note the count of these deleted attributes.  They're to be used
+     later. */
 
   /* Assemble the INFO stuff into LDAP attributes */
 
@@ -672,13 +675,13 @@ send_key(int *eof)
   err=ldap_modify_s(ldap,dn,modlist);
   if(err==LDAP_NO_SUCH_OBJECT)
     {
-      LDAPMod **addlist=&modlist[10];
+      /* This [11] is the deleted count from earlier */
+      LDAPMod **addlist=&modlist[11];
       err=ldap_add_s(ldap,dn,addlist);
     }
 
   if(err!=LDAP_SUCCESS)
     {
-      printf("err %d\n",err);
       fprintf(console,"gpgkeys: error adding key %s to keyserver: %s\n",
              keyid,ldap_err2string(err));
       ret=ldap_err_to_gpg_err(err);
@@ -712,12 +715,12 @@ send_key_keyserver(int *eof)
   char keyid[17];
   LDAPMod mod, *attrs[2];
 
-  memset (&mod, 0, sizeof mod);
-  mod.mod_op      = LDAP_MOD_ADD;
-  mod.mod_type    = pgpkeystr;
-  mod.mod_values  = key;
-  attrs[0]    = &mod;
-  attrs[1]    = NULL;
+  memset(&mod,0,sizeof(mod));
+  mod.mod_op=LDAP_MOD_ADD;
+  mod.mod_type=pgpkeystr;
+  mod.mod_values=key;
+  attrs[0]=&mod;
+  attrs[1]=NULL;
 
   dn=malloc(strlen("pgpCertid=virtual,")+strlen(basekeyspacedn)+1);
   if(dn==NULL)