diff options
Diffstat (limited to 'sm')
-rw-r--r-- | sm/ChangeLog | 5 | ||||
-rw-r--r-- | sm/gpgsm.c | 25 | ||||
-rw-r--r-- | sm/keydb.c | 14 | ||||
-rw-r--r-- | sm/keydb.h | 3 |
4 files changed, 38 insertions, 9 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog index cb7e98712..90396e8ed 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,3 +1,8 @@ +2006-09-18 Werner Koch <wk@g10code.com> + + * gpgsm.c (main): Use this to import standard certificates. + * keydb.c (keydb_add_resource): New arg AUTO_CREATED. + 2006-09-14 Werner Koch <wk@g10code.com> Replaced all call gpg_error_from_errno(errno) by diff --git a/sm/gpgsm.c b/sm/gpgsm.c index 49a56cd7c..f7b2c7aed 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -1299,10 +1299,29 @@ main ( int argc, char **argv) if (!cmd && opt.fingerprint && !with_fpr) set_cmd (&cmd, aListKeys); - if (!nrings && default_keyring) /* add default keybox */ - keydb_add_resource ("pubring.kbx", 0, 0); + if (!nrings && default_keyring) /* Add default keybox. */ + { + int created; + + keydb_add_resource ("pubring.kbx", 0, 0, &created); + if (created) + { + /* Import the standard certificates for a new default keybox. */ + char *filelist[2]; + + filelist[0] = make_filename (GNUPG_DATADIR, "com-certs.pem", NULL); + filelist[1] = NULL; + if (!access (filelist[0], F_OK)) + { + log_info (_("importing common certificates `%s'\n"), + filelist[0]); + gpgsm_import_files (&ctrl, 1, filelist, open_read); + } + xfree (filelist[0]); + } + } for (sl = nrings; sl; sl = sl->next) - keydb_add_resource (sl->d, 0, 0); + keydb_add_resource (sl->d, 0, 0, NULL); FREE_STRLIST(nrings); if (!do_not_setup_keys) diff --git a/sm/keydb.c b/sm/keydb.c index 3fc7d31b9..8ba1287fc 100644 --- a/sm/keydb.c +++ b/sm/keydb.c @@ -71,13 +71,12 @@ static void unlock_all (KEYDB_HANDLE hd); /* * Register a resource (which currently may only be a keybox file). - * The first keybox which is added by this function is - * created if it does not exist. - * Note: this function may be called before secure memory is - * available. + * The first keybox which is added by this function is created if it + * does not exist. If AUTO_CREATED is not NULL it will be set to true + * if the function has created a a new keybox. */ int -keydb_add_resource (const char *url, int force, int secret) +keydb_add_resource (const char *url, int force, int secret, int *auto_created) { static int any_secret, any_public; const char *resname = url; @@ -87,6 +86,9 @@ keydb_add_resource (const char *url, int force, int secret) KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE; const char *created_fname = NULL; + if (auto_created) + *auto_created = 0; + /* Do we have an URL? gnupg-kbx:filename := this is a plain keybox filename := See what is is, but create as plain keybox. @@ -195,6 +197,8 @@ keydb_add_resource (const char *url, int force, int secret) if (!opt.quiet) log_info (_("keybox `%s' created\n"), filename); created_fname = filename; + if (auto_created) + *auto_created = 1; } fclose (fp); fp = NULL; diff --git a/sm/keydb.h b/sm/keydb.h index 814ae9f1e..a6a6f3c29 100644 --- a/sm/keydb.h +++ b/sm/keydb.h @@ -33,7 +33,8 @@ typedef struct keydb_handle *KEYDB_HANDLE; /*-- keydb.c --*/ -int keydb_add_resource (const char *url, int force, int secret); +int keydb_add_resource (const char *url, int force, int secret, + int *auto_created); KEYDB_HANDLE keydb_new (int secret); void keydb_release (KEYDB_HANDLE hd); int keydb_set_ephemeral (KEYDB_HANDLE hd, int yes); |