97 |
if (path && dir_exist_check (path) == 0) |
if (path && dir_exist_check (path) == 0) |
98 |
return path; |
return path; |
99 |
free_if_alloc (path); |
free_if_alloc (path); |
100 |
path = multi_gnupg_path (1); |
return multi_gnupg_path (1); |
|
return path; |
|
101 |
} |
} |
102 |
|
|
103 |
|
|
107 |
get_gnupg_cfgfile (void) |
get_gnupg_cfgfile (void) |
108 |
{ |
{ |
109 |
char *optfile = NULL; |
char *optfile = NULL; |
110 |
char *path = NULL; |
char *path; |
111 |
size_t nlen = 0; |
size_t nlen; |
112 |
|
|
113 |
path = get_gnupg_path (); |
path = get_gnupg_path (); |
114 |
if (!path) |
if (!path) |
116 |
nlen = strlen (path) + 64; |
nlen = strlen (path) + 64; |
117 |
optfile = new char[nlen + 1]; |
optfile = new char[nlen + 1]; |
118 |
if (!optfile) |
if (!optfile) |
119 |
BUG (NULL); |
BUG (NULL); |
120 |
_snprintf (optfile, nlen, "%s\\"GPG_CONF, path); |
_snprintf (optfile, nlen, "%s\\"GPG_CONF, path); |
121 |
|
|
122 |
free_if_alloc (path); |
free_if_alloc (path); |
172 |
if (!path) |
if (!path) |
173 |
return NULL; |
return NULL; |
174 |
pgm = make_filename (path, "gpg", "exe"); |
pgm = make_filename (path, "gpg", "exe"); |
175 |
free_if_alloc (path); |
free_if_alloc (path); |
176 |
return pgm; |
return pgm; |
177 |
} |
} |
178 |
|
|
212 |
gnupg_load_config (void) |
gnupg_load_config (void) |
213 |
{ |
{ |
214 |
gpg_optfile_t opt; |
gpg_optfile_t opt; |
|
gpg_option_t o; |
|
215 |
char *conf; |
char *conf; |
216 |
|
|
217 |
conf = get_gnupg_cfgfile (); |
conf = get_gnupg_cfgfile (); |
218 |
if (!conf) |
if (!conf) |
219 |
return -1; |
return -1; |
220 |
if (parse_gpg_options (conf, &opt)) { |
if (parse_config (conf, &opt)) { |
221 |
free_if_alloc (conf); |
free_if_alloc (conf); |
222 |
return -1; |
return -1; |
223 |
} |
} |
224 |
o = find_option (opt, "ask-cert-level"); |
if (find_option (opt, "ask-cert-level")) |
|
if (o) |
|
225 |
reg_prefs.gpg.ask_cert_level = 1; |
reg_prefs.gpg.ask_cert_level = 1; |
226 |
o = find_option (opt, "ask-cert-expire"); |
if (find_option (opt, "ask-cert-expire")) |
|
if (o) |
|
227 |
reg_prefs.gpg.ask_cert_expire = 1; |
reg_prefs.gpg.ask_cert_expire = 1; |
228 |
release_gpg_options (opt); |
release_config (opt); |
229 |
free_if_alloc (conf); |
free_if_alloc (conf); |
230 |
return 0; |
return 0; |
231 |
} |
} |
260 |
optfile = get_gnupg_cfgfile (); |
optfile = get_gnupg_cfgfile (); |
261 |
if (!optfile) |
if (!optfile) |
262 |
return default_key_from_cache (&no_usable); |
return default_key_from_cache (&no_usable); |
263 |
if (parse_gpg_options (optfile, &opt)) { |
if (parse_config (optfile, &opt)) { |
264 |
free_if_alloc (optfile); |
free_if_alloc (optfile); |
265 |
return default_key_from_cache (&no_usable); |
return default_key_from_cache (&no_usable); |
266 |
} |
} |
271 |
keyid = extract_keyid (e->val); |
keyid = extract_keyid (e->val); |
272 |
|
|
273 |
free_if_alloc (optfile); |
free_if_alloc (optfile); |
274 |
release_gpg_options (opt); |
release_config (opt); |
275 |
if (!keyid) |
if (!keyid) |
276 |
keyid = default_key_from_cache (&no_usable); |
keyid = default_key_from_cache (&no_usable); |
277 |
return keyid; |
return keyid; |
400 |
*r_secrings = 0; |
*r_secrings = 0; |
401 |
*r_pubrings = 0; |
*r_pubrings = 0; |
402 |
|
|
403 |
if (parse_gpg_options (fname, &opt)) |
if (parse_config (fname, &opt)) |
404 |
return WPTERR_FILE_OPEN; |
return WPTERR_FILE_OPEN; |
405 |
for (e = opt->list; e; e = e->next) { |
for (e = opt->list; e; e = e->next) { |
406 |
if (!strcmp( e->name, "secret-keyring")) { |
if (!strcmp (e->name, "secret-keyring")) { |
407 |
if (!file_exist_check (e->val)) |
if (!file_exist_check (e->val)) |
408 |
r_secrings[0]++; |
r_secrings[0]++; |
409 |
} |
} |
412 |
r_pubrings[0]++; |
r_pubrings[0]++; |
413 |
} |
} |
414 |
} |
} |
415 |
release_gpg_options (opt); |
release_config (opt); |
416 |
return 0; |
return 0; |
417 |
} |
} |
418 |
|
|
558 |
optfile = get_gnupg_cfgfile (); |
optfile = get_gnupg_cfgfile (); |
559 |
if (!optfile) |
if (!optfile) |
560 |
return WPTERR_FILE_OPEN; |
return WPTERR_FILE_OPEN; |
561 |
rc = parse_gpg_options (optfile, &opt); |
rc = parse_config (optfile, &opt); |
562 |
if (rc) { |
if (rc) { |
563 |
free_if_alloc (optfile); |
free_if_alloc (optfile); |
564 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
573 |
} |
} |
574 |
else if (key) |
else if (key) |
575 |
add_entry (opt, ENTRY_MULTI, "default-key", key); |
add_entry (opt, ENTRY_MULTI, "default-key", key); |
576 |
rc = commit_gpg_options (optfile, opt); |
rc = commit_config (optfile, opt); |
577 |
|
|
578 |
free_if_alloc (optfile); |
free_if_alloc (optfile); |
579 |
release_gpg_options (opt); |
release_config (opt); |
|
|
|
580 |
return rc; |
return rc; |
581 |
} |
} |
582 |
|
|
790 |
char *kring = NULL; |
char *kring = NULL; |
791 |
int rc; |
int rc; |
792 |
|
|
793 |
rc = parse_gpg_options (fname, &opt); |
rc = parse_config (fname, &opt); |
794 |
if (rc) |
if (rc) |
795 |
return NULL; |
return NULL; |
796 |
if (pub) |
if (pub) |
799 |
e = find_option (opt, "secret-keyring"); |
e = find_option (opt, "secret-keyring"); |
800 |
if (e) |
if (e) |
801 |
kring = m_strdup (e->val); |
kring = m_strdup (e->val); |
802 |
release_gpg_options (opt); |
release_config (opt); |
803 |
|
|
804 |
return kring; |
return kring; |
805 |
} |
} |