From 0d7cae466370ce8a9498be794992063c6b3aaa7c Mon Sep 17 00:00:00 2001 From: David Shaw Date: Thu, 26 Feb 2004 01:29:26 +0000 Subject: [PATCH] * 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. --- keyserver/ChangeLog | 7 +++++++ keyserver/gpgkeys_ldap.c | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog index c0f8eb388..4d6522a21 100644 --- a/keyserver/ChangeLog +++ b/keyserver/ChangeLog @@ -1,3 +1,10 @@ +2004-02-25 David Shaw + + * 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 * gpgkeys_ldap.c (delete_one_attr): Removed. diff --git a/keyserver/gpgkeys_ldap.c b/keyserver/gpgkeys_ldap.c index af82498d2..42003b483 100644 --- a/keyserver/gpgkeys_ldap.c +++ b/keyserver/gpgkeys_ldap.c @@ -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)