changeset 99:bc1e6732f43c

Add specification and some cleanups
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 21 Mar 2014 11:54:35 +0000
parents 6090e673c707
children 8fa273791242
files cinst/mozilla.c
diffstat 1 files changed, 33 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/cinst/mozilla.c	Fri Mar 21 10:50:01 2014 +0000
+++ b/cinst/mozilla.c	Fri Mar 21 11:54:35 2014 +0000
@@ -7,6 +7,37 @@
 #include <fcntl.h>
 #include <errno.h>
 
+/* @file Mozilla installation process
+ *
+ * Reads from stdin a list of instructions in the form:
+ *
+ * I:<base64 DER econded certificate>\r\n
+ * R:<base64 DER econded certificate>\r\n
+ * ...
+ *
+ * The maximum size of an input line is 1000 characters
+ * (including the \r\n) at the end of the line.
+ *
+ * Certificates marked with I: will be installed and the ones
+ * marked with R: will be searched and if available removed from
+ * the databases.
+ *
+ * This tool tries to find all NSS databases the user has
+ * access to and to execute the instructions on all of them.
+ *
+ * If there are other processes accessing the databases the caller
+ * has to ensure that those are terminated before this process is
+ * executed.
+ *
+ * Returns 0 on success (Even when no stores where found) an error value
+ * as defined in errorcodes.h otherwise.
+ *
+ * Success messages are written to stdout. Errors to stderr. For logging
+ * purposes each installation / removal of a certificate will be reported
+ * with the profile name that it modified.
+ *
+ */
+
 /* @brief IniParser for mozilla profiles.ini
  *
  * Parse data to find values formed in 
@@ -44,6 +75,8 @@
 int readFile(const char *fileName, char **data, size_t *size,
              const size_t maxSize)
 {
+    /* TODO
+     * split out the read file from common/listutil.c and use that. */
     int fd = -1;
     struct stat fileStat;
     int rc = 0;
@@ -54,28 +87,24 @@
 
     fd = open(fileName, O_RDONLY);
     if (fd == -1) {
-        printf("Error: %s \n", strerror(errno));
         retval = RAF_UNREADABLE;
         goto cleanup;
     }
 
     rc = fstat(fd, &fileStat);
     if (rc < 0) {
-        printf ("Stat failed with rc: %i\n", rc);
         retval = RAF_STATFAILED;
         goto cleanup;
     }
 
     // Check the size of the file
     if (!fileStat.st_size) {
-        printf("Size zero\n");
         retval = RAF_STATFAILED;
         goto cleanup;
     }
 
     if (fileStat.st_size > maxSize &&
             fileStat.st_size > 0) {
-        printf("File too large\n");
         retval = RAF_TOOLARGE;
         goto cleanup;
     }
@@ -92,7 +121,6 @@
     bRead = read(fd, *data, *size);
 
     if (bRead < 0 || (size_t) bRead != *size) {
-        printf("Read failed\n");
         if (bRead == -1) {
             printf("Error: %s \n", strerror(errno));
         }
@@ -100,7 +128,6 @@
         *size = 0;
         if (*data) {
             free(*data);
-            printf("Nulling data\n");
             *data = NULL;
         }
         goto cleanup;

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