*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
-/* update the current keyblock with KB */
+/* Update the current keyblock with KB. */
int
keydb_update_cert (KEYDB_HANDLE hd, ksba_cert_t cert)
{
mode = KEYDB_SEARCH_MODE_FPR;
}
break;
-
+
+ case '&': /* Keygrip*/
+ {
+ if (hex2bin (s+1, desc->u.grip, 20) < 0)
+ return 0; /* Invalid. */
+ mode = KEYDB_SEARCH_MODE_KEYGRIP;
+ }
+ break;
+
default:
if (s[0] == '0' && s[1] == 'x')
{
transaction by locating the certificate in the DB and updating the
flags. */
gpg_error_t
-keydb_set_cert_flags (ksba_cert_t cert, int which, int idx, unsigned int value)
+keydb_set_cert_flags (ksba_cert_t cert, int ephemeral,
+ int which, int idx,
+ unsigned int mask, unsigned int value)
{
KEYDB_HANDLE kh;
gpg_error_t err;
return gpg_error (GPG_ERR_ENOMEM);;
}
+ if (ephemeral)
+ keydb_set_ephemeral (kh, 1);
+
err = keydb_lock (kh);
if (err)
{
err = keydb_search_fpr (kh, fpr);
if (err)
{
- log_error (_("problem re-searching certificate: %s\n"),
- gpg_strerror (err));
+ if (err == -1)
+ err = gpg_error (GPG_ERR_NOT_FOUND);
+ else
+ log_error (_("problem re-searching certificate: %s\n"),
+ gpg_strerror (err));
keydb_release (kh);
return err;
}
keydb_release (kh);
return err;
}
+
+ value = ((old_value & ~mask) | (value & mask));
+
if (value != old_value)
{
err = keydb_set_flags (kh, which, idx, value);
return err;
}
}
+
keydb_release (kh);
return 0;
}