diff cinst/main.c @ 382:124f08a85532

Rename instructions to choices
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 15 Apr 2014 17:46:16 +0200
parents 5fa58979cb3a
children 17e1c8f37d72
line wrap: on
line diff
--- a/cinst/main.c	Tue Apr 15 14:15:21 2014 +0200
+++ b/cinst/main.c	Tue Apr 15 17:46:16 2014 +0200
@@ -9,18 +9,18 @@
  *
  *  The first parameter to this process should be list=<file_name>
  *  of the certificate list to work on. The second parameter should
- *  be instruction=<instruction_file_name>|uninstall
+ *  be choices=<choices_file_name>|uninstall
  *
- *  instruction_file_name should be the absolute path to an
- *  instructions file formatted as:
+ *  choices_file_name should be the absolute path to an
+ *  choices file formatted as:
  *
  *  I:<certificate>
  *  R:<certificate>
  *
- *  Line breaks can be system dependent in the Instructions file.
+ *  Line breaks can be system dependent in the Choices file.
  *
- *  It will only execute the instructions if the
- *  I and R instructions are also part of the signed
+ *  It will only execute the choices if the
+ *  I and R choices are also part of the signed
  *  certificate list. The signature is validated with the
  *  built in key.
  *
@@ -42,17 +42,17 @@
 #include "windowsstore.h"
 #include "nssstore.h"
 
-/* The certificate list + instructions may only be so long as
+/* The certificate list + choices may only be so long as
  * twice the accepted certificatelist size */
 #define MAX_INPUT_SIZE MAX_LINE_LENGTH * MAX_LINES * 2
 
 /* @brief Read stdin into data structures.
  *
- * Reads instructions from an input file into the to_install
+ * Reads choices from an input file into the to_install
  * and to_remove buffers.
  *
- * Lines starting with I: are treated as install instructions.
- * Lines starting with R: are treated as remove instructions.
+ * Lines starting with I: are treated as install choices.
+ * Lines starting with R: are treated as remove choices.
  * Other lines are ignored.
  *
  * Terminates in OOM conditions.
@@ -60,14 +60,14 @@
  * The caller needs to free the memory allocated by this function
  * even when an error is returned.
  *
- * @param[in] file_name absolute path to the instructions file.
- * @param[out] to_install strv of installation instructions or NULL
- * @param[out] to_remove strv of remove instructions or NULL
+ * @param[in] file_name absolute path to the choices file.
+ * @param[out] to_install strv of installation choices or NULL
+ * @param[out] to_remove strv of remove choices or NULL
  *
  * @returns: 0 on success. An error code otherwise.
  */
 static int
-read_instructions_file (char *file_name, char ***to_install,
+read_choices_file (char *file_name, char ***to_install,
                         char ***to_remove)
 {
   int lines_read = 0;
@@ -144,12 +144,12 @@
  * for installation.
  *
  * @param[in] all_certs strv of all valid certificates in a list
- * @param[in] to_validate strv of instructions
+ * @param[in] to_validate strv of choices
  *
  * @returns 0 on success, an error otherwise
  */
 int
-validate_instructions (char **all_certs, char **to_validate)
+validate_choices (char **all_certs, char **to_validate)
 {
   int i = 0, j = 0;
 
@@ -199,38 +199,38 @@
 
   char *certificate_list = NULL,
        *certificate_file_name = NULL,
-       *instruction_file_name = NULL;
+       *choices_file_name = NULL;
   size_t list_len = 0;
   list_status_t list_status;
   bool do_uninstall = false;
 
-  /* Some very static argument parsing. list= and instructions= is only
+  /* Some very static argument parsing. list= and choices= is only
      added to make it more transparent how this programm is called if
      a user looks at the detailed uac dialog. */
   if (argc != 3 || strncmp(argv[1], "list=", 5) != 0 ||
-                   strncmp(argv[2], "instructions=", 13) != 0)
+                   strncmp(argv[2], "choices=", 8) != 0)
     {
       ERRORPRINTF ("Invalid arguments.\n"
                    "Expected arguments: list=<certificate_list> \n"
-                   "                    instructions=<instructions_file>|uninstall\n");
+                   "                    choices=<choices_file>|uninstall\n");
       return ERR_INVALID_PARAMS;
     }
 
   certificate_file_name = strchr(argv[1], '=') + 1;
-  instruction_file_name = strchr(argv[2], '=') + 1;
+  choices_file_name = strchr(argv[2], '=') + 1;
 
-  if (!certificate_file_name || !instruction_file_name)
+  if (!certificate_file_name || !choices_file_name)
     {
       ERRORPRINTF ("Invalid arguments.\n"
                    "Expected arguments: list=<certificate_list> \n"
-                   "                    instructions=<instructions_file>|uninstall\n");
+                   "                    choices=<choices_file>|uninstall\n");
       return ERR_INVALID_PARAMS;
     }
 
-  if (strncmp(instruction_file_name, "uninstall", 9) == 0)
+  if (strncmp(choices_file_name, "uninstall", 9) == 0)
     {
       do_uninstall = true;
-      instruction_file_name = NULL;
+      choices_file_name = NULL;
     }
 
   list_status = read_and_verify_list (certificate_file_name, &certificate_list,
@@ -240,9 +240,11 @@
     {
       if (list_status == InvalidSignature)
         {
+          ERRORPRINTF ("Failed to verify signature.\n");
           return ERR_INVALID_SIGNATURE;
         }
 
+      ERRORPRINTF ("Failed to read certificate list.\n");
       return ERR_INVALID_INPUT_NO_LIST;
     }
 
@@ -269,34 +271,38 @@
       return ret;
     }
 
-  ret = read_instructions_file (instruction_file_name, &to_install,
+  ret = read_choices_file (choices_file_name, &to_install,
                                 &to_remove);
 
   if (ret)
     {
+      ERRORPRINTF ("Failed to read choices file\n");
       return ret;
     }
 
   if (!strv_length (to_install) && !strv_length (to_remove) )
     {
+      ERRORPRINTF ("Failed to read choices file\n");
       return ERR_NO_INSTRUCTIONS;
     }
 
-  /* Check that the instructions are ok to execute */
+  /* Check that the choices are ok to execute */
   if (to_install)
     {
-      ret = validate_instructions (all_valid_certs, to_install);
+      ret = validate_choices (all_valid_certs, to_install);
       if (ret)
         {
+          ERRORPRINTF ("Failed to validate choices\n");
           return ret;
         }
     }
 
   if (to_remove)
     {
-      ret = validate_instructions (all_valid_certs, to_remove);
+      ret = validate_choices (all_valid_certs, to_remove);
       if (ret)
         {
+          ERRORPRINTF ("Failed to validate removal choices\n");
           return ret;
         }
     }
@@ -312,6 +318,7 @@
   if (ret != 0)
     {
       ERRORPRINTF ("Failed to write nss stores");
+      DEBUGPRINTF ("Hello World");
     }
 
   /* Make valgrind happy */

http://wald.intevation.org/projects/trustbridge/