aboutsummaryrefslogtreecommitdiffstats
path: root/agent/findkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'agent/findkey.c')
-rw-r--r--agent/findkey.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/agent/findkey.c b/agent/findkey.c
index 4ca83bce4..954199fcd 100644
--- a/agent/findkey.c
+++ b/agent/findkey.c
@@ -132,14 +132,15 @@ linefeed_to_percent0A (const char *string)
* GRIP will get overwritten. If SERIALNO and KEYREF are given a
* Token line is added to the key if the extended format is used. If
* TIMESTAMP is not zero and the key does not yet exists it will be
- * recorded as creation date. */
+ * recorded as creation date. If LINKATTR is not NULL a Link: entry
+ * with that value will also be written. */
gpg_error_t
agent_write_private_key (ctrl_t ctrl,
const unsigned char *grip,
const void *buffer, size_t length, int force,
const char *serialno, const char *keyref,
const char *dispserialno,
- time_t timestamp)
+ time_t timestamp, const char *linkattr)
{
gpg_error_t err;
char *fname = NULL;
@@ -309,6 +310,15 @@ agent_write_private_key (ctrl_t ctrl,
goto leave;
}
+ /* Write a link attribute if supplied. */
+ if (linkattr && *linkattr)
+ {
+ err = nvc_add (pk, "Link:", linkattr);
+ if (err)
+ goto leave;
+ }
+
+
/* Check whether we need to write the file at all. */
if (!nvc_modified (pk, 0))
{
@@ -2104,7 +2114,7 @@ agent_write_shadow_key (ctrl_t ctrl, const unsigned char *grip,
len = gcry_sexp_canon_len (shdkey, 0, NULL, NULL);
err = agent_write_private_key (ctrl, grip, shdkey, len, force,
- serialno, keyid, dispserialno, 0);
+ serialno, keyid, dispserialno, 0, NULL);
xfree (shdkey);
if (err)
log_error ("error writing key: %s\n", gpg_strerror (err));