changes for AGPL handling
authorChristian Grothoff <christian@grothoff.org>
Tue, 5 Jun 2018 22:32:36 +0000 (00:32 +0200)
committerChristian Grothoff <christian@grothoff.org>
Tue, 5 Jun 2018 22:32:36 +0000 (00:32 +0200)
README
src/include/gnunet_mq_lib.h
src/include/gnunet_protocols.h
src/include/gnunet_util_lib.h
src/util/mq.c
src/util/service.c

diff --git a/README b/README
index 80a87d274142d94785c64d665c631e9f4e359a36..61c54b4f42dbc87eae2b076c59d04ebd8172dd76 100644 (file)
--- a/README
+++ b/README
@@ -15,8 +15,11 @@ GNU package (http://www.gnu.org/).
 This is an ALPHA release.  There are known and significant bugs as
 well as many missing features in this release.
 
-GNUnet is free software released under the GNU General Public License
-(v3 or later). For details see the COPYING file in this directory.
+GNUnet is free software released under the GNU Affero General Public
+License (v3 or later). For details see the COPYING file in this
+directory.  If you fork this software, you MUST adjust GNUNET_AGPL_URL
+in src/include/gnunet_util_lib.h to point to the source code of your
+fork!
 
 Additional documentation about GNUnet can be found at
 https://gnunet.org/ and in the doc/ folder.
@@ -25,16 +28,9 @@ https://gnunet.org/ and in the doc/ folder.
 Dependencies:
 =============
 
-Please note that for many of its dependencies GNUnet requires very
-recent versions of the libraries which are often NOT to be found in
-stable distributions in 2014.  While using older packages may in some
-cases on some operating systems may seem to work in some limited
-fashion, we are in many cases aware of serious problems with older
-packages.  Hence please make sure to use  the versions listed below.
-
 These are the direct dependencies for running GNUnet:
 
-- libmicrohttpd >= 0.9.42
+- libmicrohttpd >= 0.9.52
 - libgcrypt     >= 1.6
 - libgnurl      >= 7.35.0 (available from https://gnunet.org/gnurl)
 - libunistring  >= 0.9.2
index fe699c48f0962c114ffe04e8f9d3ef4a8e47fbc9..daf1869fb5c574fb15a3275f1cc6b68a08ee007b 100644 (file)
@@ -339,6 +339,24 @@ struct GNUNET_MQ_MessageHandler *
 GNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers);
 
 
+/**
+ * Copy an array of handlers, appending AGPL handler.
+ *
+ * Useful if the array has been delared in local memory and needs to be
+ * persisted for future use.
+ *
+ * @param handlers Array of handlers to be copied. Can be NULL (nothing done).
+ * @param agpl_handler function to call for AGPL handling
+ * @param agpl_cls closure for @a agpl_handler
+ * @return A newly allocated array of handlers.
+ *         Needs to be freed with #GNUNET_free.
+ */
+struct GNUNET_MQ_MessageHandler *
+GNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers,
+                          GNUNET_MQ_MessageCallback agpl_handler,
+                          void *agpl_cls);
+
+
 /**
  * Count the handlers in a handler array.
  *
index 7040f2cbf519d276720cde1a4a7c950360cc4447..60dbeeb789e0d8cfaa58aa6d865ae6209952db32 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2001--2015 GNUnet e.V.
+     Copyright (C) 2001--2018 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -85,6 +85,21 @@ extern "C"
  */
 #define GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE 5
 
+/*******************************************************************************
+ * AGPL source code download
+ * *****************************************************************************/
+
+/**
+ * Message to request source code link.
+ */
+#define GNUNET_MESSAGE_TYPE_REQUEST_AGPL 6
+
+/**
+ * Source code link.
+ */
+#define GNUNET_MESSAGE_TYPE_RESPONSE_AGPL 7
+
+
 /*******************************************************************************
  * ARM message types
  ******************************************************************************/
index a9bd6c33fe6b4ac5744605c25a59b387199c57e1..e82e6caee9ddb6dc1460ebde35ea43dfd22bf825 100644 (file)
@@ -52,6 +52,14 @@ extern "C"
  */
 #define GNUNET_MIN_MESSAGE_SIZE sizeof (struct GNUNET_MessageHeader)
 
+/**
+ * NOTE: You MUST adjust this URL to point to the location of a
+ * publicly accessible repository (or TGZ) containing the sources of
+ * THIS release. Otherwise, you are violating the Affero GPL if you make
+ * this service available to anyone but yourself.
+ */
+#define GNUNET_AGPL_URL "https://gnunet.org/git/gnunet.git#" PACKAGE_VERSION;
+
 
 #include "gnunet_crypto_lib.h"
 #include "gnunet_bandwidth_lib.h"
index 81a42e0c68515d0e33fa8627a7f350490bd27920..bf8f9579062e4f0c98ca198d9c844b96184f4b94 100644 (file)
@@ -1215,6 +1215,43 @@ GNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers)
 }
 
 
+/**
+ * Copy an array of handlers, appending AGPL handler.
+ *
+ * Useful if the array has been delared in local memory and needs to be
+ * persisted for future use.
+ *
+ * @param handlers Array of handlers to be copied. Can be NULL (nothing done).
+ * @param agpl_handler function to call for AGPL handling
+ * @param agpl_cls closure for @a agpl_handler
+ * @return A newly allocated array of handlers.
+ *         Needs to be freed with #GNUNET_free.
+ */
+struct GNUNET_MQ_MessageHandler *
+GNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers,
+                          GNUNET_MQ_MessageCallback agpl_handler,
+                          void *agpl_cls)
+{
+  struct GNUNET_MQ_MessageHandler *copy;
+  unsigned int count;
+
+  if (NULL == handlers)
+    return NULL;
+  count = GNUNET_MQ_count_handlers (handlers);
+  copy = GNUNET_new_array (count + 2,
+                           struct GNUNET_MQ_MessageHandler);
+  GNUNET_memcpy (copy,
+                 handlers,
+                 count * sizeof (struct GNUNET_MQ_MessageHandler));
+  copy[count].mv = NULL;
+  copy[count].cb = agpl_handler;
+  copy[count].cls = agpl_cls;
+  copy[count].type = GNUNET_MESSAGE_TYPE_REQUEST_AGPL;
+  copy[count].expected_size = sizeof (struct GNUNET_MessageHeader);
+  return copy;
+}
+
+
 /**
  * Count the handlers in a handler array.
  *
index 1156093f4c4cce6e136e469d1187e2c6dda2c6fb..ae18099508c2564b7f23f39e32ce0316f0985c5a 100644 (file)
@@ -1571,6 +1571,36 @@ teardown_service (struct GNUNET_SERVICE_Handle *sh)
 }
 
 
+/**
+ * Function to return link to AGPL source upon request.
+ *
+ * @param cls closure with the identification of the client
+ * @param msg AGPL request
+ */
+static void
+return_agpl (void *cls,
+             const struct GNUNET_MessageHeader *msg)
+{
+  struct GNUNET_SERVICE_Client *client = cls;
+  struct GNUNET_MQ_Handle *mq;
+  struct GNUNET_MQ_Envelope *env;
+  struct GNUNET_MessageHeader *res;
+  size_t slen;
+
+  slen = strlen (GNUNET_AGPL_URL) + 1;
+  env = GNUNET_MQ_msg_extra (res,
+                             GNUNET_MESSAGE_TYPE_RESPONSE_AGPL,
+                             slen);
+  memcpy (&res[1],
+          GNUNET_AGPL_URL,
+          slen);
+  mq = GNUNET_SERVICE_client_get_mq (client);
+  GNUNET_MQ_send (mq,
+                 env);
+  GNUNET_SERVICE_client_continue (client);
+}
+
+
 /**
  * Low-level function to start a service if the scheduler
  * is already running.  Should only be used directly in
@@ -1623,7 +1653,9 @@ GNUNET_SERVICE_start (const char *service_name,
   sh->connect_cb = connect_cb;
   sh->disconnect_cb = disconnect_cb;
   sh->cb_cls = cls;
-  sh->handlers = GNUNET_MQ_copy_handlers (handlers);
+  sh->handlers = GNUNET_MQ_copy_handlers2 (handlers,
+                                           &return_agpl,
+                                           NULL);
   if (GNUNET_OK != setup_service (sh))
   {
     GNUNET_free_non_null (sh->handlers);
@@ -1723,9 +1755,9 @@ GNUNET_SERVICE_run_ (int argc,
   struct GNUNET_GETOPT_CommandLineOption service_options[] = {
     GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename),
     GNUNET_GETOPT_option_flag ('d',
-                                  "daemonize",
-                                  gettext_noop ("do daemonize (detach from terminal)"),
-                                  &do_daemonize),
+                               "daemonize",
+                               gettext_noop ("do daemonize (detach from terminal)"),
+                               &do_daemonize),
     GNUNET_GETOPT_option_help (NULL),
     GNUNET_GETOPT_option_loglevel (&loglev),
     GNUNET_GETOPT_option_logfile (&logfile),