]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
p11tool: Ask for label if not specified.
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 2 Jul 2014 11:26:58 +0000 (13:26 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 2 Jul 2014 11:29:39 +0000 (13:29 +0200)
Added --batch parameter to disable interaction.

src/certtool-common.h
src/p11tool-args.def
src/p11tool.c
src/p11tool.h
src/pkcs11.c

index 83377a33eb4d8dfa32a3bd305355c07c3d219767..de6586c7df3d2984cfe9a7af0dab9294ed9bec2c 100644 (file)
@@ -58,6 +58,7 @@ typedef struct common_info {
 
        int cprint;
 
+       unsigned int batch;
        unsigned int verbose;
 } common_info_st;
 
index 6bf10fb00f22f5a8d72865bf806f481deda3bd25..043e18794479dca33b7fd57869cb0bbc3ae76ba0 100644 (file)
@@ -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';
index 72e8888df9bf46ef01f84272731c6377584418e4..809383a90280bccc8f3a4a6aa18653664bab62d7 100644 (file)
@@ -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,
index c9e86e7647c7844f28dce041e3067e01b3c38f66..ba2ef1bf363fe03d5bd584e5775d48424b3fc0af 100644 (file)
@@ -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 *);
index 790567f4d7862cd7289215157fdfe4694480b744..08614d41d247ff8de3050f23fb5e574ac4e675ac 100644 (file)
@@ -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)