You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2013/04/15 22:46:56 UTC
[49/50] git commit: TS-1778: Remove vestigal extensions.config support
TS-1778: Remove vestigal extensions.config support
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b7b68516
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b7b68516
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b7b68516
Branch: refs/heads/3.3.x
Commit: b7b685165efb116d4a23567ba1e637653aef7d12
Parents: 922c301
Author: James Peach <jp...@apache.org>
Authored: Fri Mar 29 14:09:24 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:45 2013 -0600
----------------------------------------------------------------------
CHANGES | 2 +
.../perl/AdminClient/lib/Apache/TS/AdminClient.pm | 1 -
example/app-template/app-template.cc | 6 +-
mgmt/RecordsConfig.cc | 2 -
proxy/Main.cc | 6 +-
proxy/Makefile.am | 3 -
proxy/Plugin.cc | 64 +----
proxy/Plugin.h | 2 +-
proxy/PluginDB.cc | 205 ---------------
proxy/PluginDB.h | 65 -----
10 files changed, 14 insertions(+), 342 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 59a196b..3444721 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
Changes with Apache Traffic Server 3.3.2
+ *) [TS-1778] Remove vestigal extensions.config support
+
*) [TS-1806] bogus buffer sizing in CfgContextUtils.cc
*) [TS-1805] Fix stats ExpressionEval in stats xml.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
----------------------------------------------------------------------
diff --git a/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm b/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
index 82968db..8260fa2 100644
--- a/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
+++ b/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
@@ -618,7 +618,6 @@ The Apache Traffic Server Administration Manual will explain what these strings
proxy.config.output.logfile
proxy.config.ping.npacks_to_trans
proxy.config.ping.timeout_sec
- proxy.config.plugin.extensions_dir
proxy.config.plugin.plugin_dir
proxy.config.plugin.plugin_mgmt_dir
proxy.config.prefetch.child_port
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/example/app-template/app-template.cc
----------------------------------------------------------------------
diff --git a/example/app-template/app-template.cc b/example/app-template/app-template.cc
index adc2ef3..737e20a 100644
--- a/example/app-template/app-template.cc
+++ b/example/app-template/app-template.cc
@@ -233,12 +233,8 @@ int main(int argc, char * argv[])
// initialize logging (after event and net processor)
//Log::init(system_remote_management_flag ? 0 : Log::NO_REMOTE_MANAGEMENT);
-#if !defined(TS_NO_API)
- //plugin_init(system_config_directory, true); // extensions.config
-#endif
-
#ifndef TS_NO_API
- //plugin_init(system_config_directory, false); // plugin.config
+ //plugin_init(system_config_directory); // plugin.config
#else
//api_init(); // still need to initialize some of the data structure other module needs.
#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 75464bf..55b0cb8 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -1384,8 +1384,6 @@ RecordElement RecordsConfig[] = {
,
{RECT_CONFIG, "proxy.config.plugin.plugin_mgmt_dir", RECD_STRING, TS_BUILD_SYSCONFDIR "/plugins_mgmt", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.plugin.extensions_dir", RECD_STRING, TS_BUILD_RUNTIMEDIR, RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
- ,
//##############################################################################
//#
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 9cff6f3..c15529c 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1650,10 +1650,6 @@ main(int argc, char **argv)
Log::init(remote_management_flag ? 0 : Log::NO_REMOTE_MANAGEMENT);
#endif
-#if !defined(TS_NO_API)
- plugin_init(system_config_directory, true); // extensions.config
-#endif
-
//acc.init();
//if (auto_clear_authdb_flag)
// acc.clear_cache();
@@ -1717,7 +1713,7 @@ main(int argc, char **argv)
}
#ifndef TS_NO_API
- plugin_init(system_config_directory, false); // plugin.config
+ plugin_init(system_config_directory); // plugin.config
#else
api_init(); // we still need to initialize some of the data structure other module needs.
// i.e. http_global_hooks
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/Makefile.am
----------------------------------------------------------------------
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index ff2529d..288261d 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -106,8 +106,6 @@ traffic_server_SOURCES = \
ParentSelection.h \
Plugin.cc \
Plugin.h \
- PluginDB.cc \
- PluginDB.h \
PluginVC.cc \
PluginVC.h \
Prefetch.cc \
@@ -233,7 +231,6 @@ traffic_sac_SOURCES = \
Prefetch.cc \
Update.cc \
Plugin.cc \
- PluginDB.cc \
InkAPI.cc \
FetchSM.cc \
InkIOCoreAPI.cc \
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/Plugin.cc
----------------------------------------------------------------------
diff --git a/proxy/Plugin.cc b/proxy/Plugin.cc
index e40925b..419017b 100644
--- a/proxy/Plugin.cc
+++ b/proxy/Plugin.cc
@@ -35,7 +35,6 @@
#include "InkAPIInternal.h"
#include "Main.h"
#include "Plugin.h"
-#include "PluginDB.h"
// HPUX:
// LD_SHAREDCMD=ld -b
@@ -48,12 +47,8 @@
static const char *plugin_dir = ".";
-static const char *extensions_dir = ".";
-static PluginDB *plugin_db = NULL;
typedef void (*init_func_t) (int argc, char *argv[]);
-typedef void (*init_func_w_handle_t) (void *handle, int argc, char *argv[]);
-typedef int (*lic_req_func_t) (void);
// Plugin registration vars
//
@@ -75,11 +70,9 @@ PluginRegInfo::PluginRegInfo()
{ }
static void *
-dll_open(char *fn, bool global)
+dll_open(const char *path)
{
- int global_flags = global ? RTLD_GLOBAL : 0;
-
- return (void *) dlopen(fn, RTLD_NOW | global_flags);
+ return (void *) dlopen(path, RTLD_NOW);
}
static void *
@@ -101,21 +94,18 @@ dll_close(void *dlp)
dlclose(dlp);
}
-
static void
-plugin_load(int argc, char *argv[], bool internal)
+plugin_load(int argc, char *argv[])
{
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;
if (argc < 1) {
return;
}
- ink_filepath_make(path, sizeof(path), pdir, argv[0]);
+ ink_filepath_make(path, sizeof(path), plugin_dir, argv[0]);
Note("loading plugin '%s'", path);
@@ -128,33 +118,18 @@ plugin_load(int argc, char *argv[], bool internal)
plugin_reg_temp = (plugin_reg_temp->link).next;
}
- handle = dll_open(path, (internal ? true : false));
+ handle = dll_open(path);
if (!handle) {
Error("unable to load '%s': %s", path, dll_error(handle));
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);
plugin_reg_current = new PluginRegInfo;
plugin_reg_current->plugin_path = ats_strdup(path);
- init_func_w_handle_t inith = (init_func_w_handle_t) dll_findsym(handle, "TSPluginInitwDLLHandle");
- if (inith) {
- inith(handle, argc, argv);
- return;
- }
-
init = (init_func_t) dll_findsym(handle, "TSPluginInit");
if (!init) {
Error("unable to find TSPluginInit function '%s': %s", path, dll_error(handle));
@@ -268,7 +243,7 @@ plugins_exist(const char *config_dir)
}
void
-plugin_init(const char *config_dir, bool internal)
+plugin_init(const char *config_dir)
{
char path[PATH_NAME_MAX + 1];
char line[1024], *p;
@@ -281,35 +256,14 @@ plugin_init(const char *config_dir, bool internal)
if (INIT_ONCE) {
api_init();
- char *cfg = NULL;
-
plugin_dir = TSPluginDirGet();
-
- RecGetRecordString_Xmalloc("proxy.config.plugin.extensions_dir", (char**)&cfg);
- if (cfg != NULL) {
- extensions_dir = Layout::get()->relative(cfg);
- ats_free(cfg);
- cfg = NULL;
- }
- ink_filepath_make(path, sizeof(path), config_dir, "plugin.db");
- plugin_db = new PluginDB(path);
INIT_ONCE = false;
}
- ink_assert(plugin_db);
-
- if (internal == false) {
- ink_filepath_make(path, sizeof(path), config_dir, "plugin.config");
- } else {
- ink_filepath_make(path, sizeof(path), config_dir, "extensions.config");
- }
-
+ ink_filepath_make(path, sizeof(path), config_dir, "plugin.config");
fd = open(path, O_RDONLY);
if (fd < 0) {
- /* secret extensions dont complain */
- if (internal == false) {
- Warning("unable to open plugin config file '%s': %d, %s", path, errno, strerror(errno));
- }
+ Warning("unable to open plugin config file '%s': %d, %s", path, errno, strerror(errno));
return;
}
@@ -362,7 +316,7 @@ plugin_init(const char *config_dir, bool internal)
}
}
- plugin_load(argc, argv, internal);
+ plugin_load(argc, argv);
for (i = 0; i < argc; i++)
ats_free(vars[i]);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/Plugin.h
----------------------------------------------------------------------
diff --git a/proxy/Plugin.h b/proxy/Plugin.h
index d520313..4173a05 100644
--- a/proxy/Plugin.h
+++ b/proxy/Plugin.h
@@ -56,7 +56,7 @@ struct PluginRegInfo
extern DLL<PluginRegInfo> plugin_reg_list;
extern PluginRegInfo *plugin_reg_current;
-void plugin_init(const char *config_dir, bool internal_exts);
+void plugin_init(const char *config_dir);
int plugins_exist(const char *config_dir);
#endif /* __PLUGIN_H__ */
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/PluginDB.cc
----------------------------------------------------------------------
diff --git a/proxy/PluginDB.cc b/proxy/PluginDB.cc
deleted file mode 100644
index a2b42d2..0000000
--- a/proxy/PluginDB.cc
+++ /dev/null
@@ -1,205 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#include "ink_config.h"
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include "ink_code.h"
-#include "Diags.h"
-#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);
- ReadPluginDB(plugin_db_file);
-}
-
-PluginDB::~PluginDB(void)
-{
- ink_hash_table_destroy_and_free_values(info_table);
-}
-
-void
-PluginDB::ReadPluginDB(const char *plugin_db_file)
-{
- FILE *pdb = fopen(plugin_db_file, "r");
- if (pdb == NULL) {
- Warning("unable to open plugin.db file '%s': %d, %s", plugin_db_file, errno, strerror(errno));
- return;
- }
-
- char line[1024];
- char plugin_obj[256];
- plugin_obj[0] = '\0';
- PluginDB::PluginInfo * pinfo = new PluginDB::PluginInfo();
-
- while (fgets(line, sizeof(line) - 1, pdb) != NULL) {
- char *p = line;
- while (*p && ParseRules::is_wslfcr(*p)) {
- p++;
- }
- if ((*p == '\0') || (*p == '#')) {
- continue;
- }
- // We have a non-comment and non-blank line
-
- // Nullify the newline character
- int len = strlen(p);
- int i;
- p[len - 1] = '\0';
-
- if (p[0] == '[') {
- if (plugin_obj[0] != '\0' && (pinfo->name[0] != '\0' || pinfo->license[0] != '\0')) {
- ink_hash_table_insert(info_table, (InkHashTableKey) plugin_obj, (InkHashTableValue) pinfo);
- plugin_obj[0] = '\0';
- pinfo = new PluginDB::PluginInfo();
- }
- p++;
- for (i = 0; p[i] != '\0' && p[i] != ']' && i < 255; i++) {
- pinfo->name[i] = p[i];
- }
- pinfo->name[i] = '\0';
-
- } else {
- if (strstr(p, "Object=")) {
- p = p + sizeof("Object=") - 1;
- for (i = 0; p[i] != '\0' && i < 255; i++) {
- 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')) {
- ink_hash_table_insert(info_table, (InkHashTableKey) plugin_obj, (InkHashTableValue) pinfo);
- } else {
- delete pinfo;
- }
- 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;
-}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/PluginDB.h
----------------------------------------------------------------------
diff --git a/proxy/PluginDB.h b/proxy/PluginDB.h
deleted file mode 100644
index cf8f3ae..0000000
--- a/proxy/PluginDB.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#ifndef __PLUGIN_DB_H__
-#define __PLUGIN_DB_H__
-
-#include "ink_hash_table.h"
-
-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;
-};
-
-#endif /* __PLUGIN_DB_H__ */