diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/context.h | 3 | ||||
| -rw-r--r-- | src/engine-gpg.c | 23 | ||||
| -rw-r--r-- | src/gpgme.c | 12 | 
3 files changed, 38 insertions, 0 deletions
| diff --git a/src/context.h b/src/context.h index 3ed38188..2792a160 100644 --- a/src/context.h +++ b/src/context.h @@ -174,6 +174,9 @@ struct gpgme_context    /* The optional trust-model override.  */    char *trust_model; +  /* The optional expiration date of a certification.  */ +  char *cert_expire; +    /* The operation data hooked into the context.  */    ctx_op_data_t op_data; diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 969abab6..b51ea173 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -1961,6 +1961,27 @@ append_args_from_sig_notations (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */,  static gpgme_error_t +append_args_from_cert_expire (engine_gpg_t gpg, gpgme_ctx_t ctx) +{ +  gpgme_error_t err; + +  if (ctx->cert_expire) +    { +      /* Override ask-cert-expire set in the configuration, so that the specified +       * default is actually used.  */ +      err = add_arg (gpg, "--no-ask-cert-expire"); +      if (!err) +        err = add_arg (gpg, "--default-cert-expire"); +      if (!err) +        err = add_arg (gpg, ctx->cert_expire); +    } +  else +    err = 0; +  return err; +} + + +static gpgme_error_t  gpg_edit (void *engine, int type, gpgme_key_t key, gpgme_data_t out,  	  gpgme_ctx_t ctx /* FIXME */)  { @@ -1976,6 +1997,8 @@ gpg_edit (void *engine, int type, gpgme_key_t key, gpgme_data_t out,    if (!err)      err = append_args_from_sig_notations (gpg, ctx, NOTATION_FLAG_CERT);    if (!err) +    err = append_args_from_cert_expire (gpg, ctx); +  if (!err)      err = add_arg (gpg, type == 0 ? "--edit-key" : "--card-edit");    if (!err)      err = add_data (gpg, out, 1, 1); diff --git a/src/gpgme.c b/src/gpgme.c index 8bc11d51..255d1165 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -253,6 +253,7 @@ gpgme_release (gpgme_ctx_t ctx)    free (ctx->request_origin);    free (ctx->auto_key_locate);    free (ctx->trust_model); +  free (ctx->cert_expire);    _gpgme_engine_info_release (ctx->engine_info);    ctx->engine_info = NULL;    DESTROY_LOCK (ctx->lock); @@ -578,6 +579,13 @@ gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value)      {        ctx->extended_edit = abool;      } +  else if (!strcmp (name, "cert-expire")) +    { +      free (ctx->cert_expire); +      ctx->cert_expire = strdup (value); +      if (!ctx->cert_expire) +        err = gpg_error_from_syserror (); +    }    else      err = gpg_error (GPG_ERR_UNKNOWN_NAME); @@ -647,6 +655,10 @@ gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name)      {        return ctx->extended_edit ? "1":"";      } +  else if (!strcmp (name, "cert-expire")) +    { +      return ctx->cert_expire? ctx->cert_expire : ""; +    }    else      return NULL;  } | 
