stuff
[oweals/gnunet.git] / src / transport / plugin_transport_http.c
index 93001beec2b7d48fcdcacbda11a1d52ba7688b57..e63549784728e1842e1920f04f4d1feff41e9cd8 100644 (file)
@@ -2613,7 +2613,7 @@ http_plugin_send (void *cls,
          ps->send_force_disconnect = GNUNET_NO;
          ps->pending_msgs_head = NULL;
          ps->pending_msgs_tail = NULL;
-         ps->peercontext=pc;
+         ps->peercontext = pc;
          ps->session_id = pc->session_id_counter;
          ps->queue_length_cur = 0;
          ps->queue_length_max = GNUNET_SERVER_MAX_MESSAGE_SIZE;
@@ -3154,23 +3154,6 @@ tcp_nat_port_map_callback (void *cls,
   }
 }
 
-#if 0
-/**
- * Notify transport service about address
- *
- * @param cls the plugin
- * @param tc unused
- */
-static void
-address_notification (void *cls,
-                    const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct Plugin *plugin = cls;
-
-  GNUNET_OS_network_interfaces_list (&process_interfaces, plugin);
-}
-#endif
-
 /**
  * Exit point from the plugin.
  */
@@ -3499,54 +3482,56 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
 
   if ( (plugin->key==NULL) || (plugin->cert==NULL) )
     {
-      char * cmd;
-      int ret = 0;
+      struct GNUNET_OS_Process *certcreation;
 
       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);
+#if DEBUG_HTTP
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "No usable TLS certificate found, creating certificate\n");
-      ret = system(cmd);
-      if (ret != 0)
+#endif
+      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) 
        {
          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' could not be started!\n"));
          GNUNET_free (key_file);
          GNUNET_free (cert_file);
          GNUNET_free (component_name);
-         LIBGNUNET_PLUGIN_TRANSPORT_DONE(api);
-         GNUNET_free (cmd);
+         LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
          return NULL;
        }
-      GNUNET_free (cmd);      
+      GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (certcreation));
+      GNUNET_OS_process_close (certcreation);
       plugin->key = load_certificate (key_file);
       plugin->cert = load_certificate (cert_file);
-      if ((plugin->key==NULL) || (plugin->cert==NULL))
-       {
-         GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
-                          "https",
-                          _("No usable TLS certificate found and creating one failed!\n"),
-                          "transport-https");
-         GNUNET_free (key_file);
-         GNUNET_free (cert_file);
-         GNUNET_free (component_name);   
-         LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
-         return NULL;
-       }
     }
+  if ( (plugin->key==NULL) || (plugin->cert==NULL) )
+    {
+      GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+                      "https",
+                      _("No usable TLS certificate found and creating one failed!\n"),
+                      "transport-https");
+      GNUNET_free (key_file);
+      GNUNET_free (cert_file);
+      GNUNET_free (component_name);      
+      LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
+      return NULL;
+    }    
   GNUNET_free (key_file);
   GNUNET_free (cert_file);
-  
-  GNUNET_assert((plugin->key!=NULL) && (plugin->cert!=NULL));
+#if DEBUG_HTTP
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
              "TLS certificate loaded\n");
+#endif
 #endif
 
   GNUNET_assert ((port > 0) && (port <= 65535));