Browse Source

Displaying all available attacks on qa --help command.

Michele Orrù 10 years ago
parent
commit
ef239b564c
3 changed files with 14 additions and 6 deletions
  1. 11 1
      src/cmdline.c
  2. 1 4
      src/qa.c
  3. 2 1
      src/questions/allquestions.c

+ 11 - 1
src/cmdline.c

@@ -14,7 +14,10 @@
 #include <string.h>
 #include <errno.h>
 
+#include <bsd/sys/queue.h>
+
 #include "qa/qa.h"
+#include "qa/questions/questions.h"
 
 /**
  * \brief Prints the usage message, then exit.
@@ -24,15 +27,20 @@
  */
 void usage(void)
 {
+  qa_question_t *q;
   static const char* help_message = "%s usage: %s"
     " [-r HOST:port | -f X509 | -R RSA]"
     " [-a ATTACK]"
     " \n\n"
     "If no argument is supplied, by default a public RSA key is expected "
-    "to be read from the standard input.\n";
+    "to be read from the standard input.\n\n"
+    "Available attacks: \n";
   fprintf(stderr, help_message,
           program_invocation_short_name,
           program_invocation_name);
+  LIST_FOREACH(q, &questions, qs)
+    fprintf(stderr, "%-10s\t\t%s\n", q->name, q->pretty_name);
+  fprintf(stderr, "\n");
 }
 
 void conflicting_args(void)
@@ -61,6 +69,8 @@ int main(int argc, char** argv)
     .attacks = NULL,
   };
 
+  QA_library_init();
+
   while ((opt=getopt_long(argc, argv,
                           short_options, long_options,
                           &option_index)) != -1)

+ 1 - 4
src/qa.c

@@ -105,10 +105,7 @@ qa_init(const struct qa_conf* conf)
   bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
   bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
 
-  QA_library_init();
-
-  if (!conf->attacks) select_all_questions();
-  else select_question(conf->attacks);
+  if (conf->attacks) select_question(conf->attacks);
   if (!questions.lh_first) error(EXIT_FAILURE, 0, "No valid question selected.");
 
   if (conf->src_type == REMOTE)

+ 2 - 1
src/questions/allquestions.c

@@ -28,6 +28,8 @@ void QA_library_init(void)
   MPI_Init(0 , NULL);
 #endif
 
+  select_all_questions();
+
 }
 
 /**
@@ -38,7 +40,6 @@ void select_question(const char *sq)
 {
   qa_question_t *q, *tmpq;
 
-  select_all_questions();
   assert(questions.lh_first);
 
   LIST_FOREACH_SAFE(q, &questions, qs, tmpq)