From 4552115bbb039b9683ffdad40964d2925e0754ef Mon Sep 17 00:00:00 2001 From: David Shaw Date: Wed, 28 Jul 2004 19:45:23 +0000 Subject: [PATCH] * gpgkeys_ldap.c (join_two_modlists): New. (send_key): Use new function so we can try a modify operation first, and fail over to an add if that fails. Add cannot cope with the NULLs at the head of the modify request, so we jump into the list in the middle. --- keyserver/ChangeLog | 8 ++++ keyserver/gpgkeys_ldap.c | 81 ++++++++++++++++++++++++++++++---------- 2 files changed, 70 insertions(+), 19 deletions(-) diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog index e364daf31..1780d3717 100644 --- a/keyserver/ChangeLog +++ b/keyserver/ChangeLog @@ -1,3 +1,11 @@ +2004-07-28 David Shaw + + * gpgkeys_ldap.c (join_two_modlists): New. + (send_key): Use new function so we can try a modify operation + first, and fail over to an add if that fails. Add cannot cope + with the NULLs at the head of the modify request, so we jump into + the list in the middle. + 2004-07-27 David Shaw * gpgkeys_ldap.c (main): Don't try and error out before making a diff --git a/keyserver/gpgkeys_ldap.c b/keyserver/gpgkeys_ldap.c index 9db0026c8..8d1014179 100644 --- a/keyserver/gpgkeys_ldap.c +++ b/keyserver/gpgkeys_ldap.c @@ -220,6 +220,34 @@ epoch2ldaptime(time_t stamp) return strdup(buf); } +/* Append two onto the end of one. Two is not freed, but its pointers + are now part of one. Make sure you don't free them both! */ +static int +join_two_modlists(LDAPMod ***one,LDAPMod **two) +{ + int i,one_count=0,two_count=0; + LDAPMod **grow; + + for(grow=*one;*grow;grow++) + one_count++; + + for(grow=two;*grow;grow++) + two_count++; + + grow=realloc(*one,sizeof(LDAPMod *)*(one_count+two_count+1)); + if(!grow) + return 0; + + for(i=0;i