# HG changeset patch # User Andre Heinecke # Date 1395402875 0 # Node ID bc1e6732f43c5f6f3d914157821cff21ccc2efbf # Parent 6090e673c707756d847eb89e9e9de251ac90ca0f Add specification and some cleanups diff -r 6090e673c707 -r bc1e6732f43c cinst/mozilla.c --- 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 #include +/* @file Mozilla installation process + * + * Reads from stdin a list of instructions in the form: + * + * I:\r\n + * R:\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;