From 7be0774cf280a6c07976883a3e75bbf229b84420 Mon Sep 17 00:00:00 2001 From: okir Date: Thu, 9 Jan 2003 09:14:15 +0000 Subject: [PATCH] - learn_card: the cache directory is now created by libopensc git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@852 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/tools/pkcs15-tool.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/tools/pkcs15-tool.c b/src/tools/pkcs15-tool.c index ffe0a890..146b51d8 100644 --- a/src/tools/pkcs15-tool.c +++ b/src/tools/pkcs15-tool.c @@ -21,6 +21,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include #include #include "util.h" @@ -693,8 +694,7 @@ int read_and_cache_file(const struct sc_path *path) int learn_card(void) { - struct stat stbuf; - char dir[120]; + char dir[PATH_MAX]; int r, i, cert_count; struct sc_pkcs15_object *certs[32]; struct sc_pkcs15_df *df; @@ -704,15 +704,7 @@ int learn_card(void) fprintf(stderr, "Unable to find cache directory: %s\n", sc_strerror(r)); return 1; } - r = stat(dir, &stbuf); - if (r) { - printf("No '%s' directory found, creating...\n", dir); - r = mkdir(dir, 0700); - if (r) { - perror("Directory creation failed"); - return 1; - } - } + printf("Using cache directory '%s'.\n", dir); r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_CERT_X509, certs, 32); if (r < 0) { @@ -730,6 +722,9 @@ int learn_card(void) fprintf(stderr, "PIN code enumeration failed: %s\n", sc_strerror(r)); return 1; } + + /* Cache all relevant DF files. The cache + * directory is created automatically. */ for (df = p15card->df_list; df != NULL; df = df->next) read_and_cache_file(&df->path); printf("Caching %d certificate(s)...\n", cert_count);