From: Christian Grothoff Date: Mon, 1 Aug 2011 20:38:50 +0000 (+0000) Subject: LRN: Let gnunet-transport-certificate-creation be a program X-Git-Tag: initial-import-from-subversion-38251~17554 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3de7831182e144ea960326e5efaaf1447d5e5ae9;p=oweals%2Fgnunet.git LRN: Let gnunet-transport-certificate-creation be a program --- diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 2ce2a48be..06f09e227 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -62,6 +62,11 @@ UNIX_QUOTA_TEST = test_quota_compliance_unix \ test_quota_compliance_unix_asymmetric_recv_constant endif +<<<<<<< HEAD +======= +noinst_PROGRAMS = ${check_PROGRAMS} gnunet-transport-certificate-creation + +>>>>>>> Let gnunet-transport-certificate-creation be a program lib_LTLIBRARIES = \ libgnunettransport.la @@ -83,15 +88,20 @@ bin_PROGRAMS = \ gnunet-transport \ $(WLAN_BIN) \ gnunet-service-transport \ - gnunet-transport-list-connections + gnunet-transport-list-connections \ + gnunet-transport-certificate-creation #noinst_PROGRAMS = ${check_PROGRAMS} noinst_PROGRAMS = \ $(WLAN_BIN_DUMMY) -bin_SCRIPTS = \ - gnunet-transport-certificate-creation +#bin_SCRIPTS = \ +# gnunet-transport-certificate-creation +gnunet_transport_certificate_creation_SOURCES = \ + gnunet-transport-certificate-creation.c +gnunet_transport_certificate_creation_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la gnunet_transport_wlan_helper_SOURCES = \ wlan/byteorder.h \ 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) if ( (plugin->key==NULL) || (plugin->cert==NULL) ) { - char * cmd; + struct GNUNET_OS_Process *certcreation = NULL; + enum GNUNET_OS_ProcessStatusType status_type = GNUNET_OS_PROCESS_UNKNOWN; + unsigned long code = 0; int ret = 0; GNUNET_free_non_null (plugin->key); plugin->key = NULL; GNUNET_free_non_null (plugin->cert); plugin->cert = NULL; - GNUNET_asprintf(&cmd, - "gnunet-transport-certificate-creation %s %s", - key_file, cert_file); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No usable TLS certificate found, creating certificate\n"); - ret = system(cmd); - if (ret != 0) + errno = 0; + certcreation = GNUNET_OS_start_process (NULL, NULL, "gnunet-transport-certificate-creation", "gnunet-transport-certificate-creation", key_file, cert_file, NULL); + if (certcreation == NULL + || (ret = 1) != 1 || GNUNET_OS_process_wait (certcreation) != GNUNET_OK + || (ret = 2) != 2 || (GNUNET_OS_process_status (certcreation, &status_type, &code) != GNUNET_OK + || (ret = 3) != 3 || status_type != GNUNET_OS_PROCESS_EXITED + || (ret = 4) != 4 || code != 0)) { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https", - _("Could not create a new TLS certificate, shell script `%s' failed!\n"), - cmd); + _("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"), + errno, ret, status_type, code); GNUNET_free (key_file); GNUNET_free (cert_file); GNUNET_free (component_name); + if (certcreation != NULL) + { + GNUNET_OS_process_kill (certcreation, SIGTERM); + GNUNET_OS_process_close (certcreation); + } LIBGNUNET_PLUGIN_TRANSPORT_DONE(api); - GNUNET_free (cmd); return NULL; } - GNUNET_free (cmd); + GNUNET_OS_process_close (certcreation); + plugin->key = load_certificate (key_file); plugin->cert = load_certificate (cert_file); if ((plugin->key==NULL) || (plugin->cert==NULL))