myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-246


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-246-g446475f
Date: Sat, 22 May 2010 11:30:11 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  446475f1bd09d6dc3c392e1833a29e3b1a66b541 (commit)
       via  2406624ad78d5fb84291a6edd2e42c909a61d944 (commit)
      from  6820d668ea7afb38c9d32ac2105813e0263ebc74 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 446475f1bd09d6dc3c392e1833a29e3b1a66b541
Author: Giuseppe Scrivano <address@hidden>
Date:   Sat May 22 13:30:22 2010 +0200

    Specify plugins license.

diff --git a/plugins/src/guile/guile.cpp b/plugins/src/guile/guile.cpp
index a2b03ea..0e253b8 100644
--- a/plugins/src/guile/guile.cpp
+++ b/plugins/src/guile/guile.cpp
@@ -21,6 +21,7 @@
 
 
 PLUGIN_NAME ("guile");
+DECLARE_LICENSE (gpl);
 
 EXPORTABLE(SCM) eval (char *const string)
 {
diff --git a/plugins/src/guile_conf/guile_conf.cpp 
b/plugins/src/guile_conf/guile_conf.cpp
index a0cd0cc..3501b6f 100644
--- a/plugins/src/guile_conf/guile_conf.cpp
+++ b/plugins/src/guile_conf/guile_conf.cpp
@@ -28,6 +28,7 @@
 #define CONF_FILE_NAME "myserver.sch"
 
 PLUGIN_NAME ("guile_conf");
+DECLARE_LICENSE (gpl);
 
 /*! Define the interface to read from the main configuration file.  */
 class GuileConfiguration : public MainConfiguration
diff --git a/plugins/src/hello/hello.cpp b/plugins/src/hello/hello.cpp
index a5ea40f..44f52e4 100644
--- a/plugins/src/hello/hello.cpp
+++ b/plugins/src/hello/hello.cpp
@@ -19,6 +19,7 @@
 #include <include/plugin/plugin.h>
 
 PLUGIN_NAME ("hello");
+DECLARE_LICENSE (gpl);
 
 EXPORTABLE(int) load (void* server)
 {
diff --git a/plugins/src/http_checker/http_checker.cpp 
b/plugins/src/http_checker/http_checker.cpp
index 8b97d7c..5b9f16c 100644
--- a/plugins/src/http_checker/http_checker.cpp
+++ b/plugins/src/http_checker/http_checker.cpp
@@ -30,6 +30,7 @@ typedef int (*executePROC)(char*, u_long);
 typedef int (*executeFromFilePROC)(char*);
 
 PLUGIN_NAME ("http_checker");
+DECLARE_LICENSE (gpl);
 
 struct ThreadData
 {
diff --git a/plugins/src/mime_magic/mime_magic.cpp 
b/plugins/src/mime_magic/mime_magic.cpp
index 8cf6c7d..24fe767 100755
--- a/plugins/src/mime_magic/mime_magic.cpp
+++ b/plugins/src/mime_magic/mime_magic.cpp
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2007, 2009 The Free Software Foundation Inc.
+Copyright (C) 2007, 2009, 2010 The Free Software Foundation Inc.
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
@@ -27,6 +27,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 #include <include/plugin/plugin.h>
 
 PLUGIN_NAME ("mime_magic");
+DECLARE_LICENSE (gpl);
 
 class MagicHandler : public MimeManagerHandler
 {
diff --git a/plugins/src/python/python.cpp b/plugins/src/python/python.cpp
index 7e37ac4..e326546 100644
--- a/plugins/src/python/python.cpp
+++ b/plugins/src/python/python.cpp
@@ -23,6 +23,7 @@ HashMap<ThreadID, PythonData*> pythonThreadData;
 static Server *serverInstance;
 
 PLUGIN_NAME ("python");
+DECLARE_LICENSE (gpl);
 
 PyInterpreterState* PythonData::getInterpreter ()
 {
diff --git a/plugins/src/python_http_handler/python_http_handler.cpp 
b/plugins/src/python_http_handler/python_http_handler.cpp
index bd588a5..650f9ca 100644
--- a/plugins/src/python_http_handler/python_http_handler.cpp
+++ b/plugins/src/python_http_handler/python_http_handler.cpp
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2007, 2008, 2009 The Free Software Foundation Inc.
+Copyright (C) 2007, 2008, 2009, 2010 The Free Software Foundation Inc.
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
@@ -29,6 +29,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 
 
 PLUGIN_NAME ("python_http_handler");
+DECLARE_LICENSE (gpl);
 
 static Server* serverInstance;
 
diff --git a/plugins/src/rules_checker/rules_checker.cpp 
b/plugins/src/rules_checker/rules_checker.cpp
index ae38dd6..6503f5f 100644
--- a/plugins/src/rules_checker/rules_checker.cpp
+++ b/plugins/src/rules_checker/rules_checker.cpp
@@ -1,6 +1,6 @@
 /*
   MyServer
-  Copyright (C) 2007, 2009 The Free Software Foundation Inc.
+  Copyright (C) 2007, 2009, 2010 The Free Software Foundation Inc.
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
@@ -24,6 +24,7 @@
 #include <include/plugin/plugin.h>
 
 PLUGIN_NAME ("rules_checker");
+DECLARE_LICENSE (gpl);
 
 class RulesCheckerObserver : public Multicast<string, void*, int>
 {



commit 2406624ad78d5fb84291a6edd2e42c909a61d944
Author: Giuseppe Scrivano <address@hidden>
Date:   Sat May 22 13:29:15 2010 +0200

    Deny loading of plugins that are not GPL'ed.

diff --git a/myserver/include/base/dynamic_lib/dynamiclib.h 
b/myserver/include/base/dynamic_lib/dynamiclib.h
index 44d998e..167c033 100644
--- a/myserver/include/base/dynamic_lib/dynamiclib.h
+++ b/myserver/include/base/dynamic_lib/dynamiclib.h
@@ -38,10 +38,10 @@ public:
   int validHandle ();
   DynamicLibrary ();
   ~DynamicLibrary ();
-  int loadLibrary (const char* filename, int globally=0);
-  void* getProc (const char*);
+  int loadLibrary (const char *filename, int globally = 0);
+  void *getProc (const char *sym);
   int close ();
-  const char* getFileName (){return fileName.c_str ();}
+  const char *getFileName (){return fileName.c_str ();}
 private:
   string fileName;
   void *handle;
diff --git a/myserver/include/plugin/plugin.h b/myserver/include/plugin/plugin.h
index e6423a9..f9ea7c8 100644
--- a/myserver/include/plugin/plugin.h
+++ b/myserver/include/plugin/plugin.h
@@ -25,7 +25,10 @@
 #  define EXPORTABLE(x) extern "C" x
 # endif
 
-# define PLUGIN_NAME(X) static const char * __name = X; \
+# define DECLARE_LICENSE(x) EXPORTABLE (const char *) __##x##_license;  \
+  const char *__##x##_license = "1";
+
+# define PLUGIN_NAME(X) static const char *__name = X; \
         EXPORTABLE(const char*) name (){return X;}
 
 # include "myserver.h"
@@ -48,7 +51,7 @@ public:
   virtual int postLoad (Server* server);
   virtual int unLoad ();
   virtual const char* getName ();
-  virtual void* getDirectMethod (char* name);
+  virtual void* findSymbol (const char *name);
 protected:
   DynamicLibrary hinstLib;
 };
diff --git a/myserver/src/base/dynamic_lib/dynamiclib.cpp 
b/myserver/src/base/dynamic_lib/dynamiclib.cpp
index 0a733b7..0083eff 100644
--- a/myserver/src/base/dynamic_lib/dynamiclib.cpp
+++ b/myserver/src/base/dynamic_lib/dynamiclib.cpp
@@ -59,7 +59,7 @@ DynamicLibrary::~DynamicLibrary ()
   \param filename Name of the file to load.
   \param globally Set if the library is loaded globally.
  */
-int DynamicLibrary::loadLibrary (const char* filename, int globally)
+int DynamicLibrary::loadLibrary (const char *filename, int globally)
 {
   fileName.assign (filename);
 #ifdef WIN32
@@ -89,19 +89,19 @@ int DynamicLibrary::loadLibrary (const char* filename, int 
globally)
 }
 
 /*!
-  Get a pointer to the specified function. Returns 0 on errors or
-  the function address.
-  \param fnName Function name to find.
+  Get a pointer to the specified symbol. Returns 0 on errors or
+  the symbol address.
+  \param fnName Symbol to find.
  */
-void* DynamicLibrary::getProc (const char* fnName)
+void *DynamicLibrary::getProc (const char *sym)
 {
   if (!handle)
     return 0;
 #ifdef WIN32
-    return (void*) GetProcAddress ((HMODULE) handle, fnName);
+    return (void *) GetProcAddress ((HMODULE) handle, sym);
 #endif
 #ifdef HAVE_DL
-    return (void*) dlsym (handle, fnName);
+    return (void *) dlsym (handle, sym);
 #endif
 }
 
diff --git a/myserver/src/plugin/plugin.cpp b/myserver/src/plugin/plugin.cpp
index 5185e2b..cfaa818 100644
--- a/myserver/src/plugin/plugin.cpp
+++ b/myserver/src/plugin/plugin.cpp
@@ -52,7 +52,7 @@ Plugin::~Plugin ()
  */
 int Plugin::load (Server* server)
 {
-  loadPROC proc = (loadPROC)hinstLib.getProc ("load");
+  loadPROC proc = (loadPROC) hinstLib.getProc ("load");
   if (proc)
     return proc (server);
   return 0;
@@ -124,9 +124,10 @@ const char* Plugin::getName ()
   Get directly access to a method.
   \param name The method name.
  */
-void* Plugin::getDirectMethod (char* name)
+void* Plugin::findSymbol (const char *name)
 {
   if (!hinstLib.validHandle ())
     return 0;
+
   return hinstLib.getProc (name);
 }
diff --git a/myserver/src/plugin/plugins_manager.cpp 
b/myserver/src/plugin/plugins_manager.cpp
index f7508c4..7c28125 100644
--- a/myserver/src/plugin/plugins_manager.cpp
+++ b/myserver/src/plugin/plugins_manager.cpp
@@ -223,25 +223,23 @@ PluginsManager::preLoad (Server* server, string &resource)
   \param pinfo Plugin information.
  */
 int
-PluginsManager::loadFile (Server* server, string &name, string &file,
-                          PluginInfo* pinfo)
+PluginsManager::loadFile (Server *server, string &name, string &file,
+                          PluginInfo *pinfo)
 {
   int ret = 0;
   if (pinfo->isEnabled ())
     {
       Plugin* plugin = preLoadPlugin (file, server,
                                       pinfo->isGlobal ());
-      if (plugin)
-        pinfo->setPlugin (plugin);
+      if (! plugin)
+        ret = 1;
       else
         {
-          ret = 1;
-          server->log (MYSERVER_LOG_MSG_ERROR,
-                       _("Error loading plugin `%s'"), file.c_str ());
+          pinfo->setPlugin (plugin);
+          addPluginInfo (name, pinfo);
         }
     }
 
-  addPluginInfo (name, pinfo);
   return ret;
 }
 
@@ -501,8 +499,8 @@ PluginsManager::preLoadPlugin (string &file, Server* 
server, bool global)
       delete plugin;
       return NULL;
     }
-  namePtr = plugin->getName ();
 
+  namePtr = plugin->getName ();
   if (namePtr)
     name.assign (namePtr);
   else
@@ -514,12 +512,21 @@ PluginsManager::preLoadPlugin (string &file, Server* 
server, bool global)
       return NULL;
     }
 
+  if (plugin->findSymbol ("__gpl_license") == NULL)
+    {
+      server->log (MYSERVER_LOG_MSG_ERROR,
+                   _("Error loading plugin `%s', the license is not GPL"),
+                   file.c_str ());
+      delete plugin;
+      return NULL;
+    }
+
   return plugin;
 }
 
 void
 PluginsManager::recursiveDependencesFallDown (Server* server, string &name,
-                                  HashMap<string, bool> &remove,
+                                              HashMap<string, bool> &remove,
                                   HashMap<string, list<string>*> &dependsOn)
 {
   remove.put (name, true);
@@ -655,9 +662,7 @@ PluginsManager::load (Server *server)
     }
 
   for (it = pluginsInfos.begin (); it != pluginsInfos.end (); it++)
-    {
-      (*it)->getPlugin ()->load (server);
-    }
+    (*it)->getPlugin ()->load (server);
 
   return 0;
 }
diff --git a/myserver/tests/test_plugins_manager.cpp 
b/myserver/tests/test_plugins_manager.cpp
index cd8e836..62eb8ee 100644
--- a/myserver/tests/test_plugins_manager.cpp
+++ b/myserver/tests/test_plugins_manager.cpp
@@ -58,12 +58,12 @@ public:
     return 0;
   }
 
-  virtual const char* getName (char* buffer, u_long len)
+  virtual const char *getName (char* buffer, u_long len)
   {
     return 0;
   }
 
-  virtual void* getDirectMethod (char* name)
+  virtual void *findSymbol (char* name)
   {
     return 0;
   }

-----------------------------------------------------------------------

Summary of changes:
 myserver/include/base/dynamic_lib/dynamiclib.h     |    6 ++--
 myserver/include/plugin/plugin.h                   |    7 +++-
 myserver/src/base/dynamic_lib/dynamiclib.cpp       |   14 ++++----
 myserver/src/plugin/plugin.cpp                     |    5 ++-
 myserver/src/plugin/plugins_manager.cpp            |   31 +++++++++++--------
 myserver/tests/test_plugins_manager.cpp            |    4 +-
 plugins/src/guile/guile.cpp                        |    1 +
 plugins/src/guile_conf/guile_conf.cpp              |    1 +
 plugins/src/hello/hello.cpp                        |    1 +
 plugins/src/http_checker/http_checker.cpp          |    1 +
 plugins/src/mime_magic/mime_magic.cpp              |    3 +-
 plugins/src/python/python.cpp                      |    1 +
 .../python_http_handler/python_http_handler.cpp    |    3 +-
 plugins/src/rules_checker/rules_checker.cpp        |    3 +-
 14 files changed, 49 insertions(+), 32 deletions(-)


hooks/post-receive
-- 
GNU MyServer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]