aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-01 20:38:50 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-01 20:38:50 +0000
commit3de7831182e144ea960326e5efaaf1447d5e5ae9 (patch)
tree7360cdef5390c2647f60a020e0f080631025912d /src/transport/plugin_transport_http.c
parent61f69bf367cf87c4de51b2244d50c62bc941a8c3 (diff)
downloadgnunet-3de7831182e144ea960326e5efaaf1447d5e5ae9.tar.gz
gnunet-3de7831182e144ea960326e5efaaf1447d5e5ae9.zip
LRN: Let gnunet-transport-certificate-creation be a program
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r--src/transport/plugin_transport_http.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 1c578d3f6..955b622b7 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -3482,33 +3482,42 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3482 3482
3483 if ( (plugin->key==NULL) || (plugin->cert==NULL) ) 3483 if ( (plugin->key==NULL) || (plugin->cert==NULL) )
3484 { 3484 {
3485 char * cmd; 3485 struct GNUNET_OS_Process *certcreation = NULL;
3486 enum GNUNET_OS_ProcessStatusType status_type = GNUNET_OS_PROCESS_UNKNOWN;
3487 unsigned long code = 0;
3486 int ret = 0; 3488 int ret = 0;
3487 3489
3488 GNUNET_free_non_null (plugin->key); 3490 GNUNET_free_non_null (plugin->key);
3489 plugin->key = NULL; 3491 plugin->key = NULL;
3490 GNUNET_free_non_null (plugin->cert); 3492 GNUNET_free_non_null (plugin->cert);
3491 plugin->cert = NULL; 3493 plugin->cert = NULL;
3492 GNUNET_asprintf(&cmd,
3493 "gnunet-transport-certificate-creation %s %s",
3494 key_file, cert_file);
3495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3494 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3496 "No usable TLS certificate found, creating certificate\n"); 3495 "No usable TLS certificate found, creating certificate\n");
3497 ret = system(cmd); 3496 errno = 0;
3498 if (ret != 0) 3497 certcreation = GNUNET_OS_start_process (NULL, NULL, "gnunet-transport-certificate-creation", "gnunet-transport-certificate-creation", key_file, cert_file, NULL);
3498 if (certcreation == NULL
3499 || (ret = 1) != 1 || GNUNET_OS_process_wait (certcreation) != GNUNET_OK
3500 || (ret = 2) != 2 || (GNUNET_OS_process_status (certcreation, &status_type, &code) != GNUNET_OK
3501 || (ret = 3) != 3 || status_type != GNUNET_OS_PROCESS_EXITED
3502 || (ret = 4) != 4 || code != 0))
3499 { 3503 {
3500 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 3504 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
3501 "https", 3505 "https",
3502 _("Could not create a new TLS certificate, shell script `%s' failed!\n"), 3506 _("Could not create a new TLS certificate, program `gnunet-transport-certificate-creation' failed with errno %d, if-code %d, status %d, return value %d!\n"),
3503 cmd); 3507 errno, ret, status_type, code);
3504 GNUNET_free (key_file); 3508 GNUNET_free (key_file);
3505 GNUNET_free (cert_file); 3509 GNUNET_free (cert_file);
3506 GNUNET_free (component_name); 3510 GNUNET_free (component_name);
3511 if (certcreation != NULL)
3512 {
3513 GNUNET_OS_process_kill (certcreation, SIGTERM);
3514 GNUNET_OS_process_close (certcreation);
3515 }
3507 LIBGNUNET_PLUGIN_TRANSPORT_DONE(api); 3516 LIBGNUNET_PLUGIN_TRANSPORT_DONE(api);
3508 GNUNET_free (cmd);
3509 return NULL; 3517 return NULL;
3510 } 3518 }
3511 GNUNET_free (cmd); 3519 GNUNET_OS_process_close (certcreation);
3520
3512 plugin->key = load_certificate (key_file); 3521 plugin->key = load_certificate (key_file);
3513 plugin->cert = load_certificate (cert_file); 3522 plugin->cert = load_certificate (cert_file);
3514 if ((plugin->key==NULL) || (plugin->cert==NULL)) 3523 if ((plugin->key==NULL) || (plugin->cert==NULL))