Hey folks,

Here's a proposal for removing the licensing code.

review/comments very welcome.

i

--
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.ga...@brainsware.org
URL: http://brainsware.org/
GPG: 571B 8B8A FC97 266D BDA3  EF6F 43AD 80A4 5779 3257
Index: proxy/api/ts/ts.h.in
===================================================================
--- proxy/api/ts/ts.h.in	(revision 1174515)
+++ proxy/api/ts/ts.h.in	(working copy)
@@ -645,21 +645,7 @@
    */
   extern tsapi void TSPluginInit(int argc, const char* argv[]);
 
-  /* --------------------------------------------------------------------------
-     License */
-  /**
-      This function lets Traffic Server know that a license key is
-      required for the plugin. You implement this function to return the
-      necessary value. If a license is required, Traffic Server looks
-      at the plugin.db file for the license key. If this function is
-      not defined, a license is not required. Use the gen_key tool to
-      generate license keys.
 
-      @return Zero if no license is required. Returns 1 if a license
-        is required.
-  */
-  extern tsapi int TSPluginLicenseRequired(void);
-
   /* --------------------------------------------------------------------------
      URL schemes */
   extern tsapi const char* TS_URL_SCHEME_FILE;
Index: proxy/PluginDB.h
===================================================================
--- proxy/PluginDB.h	(revision 1174515)
+++ proxy/PluginDB.h	(working copy)
@@ -29,34 +29,16 @@
 class PluginDB
 {
 public:
-  typedef enum
-  {
-    license_missing = 0,
-    license_expired,
-    license_invalid,
-    license_ok
-  } CheckLicenseResult;
-
     PluginDB(const char *plugin_db_file);
    ~PluginDB(void);
 
-  CheckLicenseResult CheckLicense(const char *plugin_obj);
-
-  static const char *CheckLicenseResultStr[];
-
 private:
 
   typedef struct
   {
     char name[256];
-    char license[256];
   } PluginInfo;
 
-  static const unsigned int license_custid_len;
-  static const unsigned int license_expire_len;
-  static const unsigned int license_digest_len;
-  static const unsigned int license_total_len;
-
   void ReadPluginDB(const char *plugin_db_file);
 
   InkHashTable *info_table;
Index: proxy/Plugin.cc
===================================================================
--- proxy/Plugin.cc	(revision 1174515)
+++ proxy/Plugin.cc	(working copy)
@@ -116,7 +116,6 @@
   char path[PATH_NAME_MAX + 1];
   void *handle;
   init_func_t init;
-  lic_req_func_t lic_req;
   PluginRegInfo *plugin_reg_temp;
   const char *pdir = internal ? extensions_dir : plugin_dir;
 
@@ -142,15 +141,6 @@
     abort();
   }
 
-  lic_req = (lic_req_func_t) dll_findsym(handle, "TSPluginLicenseRequired");
-  if (lic_req && lic_req() != 0) {
-    PluginDB::CheckLicenseResult result = plugin_db->CheckLicense(argv[0]);
-    if (result != PluginDB::license_ok) {
-      Error("unable to load '%s': %s", path, PluginDB::CheckLicenseResultStr[result]);
-      dll_close(handle);
-      abort();
-    }
-  }
   // Allocate a new registration structure for the
   //    plugin we're starting up
   ink_assert(plugin_reg_current == NULL);
Index: proxy/PluginDB.cc
===================================================================
--- proxy/PluginDB.cc	(revision 1174515)
+++ proxy/PluginDB.cc	(working copy)
@@ -30,43 +30,6 @@
 #include "ParseRules.h"
 #include "PluginDB.h"
 
-/***************************************************************************
- *
- * An Inktomi Traffic Server plugin license key should look like:
- *
- *     XXXXXEEEEDDDDDD
- *
- * XXXXX is a 5 digit alphanumeric id used by plugin vendors to
- * assign to their customers.
- *
- * EEEE is the hex encoding of the expiration date. It's the number
- * of days from January 1, 1970. If a plugin has no expiration date,
- * 0000 can be used instead.
- *
- * DDDDDD is the INK_MD5 encoding of some combination of the following
- * strings: "Inktomi Traffic Server", "Plugin Name", "XXXXXEEEE".
- *
- *
- ***************************************************************************/
-
-const char *
-  PluginDB::CheckLicenseResultStr[] = {
-  "license missing",
-  "license expired",
-  "license invalid",
-  "license ok"
-};
-
-const unsigned int
-  PluginDB::license_custid_len = 5;
-const unsigned int
-  PluginDB::license_expire_len = 4;
-const unsigned int
-  PluginDB::license_digest_len = 6;
-const unsigned int
-  PluginDB::license_total_len = PluginDB::license_custid_len +
-  PluginDB::license_expire_len + PluginDB::license_digest_len;
-
 PluginDB::PluginDB(const char *plugin_db_file)
 {
   info_table = ink_hash_table_create(InkHashTableKeyType_String);
@@ -108,7 +71,7 @@
     p[len - 1] = '\0';
 
     if (p[0] == '[') {
-      if (plugin_obj[0] != '\0' && (pinfo->name[0] != '\0' || pinfo->license[0] != '\0')) {
+      if (plugin_obj[0] != '\0' && (pinfo->name[0] != '\0')) {
         ink_hash_table_insert(info_table, (InkHashTableKey) plugin_obj, (InkHashTableValue) pinfo);
         plugin_obj[0] = '\0';
         pinfo = new PluginDB::PluginInfo();
@@ -126,17 +89,11 @@
           plugin_obj[i] = p[i];
         }
         plugin_obj[i] = '\0';
-      } else if (strstr(p, "License=")) {
-        p = p + sizeof("License=") - 1;
-        for (i = 0; p[i] != '\0' && i < 255; i++) {
-          pinfo->license[i] = p[i];
-        }
-        pinfo->license[i] = '\0';
       }
     }
   }
 
-  if (plugin_obj[0] != '\0' && (pinfo->name[0] != '\0' || pinfo->license[0] != '\0')) {
+  if (plugin_obj[0] != '\0' && (pinfo->name[0] != '\0')) {
     ink_hash_table_insert(info_table, (InkHashTableKey) plugin_obj, (InkHashTableValue) pinfo);
   } else {
     delete pinfo;
@@ -144,62 +101,3 @@
   fclose(pdb);
 }
 
-PluginDB::CheckLicenseResult PluginDB::CheckLicense(const char *plugin_obj)
-{
-  char
-    buffer[1024],
-    buffer_md5[16],
-    buffer_md5_str[33];
-  char
-    expire_str[PluginDB::license_expire_len + 1];
-  unsigned long
-    expire_days;
-  INK_DIGEST_CTX
-    md5_context;
-  PluginDB::PluginInfo * pinfo;
-  char *
-    end_ptr = NULL;
-
-  InkHashTableEntry *
-    ht_entry = ink_hash_table_lookup_entry(info_table,
-                                           (InkHashTableKey) plugin_obj);
-  if (ht_entry != NULL) {
-    pinfo = (PluginDB::PluginInfo *) ink_hash_table_entry_value(info_table, ht_entry);
-  } else {
-    return PluginDB::license_missing;
-  }
-
-  if (strlen(pinfo->license) != PluginDB::license_total_len) {
-    return PluginDB::license_invalid;
-  }
-
-  snprintf(buffer, sizeof(buffer), "Inktomi Traffic Server %s ", pinfo->name);
-  strncat(buffer, pinfo->license, PluginDB::license_custid_len + PluginDB::license_expire_len);
-
-  ink_code_incr_md5_init(&md5_context);
-  ink_code_incr_md5_update(&md5_context, buffer, strlen(buffer));
-  ink_code_incr_md5_final(buffer_md5, &md5_context);
-  // coverity[uninit_use_in_call]
-  ink_code_md5_stringify(buffer_md5_str, sizeof(buffer_md5_str), buffer_md5);
-
-  if (strncmp(buffer_md5_str,
-              pinfo->license + PluginDB::license_custid_len
-              + PluginDB::license_expire_len, PluginDB::license_digest_len) != 0) {
-    return PluginDB::license_invalid;
-  }
-
-  strncpy(expire_str, pinfo->license + PluginDB::license_custid_len, PluginDB::license_expire_len);
-  expire_str[PluginDB::license_expire_len] = '\0';
-
-  expire_days = strtoul(expire_str, &end_ptr, 16);
-
-  if (expire_days != 0) {
-    time_t
-      time_now = time(NULL);
-    if ((unsigned long) time_now > expire_days * (60 * 60 * 24)) {
-      return PluginDB::license_expired;
-    }
-  }
-
-  return PluginDB::license_ok;
-}

Reply via email to