554 |
} /* get_gnupg_config */ |
} /* get_gnupg_config */ |
555 |
|
|
556 |
|
|
557 |
|
/* Set the default key in the gpg.conf. |
558 |
|
If @key is NULL, the entry will be deleted. */ |
559 |
int |
int |
560 |
set_gnupg_default_key (const char * key) |
set_gnupg_default_key (const char *key) |
561 |
{ |
{ |
562 |
gpg_optfile_t opt; |
gpg_optfile_t opt; |
563 |
gpg_option_t e; |
gpg_option_t e; |
566 |
|
|
567 |
optfile = get_gnupg_cfgfile (); |
optfile = get_gnupg_cfgfile (); |
568 |
if (!optfile) |
if (!optfile) |
569 |
return -1; |
return WPTERR_FILE_OPEN; |
570 |
rc = parse_gpg_options (optfile, &opt); |
rc = parse_gpg_options (optfile, &opt); |
571 |
if( rc ) { |
if (rc) { |
572 |
free_if_alloc (optfile); |
free_if_alloc (optfile); |
573 |
return -1; |
return WPTERR_GENERAL; |
574 |
} |
} |
575 |
e = find_option (opt, "default-key"); |
e = find_option (opt, "default-key"); |
576 |
if (e) { |
if (e && !key) |
577 |
|
e->used = 0; |
578 |
|
else if (e) { |
579 |
free_if_alloc (e->val); |
free_if_alloc (e->val); |
580 |
e->val = m_strdup (key); |
e->val = m_strdup (key); |
581 |
e->used = 1; |
e->used = 1; |
588 |
release_gpg_options (opt); |
release_gpg_options (opt); |
589 |
|
|
590 |
return rc; |
return rc; |
591 |
} /* set_gnupg_default_key */ |
} |
592 |
|
|
593 |
|
|
594 |
/* |
/* |