aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-transport-certificate-creation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-02 08:52:16 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-02 08:52:16 +0000
commit965295ecfb2b5aba301f7404d3f8442f034d42ea (patch)
tree0cbc4f7a6358863de56b329f8fbd00e8b21534f3 /src/transport/gnunet-transport-certificate-creation.c
parent9c4861364111fa25f4f7884b9f3b8cc0d52daa8e (diff)
downloadgnunet-965295ecfb2b5aba301f7404d3f8442f034d42ea.tar.gz
gnunet-965295ecfb2b5aba301f7404d3f8442f034d42ea.zip
fix double-waitpid here too
Diffstat (limited to 'src/transport/gnunet-transport-certificate-creation.c')
-rw-r--r--src/transport/gnunet-transport-certificate-creation.c52
1 files changed, 8 insertions, 44 deletions
diff --git a/src/transport/gnunet-transport-certificate-creation.c b/src/transport/gnunet-transport-certificate-creation.c
index 22d3d08f9..258c9e69a 100644
--- a/src/transport/gnunet-transport-certificate-creation.c
+++ b/src/transport/gnunet-transport-certificate-creation.c
@@ -35,12 +35,12 @@ removecerts (const char *file1,
35{ 35{
36 if (GNUNET_DISK_file_test (file1) == GNUNET_YES) 36 if (GNUNET_DISK_file_test (file1) == GNUNET_YES)
37 { 37 {
38 CHMOD (file1, 0777); 38 CHMOD (file1, S_IWUSR | S_IRUSR);
39 REMOVE (file1); 39 REMOVE (file1);
40 } 40 }
41 if (GNUNET_DISK_file_test (file2) == GNUNET_YES) 41 if (GNUNET_DISK_file_test (file2) == GNUNET_YES)
42 { 42 {
43 CHMOD (file2, 0777); 43 CHMOD (file2, S_IWUSR | S_IRUSR);
44 REMOVE (file2); 44 REMOVE (file2);
45 } 45 }
46} 46}
@@ -50,13 +50,11 @@ int
50main (int argc, char **argv) 50main (int argc, char **argv)
51{ 51{
52 struct GNUNET_OS_Process *openssl; 52 struct GNUNET_OS_Process *openssl;
53 enum GNUNET_OS_ProcessStatusType status_type;
54 unsigned long code;
55 53
56 if (argc != 3) 54 if (argc != 3)
57 return 1; 55 return 1;
58 close (2); /* no output to stderr */
59 removecerts (argv[1], argv[2]); 56 removecerts (argv[1], argv[2]);
57 close (2); /* eliminate stderr */
60 /* Create RSA Private Key */ 58 /* Create RSA Private Key */
61 /* openssl genrsa -out $1 1024 2> /dev/null */ 59 /* openssl genrsa -out $1 1024 2> /dev/null */
62 openssl = GNUNET_OS_start_process (NULL, NULL, 60 openssl = GNUNET_OS_start_process (NULL, NULL,
@@ -66,24 +64,7 @@ main (int argc, char **argv)
66 NULL); 64 NULL);
67 if (openssl == NULL) 65 if (openssl == NULL)
68 return 2; 66 return 2;
69 if (GNUNET_OS_process_wait (openssl) != GNUNET_OK) 67 GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK);
70 {
71 GNUNET_OS_process_kill (openssl, SIGTERM);
72 removecerts (argv[1], argv[2]);
73 return 3;
74 }
75 if (GNUNET_OS_process_status (openssl, &status_type, &code) != GNUNET_OK)
76 {
77 GNUNET_OS_process_kill (openssl, SIGTERM);
78 removecerts (argv[1], argv[2]);
79 return 4;
80 }
81 if (status_type != GNUNET_OS_PROCESS_EXITED || code != 0)
82 {
83 GNUNET_OS_process_kill (openssl, SIGTERM);
84 removecerts (argv[1], argv[2]);
85 return 5;
86 }
87 GNUNET_OS_process_close (openssl); 68 GNUNET_OS_process_close (openssl);
88 69
89 /* Create a self-signed certificate in batch mode using rsa key*/ 70 /* Create a self-signed certificate in batch mode using rsa key*/
@@ -95,28 +76,11 @@ main (int argc, char **argv)
95 "-out", argv[2], "-new", "-x509", "-key", argv[1], 76 "-out", argv[2], "-new", "-x509", "-key", argv[1],
96 NULL); 77 NULL);
97 if (openssl == NULL) 78 if (openssl == NULL)
98 return 6; 79 return 3;
99 if (GNUNET_OS_process_wait (openssl) != GNUNET_OK) 80 GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK);
100 {
101 GNUNET_OS_process_kill (openssl, SIGTERM);
102 removecerts (argv[1], argv[2]);
103 return 7;
104 }
105 if (GNUNET_OS_process_status (openssl, &status_type, &code) != GNUNET_OK)
106 {
107 GNUNET_OS_process_kill (openssl, SIGTERM);
108 removecerts (argv[1], argv[2]);
109 return 8;
110 }
111 if (status_type != GNUNET_OS_PROCESS_EXITED || code != 0)
112 {
113 GNUNET_OS_process_kill (openssl, SIGTERM);
114 removecerts (argv[1], argv[2]);
115 return 9;
116 }
117 GNUNET_OS_process_close (openssl); 81 GNUNET_OS_process_close (openssl);
118 CHMOD (argv[1], 0400); 82 CHMOD (argv[1], S_IRUSR);
119 CHMOD (argv[2], 0400); 83 CHMOD (argv[2], S_IRUSR);
120 return 0; 84 return 0;
121} 85}
122 86