aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-transport-certificate-creation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-07-25 08:46:49 +0000
committerChristian Grothoff <christian@grothoff.org>2012-07-25 08:46:49 +0000
commite60a9052ae5d2211611e27f4ba86026e4dd1ccd6 (patch)
tree7111f9847d95977b39d75053a1c51cadbbfa2565 /src/transport/gnunet-transport-certificate-creation.c
parentf4e5b024d1ef21ecad101dd3a3c65e6144d5fc65 (diff)
downloadgnunet-e60a9052ae5d2211611e27f4ba86026e4dd1ccd6.tar.gz
gnunet-e60a9052ae5d2211611e27f4ba86026e4dd1ccd6.zip
-check return values
Diffstat (limited to 'src/transport/gnunet-transport-certificate-creation.c')
-rw-r--r--src/transport/gnunet-transport-certificate-creation.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/transport/gnunet-transport-certificate-creation.c b/src/transport/gnunet-transport-certificate-creation.c
index f7deb1206..5ecc7de42 100644
--- a/src/transport/gnunet-transport-certificate-creation.c
+++ b/src/transport/gnunet-transport-certificate-creation.c
@@ -22,7 +22,6 @@
22 * @file transport/gnunet-transport-certificate-creation.c 22 * @file transport/gnunet-transport-certificate-creation.c
23 * @brief create certificate for HTTPS transport 23 * @brief create certificate for HTTPS transport
24 * @author LRN 24 * @author LRN
25 *
26 */ 25 */
27#include "platform.h" 26#include "platform.h"
28#include "gnunet_disk_lib.h" 27#include "gnunet_disk_lib.h"
@@ -32,15 +31,19 @@
32static void 31static void
33removecerts (const char *file1, const char *file2) 32removecerts (const char *file1, const char *file2)
34{ 33{
35 if (GNUNET_DISK_file_test (file1) == GNUNET_YES) 34 if (GNUNET_YES == GNUNET_DISK_file_test (file1))
36 { 35 {
37 CHMOD (file1, S_IWUSR | S_IRUSR); 36 if (0 != CHMOD (file1, S_IWUSR | S_IRUSR))
38 REMOVE (file1); 37 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "chmod", file1);
38 if (0 != REMOVE (file1))
39 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "remove", file1);
39 } 40 }
40 if (GNUNET_DISK_file_test (file2) == GNUNET_YES) 41 if (GNUNET_YES == GNUNET_DISK_file_test (file2))
41 { 42 {
42 CHMOD (file2, S_IWUSR | S_IRUSR); 43 if (0 != CHMOD (file2, S_IWUSR | S_IRUSR))
43 REMOVE (file2); 44 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "chmod", file2);
45 if (0 != REMOVE (file2))
46 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "remove", file2);
44 } 47 }
45} 48}
46 49
@@ -50,7 +53,7 @@ main (int argc, char **argv)
50{ 53{
51 struct GNUNET_OS_Process *openssl; 54 struct GNUNET_OS_Process *openssl;
52 55
53 if (argc != 3) 56 if (3 != argc)
54 return 1; 57 return 1;
55 removecerts (argv[1], argv[2]); 58 removecerts (argv[1], argv[2]);
56 (void) close (2); /* eliminate stderr */ 59 (void) close (2); /* eliminate stderr */
@@ -59,9 +62,9 @@ main (int argc, char **argv)
59 openssl = 62 openssl =
60 GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "openssl", "openssl", "genrsa", 63 GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "openssl", "openssl", "genrsa",
61 "-out", argv[1], "1024", NULL); 64 "-out", argv[1], "1024", NULL);
62 if (openssl == NULL) 65 if (NULL == openssl)
63 return 2; 66 return 2;
64 GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK); 67 GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (openssl));
65 GNUNET_OS_process_destroy (openssl); 68 GNUNET_OS_process_destroy (openssl);
66 69
67 /* Create a self-signed certificate in batch mode using rsa key */ 70 /* Create a self-signed certificate in batch mode using rsa key */
@@ -70,12 +73,14 @@ main (int argc, char **argv)
70 GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "openssl", "openssl", "req", 73 GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "openssl", "openssl", "req",
71 "-batch", "-days", "365", "-out", argv[2], 74 "-batch", "-days", "365", "-out", argv[2],
72 "-new", "-x509", "-key", argv[1], NULL); 75 "-new", "-x509", "-key", argv[1], NULL);
73 if (openssl == NULL) 76 if (NULL == openssl)
74 return 3; 77 return 3;
75 GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK); 78 GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (openssl));
76 GNUNET_OS_process_destroy (openssl); 79 GNUNET_OS_process_destroy (openssl);
77 CHMOD (argv[1], S_IRUSR); 80 if (0 != CHMOD (argv[1], S_IRUSR))
78 CHMOD (argv[2], S_IRUSR); 81 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "chmod", argv[1]);
82 if (0 != CHMOD (argv[2], S_IRUSR))
83 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "chmod", argv[2]);
79 return 0; 84 return 0;
80} 85}
81 86