diff options
-rw-r--r-- | src/certtool-common.h | 1 | ||||
-rw-r--r-- | src/p11tool-args.def | 6 | ||||
-rw-r--r-- | src/p11tool.c | 2 | ||||
-rw-r--r-- | src/p11tool.h | 2 | ||||
-rw-r--r-- | src/pkcs11.c | 12 |
5 files changed, 19 insertions, 4 deletions
diff --git a/src/certtool-common.h b/src/certtool-common.h index 83377a33eb..de6586c7df 100644 --- a/src/certtool-common.h +++ b/src/certtool-common.h @@ -58,6 +58,7 @@ typedef struct common_info { int cprint; + unsigned int batch; unsigned int verbose; } common_info_st; diff --git a/src/p11tool-args.def b/src/p11tool-args.def index 6bf10fb00f..043e187944 100644 --- a/src/p11tool-args.def +++ b/src/p11tool-args.def @@ -290,6 +290,12 @@ flag = { doc = "This will override the default options in /etc/gnutls/pkcs11.conf"; }; +flag = { + name = batch; + descrip = "Disable all interaction with the tool. All parameters need to be specified on command line."; + doc = ""; +}; + doc-section = { ds-type = 'SEE ALSO'; diff --git a/src/p11tool.c b/src/p11tool.c index 72e8888df9..809383a902 100644 --- a/src/p11tool.c +++ b/src/p11tool.c @@ -246,7 +246,7 @@ static void cmd_parser(int argc, char **argv) } else if (HAVE_OPT(INITIALIZE)) pkcs11_init(outfile, url, label, &cinfo); else if (HAVE_OPT(DELETE)) - pkcs11_delete(outfile, url, 0, login, &cinfo); + pkcs11_delete(outfile, url, login, &cinfo); else if (HAVE_OPT(GENERATE_ECC)) { key_type = GNUTLS_PK_EC; pkcs11_generate(outfile, url, key_type, diff --git a/src/p11tool.h b/src/p11tool.h index c9e86e7647..ba2ef1bf36 100644 --- a/src/p11tool.h +++ b/src/p11tool.h @@ -44,7 +44,7 @@ void pkcs11_write(FILE * outfile, const char *pkcs11_url, const char *label, int trusted, int ca, int private, unsigned int login, common_info_st *); -void pkcs11_delete(FILE * outfile, const char *pkcs11_url, int batch, +void pkcs11_delete(FILE * outfile, const char *pkcs11_url, unsigned int login, common_info_st *); void pkcs11_init(FILE * outfile, const char *pkcs11_url, const char *label, common_info_st *); diff --git a/src/pkcs11.c b/src/pkcs11.c index 790567f4d7..08614d41d2 100644 --- a/src/pkcs11.c +++ b/src/pkcs11.c @@ -53,7 +53,7 @@ char *get_single_token_url(common_info_st * info); "warning: --login was not specified and it may be required for this operation.\n") void -pkcs11_delete(FILE * outfile, const char *url, int batch, +pkcs11_delete(FILE * outfile, const char *url, unsigned int login_flags, common_info_st * info) { int ret; @@ -61,7 +61,7 @@ pkcs11_delete(FILE * outfile, const char *url, int batch, if (login_flags) obj_flags = login_flags; - if (!batch) { + if (info->batch == 0) { pkcs11_list(outfile, url, PKCS11_TYPE_ALL, login_flags, GNUTLS_PKCS11_URL_LIB, info); ret = @@ -456,6 +456,10 @@ pkcs11_write(FILE * outfile, const char *url, const char *label, FIX(url, outfile, 0, info); CHECK_LOGIN_FLAG(login_flags); + if (label == NULL && info->batch == 0) { + label = read_str("warning: The object's label was not specified.\nLabel: "); + } + secret_key = load_secret_key(0, info); if (secret_key != NULL) { ret = @@ -543,6 +547,10 @@ pkcs11_generate(FILE * outfile, const char *url, gnutls_pk_algorithm_t pk, sleep(3); } + if (label == NULL && info->batch == 0) { + label = read_str("warning: Label was not specified.\nLabel: "); + } + if (private == 1) flags |= GNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE; else if (private == 0) |