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 2011/04/03 20:34:50 UTC
svn commit: r1088371 [2/2] - in /trafficserver/traffic/trunk:
contrib/perl/AdminClient/lib/Apache/TS/ cop/ doc/man/ mgmt/ mgmt/api/
mgmt/api/include/ mgmt/api/remote/ mgmt/cli/ mgmt/tools/ mgmt/utils/
mgmt/web2/ proxy/ proxy/config/ proxy/http/remap/
Modified: trafficserver/traffic/trunk/mgmt/web2/WebHttp.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebHttp.cc?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebHttp.cc (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebHttp.cc Sun Apr 3 18:34:48 2011
@@ -37,11 +37,8 @@
#include "WebCompatibility.h"
#include "WebHttp.h"
-#include "WebHttpAuth.h"
#include "WebHttpContext.h"
-#include "WebHttpLog.h"
#include "WebHttpMessage.h"
-#include "WebHttpRender.h"
#include "WebHttpSession.h"
#include "WebOverview.h"
@@ -56,9 +53,6 @@
#include "ConfigAPI.h"
#include "SysAPI.h"
-#include "openssl/ssl.h"
-#include "openssl/err.h"
-#include "openssl/crypto.h"
#if !defined(_WIN32)
// Ugly hack - define HEAP_H and STACK_H to prevent stuff from the
// template library from being included which SUNPRO CC does not not
@@ -95,116 +89,9 @@ typedef int (*WebHttpHandler) (WebHttpCo
// only allow access to specific files on the autoconf port
static InkHashTable *g_autoconf_allow_ht = 0;
-static InkHashTable *g_submit_bindings_ht = 0;
static InkHashTable *g_file_bindings_ht = 0;
-static InkHashTable *g_extn_bindings_ht = 0;
-
-InkHashTable *g_display_config_ht = 0;
-
-//-------------------------------------------------------------------------
-// prototypes
-//-------------------------------------------------------------------------
-
-void spawn_script(WebHttpContext * whc, char *script, char **args);
-
-//-------------------------------------------------------------------------
-// record_version_valid
-//-------------------------------------------------------------------------
-
-static bool
-record_version_valid(char *record_version)
-{
- int old_version, old_pid, cur_version;
- // coverity[secure_coding]
- if (sscanf(record_version, "%d:%d", &old_pid, &old_version) == 2 && old_version >= 0) {
- cur_version = RecGetRecordUpdateCount(RECT_CONFIG);
- //fix me --> lmgmt->record_data->pid
- // TODO: need to check the PID ??
- // if (cur_version != old_version || lmgmt->record_data->pid != old_pid) {
- if (cur_version != old_version) {
- // we are out of date since the version number has been incremented
- return false;
- } else {
- return true;
- }
- }
- // bad format, return false to be safe
- return false;
-}
-
-//-------------------------------------------------------------------------
-// set_record_value
-//-------------------------------------------------------------------------
-
-static bool
-set_record_value(WebHttpContext * whc, const char *rec, const char *value)
-{
- MgmtData varValue;
- char *record;
- char *script = NULL;
- char *script_path;
-
- if (rec == NULL) {
- return false;
- }
- if (value == NULL) {
- value = "";
- }
- // INKqa11771: exec script that associates with a record
- record = xstrdup(rec);
- if ((script = strchr(record, ':'))) {
- *script = '\0';
- script++;
- }
- // FIXME: If someone else has already added a NOTE or WARN, then we
- // won't be able to add anymore. This is desired for
- // handle_submit_update, but going forward, we'll need a more
- // general mechanism.
-
- varValue.setFromName(record);
- if (varValue.compareFromString(value) == false) {
- if (recordValidityCheck(record, value)) {
- if (recordRestartCheck(record)) {
- ink_hash_table_insert(whc->submit_note_ht, record, NULL);
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_NOTE)) {
- HtmlRndrText(whc->submit_note, whc->lang_dict_ht, HTML_ID_RESTART_REQUIRED);
- HtmlRndrBr(whc->submit_note);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_NOTE;
- }
- varSetFromStr(record, value);
-
-#ifndef _WIN32
- if (script) {
- const char *args[MAX_ARGS + 1];
- for (int i = 0; i < MAX_ARGS; i++)
- args[i] = NULL;
- script_path = WebHttpAddDocRoot_Xmalloc(whc, script);
- args[0] = script_path;
- args[1] = value;
- processSpawn(&args[0], NULL, NULL, NULL, false, false);
- xfree(script_path);
- }
-#endif
- } else {
- ink_hash_table_insert(whc->submit_warn_ht, record, NULL);
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_INVALID_ENTRY);
- HtmlRndrBr(whc->submit_warn);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- }
- }
- xfree(record);
- return true;
-}
-
-//-------------------------------------------------------------------------
-// spawn_cgi
-//-------------------------------------------------------------------------
#if defined(_WIN32)
-
// adjustCmdLine
//
// This function is used for constructing a command line from a CGI
@@ -240,185 +127,6 @@ adjustCmdLine(char *cmdLine, int cmdline
#endif
-int
-spawn_cgi(WebHttpContext * whc, const char *cgi_path, char **args, bool nowait, bool run_as_root)
-{
-
- struct stat info;
- const char *query_string;
- textBuffer query_string_tb(MAX_TMP_BUF_LEN);
- int qlen = 0;
- char content_length_buffer[10];
- EnvBlock env;
- const char *a[MAX_ARGS + 2];
- int i;
-
- httpMessage *request = whc->request;
- textBuffer *replyMsg = whc->response_bdy;
- httpResponse *answerHdr = whc->response_hdr;
-
- // check if file exists
- if (stat(cgi_path, &info) < 0) {
- WebHttpSetErrorResponse(whc, STATUS_NOT_FOUND);
- answerHdr->setStatus(STATUS_NOT_FOUND);
- return WEB_HTTP_ERR_REQUEST_ERROR;
- }
- // initialize arguments
- for (i = 0; i < MAX_ARGS + 2; i++)
- a[i] = NULL;
- a[0] = cgi_path;
- for (i = 1; i < MAX_ARGS + 1 && args && args[i - 1]; i++)
- a[i] = args[i - 1];
-
- // initialize environment
- if (request->getContentType() != NULL) {
- env.setVar("CONTENT_TYPE", request->getContentType());
- }
- if (request->getMethod() == METHOD_POST) {
- env.setVar("REQUEST_METHOD", "POST");
- query_string = request->getBody();
-
- } else if (request->getMethod() == METHOD_GET) {
- env.setVar("REQUEST_METHOD", "GET");
- query_string = request->getQuery();
-
- } else {
- answerHdr->setStatus(STATUS_NOT_IMPLEMENTED);
- WebHttpSetErrorResponse(whc, STATUS_NOT_IMPLEMENTED);
- return WEB_HTTP_ERR_REQUEST_ERROR;;
- }
- if (query_string != NULL) {
-
- // use getConLen() to handle binary
- qlen = request->getConLen();
- if (qlen <= 0)
- qlen = strlen(query_string);
- snprintf(content_length_buffer, sizeof(content_length_buffer), "%d", qlen);
- env.setVar("CONTENT_LENGTH", content_length_buffer);
- env.setVar("QUERY_STRING", query_string);
-
- query_string_tb.copyFrom(query_string, qlen);
- }
-#ifndef _WIN32
- if (processSpawn(&a[0], &env, &query_string_tb, replyMsg, nowait, run_as_root) != 0) {
- mgmt_elog(stderr, "[spawn_cgi] Unable to fork child process\n");
- WebHttpSetErrorResponse(whc, STATUS_INTERNAL_SERVER_ERROR);
- answerHdr->setStatus(STATUS_INTERNAL_SERVER_ERROR);
- }
-#else
-
- char buffer[1024];
- char cmdLine[PATH_MAX * 2 + 6];
- DWORD nbytes = 0;
-
- SECURITY_ATTRIBUTES saAttr;
- saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
- saAttr.bInheritHandle = TRUE;
- saAttr.lpSecurityDescriptor = NULL;
-
- // STDIN
- HANDLE hChildStdinR = NULL;
- HANDLE hChildStdinW = NULL;
-
- CreatePipe(&hChildStdinR, &hChildStdinW, &saAttr, 0);
-
- // Dup to NULL and set inheritable to FALSE so that
- // it won't be inherited by the child process
- DuplicateHandle(GetCurrentProcess(), hChildStdinW, GetCurrentProcess(), NULL, 0, FALSE, DUPLICATE_SAME_ACCESS);
-
- // STDOUT
- HANDLE hChildStdoutR = NULL;
- HANDLE hChildStdoutW = NULL;
-
- CreatePipe(&hChildStdoutR, &hChildStdoutW, &saAttr, 0);
-
- // Dup to NULL and set inheritable to FALSE so that
- // it won't be inherited by the child process
- DuplicateHandle(GetCurrentProcess(), hChildStdoutR, GetCurrentProcess(), NULL, 0, FALSE, DUPLICATE_SAME_ACCESS);
-
- STARTUPINFO suInfo;
- PROCESS_INFORMATION procInfo;
- ZeroMemory((PVOID) & suInfo, sizeof(suInfo));
-
- // hide the new console window from the user
- suInfo.cb = sizeof(STARTUPINFO);
- suInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
- suInfo.wShowWindow = SW_HIDE;
- suInfo.hStdInput = hChildStdinR;
- suInfo.hStdOutput = hChildStdoutW;
- suInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
-
- adjustCmdLine(cmdLine, sizeof(cmdLine), cgi_path);
-
- if (CreateProcess(NULL, cmdLine, NULL, // FIX THIS: process security attributes
- NULL, // FIX THIS: thread security attributes
- TRUE, // make handles inheritable
- 0, // FIX THIS: specify a priority
- env.toString(), ts_base_dir, // make script run from TSBase
- &suInfo, &procInfo) == FALSE) {
-
- mgmt_elog(stderr, "[spawn_cgi] CreateProcess error: %s\n", ink_last_err());
- WebHttpSetErrorResponse(whc, STATUS_INTERNAL_SERVER_ERROR);
- answerHdr->setStatus(STATUS_INTERNAL_SERVER_ERROR);
-
- } else {
-
- CloseHandle(hChildStdinR);
- if (request->getMethod() == METHOD_POST && query_string != NULL) {
- WriteFile(hChildStdinW, query_string, qlen, &nbytes, NULL);
- }
- CloseHandle(hChildStdinW);
-
- CloseHandle(hChildStdoutW);
- while (ReadFile(hChildStdoutR, buffer, 1024, &nbytes, NULL) == TRUE) {
- if (nbytes == 0) {
- break;
- }
- replyMsg->copyFrom(buffer, nbytes);
- }
- CloseHandle(hChildStdoutR);
- }
-
-#endif
-
- return WEB_HTTP_ERR_OKAY;
-
-}
-//-------------------------------------------------------------------------
-// handle_cgi_extn
-//-------------------------------------------------------------------------
-
-static int
-handle_cgi_extn(WebHttpContext * whc, const char *file)
-{
- NOWARN_UNUSED(file);
- int err;
- char *cgi_path;
- whc->response_hdr->setCachable(0);
- whc->response_hdr->setStatus(STATUS_OK);
- whc->response_hdr->setContentType(TEXT_HTML);
- cgi_path = WebHttpAddDocRoot_Xmalloc(whc, whc->request->getFile());
- err = spawn_cgi(whc, cgi_path, NULL, false, false);
- xfree(cgi_path);
- return err;
-}
-
-//-------------------------------------------------------------------------
-// handle_ink_extn
-//-------------------------------------------------------------------------
-
-static int
-handle_ink_extn(WebHttpContext * whc, const char *file)
-{
- int err;
- if ((err = WebHttpRender(whc, file)) == WEB_HTTP_ERR_OKAY) {
- whc->response_hdr->setStatus(STATUS_OK);
- whc->response_hdr->setLength(whc->response_bdy->spaceUsed());
- whc->response_hdr->setContentType(TEXT_HTML);
- }
- return err;
-}
-
//-------------------------------------------------------------------------
// handle_record_info
@@ -463,447 +171,12 @@ handle_synthetic(WebHttpContext * whc, c
}
//-------------------------------------------------------------------------
-// handle_submit_mgmt_auth
-//-------------------------------------------------------------------------
-
-// set_admin_passwd (sub-function)
-static inline void
-set_admin_passwd(WebHttpContext * whc)
-{
-
- char *admin_orig_epasswd;
- char *admin_old_passwd;
- char *admin_old_epasswd;
- char *admin_new_passwd;
- char *admin_new_passwd_retype;
- char *admin_new_epasswd;
-
- char empty_str[1];
- *empty_str = '\0';
-
- if (!ink_hash_table_lookup(whc->post_data_ht, "admin_old_passwd", (void **) &admin_old_passwd))
- admin_old_passwd = NULL;
- if (!ink_hash_table_lookup(whc->post_data_ht, "admin_new_passwd", (void **) &admin_new_passwd))
- admin_new_passwd = NULL;
- if (!ink_hash_table_lookup(whc->post_data_ht, "admin_new_passwd_retype", (void **) &admin_new_passwd_retype))
- admin_new_passwd_retype = NULL;
-
- if ((admin_old_passwd != NULL) || (admin_new_passwd != NULL) || (admin_new_passwd_retype != NULL)) {
-
- if (admin_old_passwd == NULL)
- admin_old_passwd = empty_str;
- if (admin_new_passwd == NULL)
- admin_new_passwd = empty_str;
- if (admin_new_passwd_retype == NULL)
- admin_new_passwd_retype = empty_str;
-
- admin_orig_epasswd = (char *) alloca(TS_ENCRYPT_PASSWD_LEN + 1);
- varStrFromName("proxy.config.admin.admin_password", admin_orig_epasswd, TS_ENCRYPT_PASSWD_LEN + 1);
-
- // INKqa12084: do not encrypt password if empty_str
- if (strcmp(admin_old_passwd, empty_str) == 0) {
- admin_old_epasswd = xstrdup(empty_str);
- } else {
- TSEncryptPassword(admin_old_passwd, &admin_old_epasswd);
- }
-
- if (strncmp(admin_old_epasswd, admin_orig_epasswd, TS_ENCRYPT_PASSWD_LEN) == 0) {
- if (strcmp(admin_new_passwd, admin_new_passwd_retype) == 0) {
- // INKqa12084: do not encrypt password if empty_str
- if (strcmp(admin_new_passwd, empty_str) == 0) {
- admin_new_epasswd = xstrdup(empty_str);
- } else {
- TSEncryptPassword(admin_new_passwd, &admin_new_epasswd);
- }
-
- set_record_value(whc, "proxy.config.admin.admin_password", admin_new_epasswd);
- xfree(admin_new_epasswd);
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_NOTE;
- HtmlRndrText(whc->submit_note, whc->lang_dict_ht, HTML_ID_NEW_ADMIN_PASSWD_SET);
- HtmlRndrBr(whc->submit_note);
- } else {
- ink_hash_table_insert(whc->submit_warn_ht, "proxy.config.admin.admin_password", NULL);
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_NEW_PASSWD_MISTYPE);
- HtmlRndrBr(whc->submit_warn);
- }
- } else {
- ink_hash_table_insert(whc->submit_warn_ht, "proxy.config.admin.admin_password", NULL);
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_OLD_PASSWD_INCORRECT);
- HtmlRndrBr(whc->submit_warn);
- }
- xfree(admin_old_epasswd);
- }
-
-}
-
-static int
-handle_submit_mgmt_auth(WebHttpContext * whc, const char *file)
-{
- NOWARN_UNUSED(file);
- bool recs_out_of_date;
- char *value;
- char *cancel;
- char *record_version;
- char *submit_from_page;
- char *aa_session_id, *aa_user_count;
- char *aa_user, *aa_access, *aa_delete;
- char *aa_new_user, *aa_new_passwd, *aa_new_passwd_retype, *aa_new_access;
- char *aa_new_epasswd;
- char admin_user[MAX_VAL_LENGTH + 1];
- int user, user_count;
- TSCfgContext ctx;
- TSAdminAccessEle *ele;
- TSActionNeedT action_need;
- TSAccessT access_t;
- bool ctx_updated;
-
- char tmp_a[32];
- char tmp_b[32];
-
- char empty_str[1];
- *empty_str = '\0';
-
- // initialize pointers we may assign memeory to
- aa_new_epasswd = NULL;
-
- // check for submit_from_page
- if (ink_hash_table_lookup(whc->post_data_ht, "submit_from_page", (void **) &submit_from_page)) {
- ink_hash_table_delete(whc->post_data_ht, "submit_from_page");
- whc->top_level_render_file = xstrdup(submit_from_page);
- } else {
- submit_from_page = NULL;
- }
-
- // check for cancel
- if (ink_hash_table_lookup(whc->post_data_ht, "cancel", (void **) &cancel))
- goto Ldone;
-
- // check for record_version
- recs_out_of_date = true;
- if (ink_hash_table_lookup(whc->post_data_ht, "record_version", (void **) &record_version)) {
- recs_out_of_date = !record_version_valid(record_version);
- ink_hash_table_delete(whc->post_data_ht, "record_version");
- xfree(record_version);
- }
- if (recs_out_of_date)
- goto Lout_of_date;
-
- // proxy.config.admin.basic_auth
- if (ink_hash_table_lookup(whc->post_data_ht, "proxy.config.admin.basic_auth", (void **) &value))
- set_record_value(whc, "proxy.config.admin.basic_auth", value);
-
- // proxy.config.admin.admin_user
- if (ink_hash_table_lookup(whc->post_data_ht, "proxy.config.admin.admin_user", (void **) &value))
- set_record_value(whc, "proxy.config.admin.admin_user", value);
-
- // proxy.config.admin.admin_password (call sub-function)
- set_admin_passwd(whc);
-
- // grab our session_id and user_count
- if (ink_hash_table_lookup(whc->post_data_ht, "session_id", (void **) &aa_session_id)) {
- if (!ink_hash_table_lookup(whc->post_data_ht, "user_count", (void **) &aa_user_count))
- goto Lunable_to_submit;
- // find our current session
- if (WebHttpSessionRetrieve(aa_session_id, (void **) &ctx) != WEB_HTTP_ERR_OKAY)
- goto Lout_of_date;
- // get new additional-user information
- if (!ink_hash_table_lookup(whc->post_data_ht, "new_user", (void **) &aa_new_user))
- aa_new_user = NULL;
- if (!ink_hash_table_lookup(whc->post_data_ht, "new_passwd", (void **) &aa_new_passwd))
- aa_new_passwd = NULL;
- if (!ink_hash_table_lookup(whc->post_data_ht, "new_passwd_retype", (void **) &aa_new_passwd_retype))
- aa_new_passwd_retype = NULL;
- if (!ink_hash_table_lookup(whc->post_data_ht, "new_access", (void **) &aa_new_access))
- aa_new_access = NULL;
- // check if the user is trying to add a new additional-user
- if (aa_new_user != NULL) {
- // kwt 12.March.2001 check for username length
- if (strlen(aa_new_user) > WEB_HTTP_AUTH_USER_MAX) {
- ink_hash_table_insert(whc->submit_warn_ht, "additional_administrative_accounts", NULL);
- ink_hash_table_insert(whc->submit_warn_ht, "add_new_administrative_user", NULL);
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_NEW_USERNAME_LENGTH);
- HtmlRndrBr(whc->submit_warn);
- aa_new_user = NULL;
- }
- // kwt
- if (aa_new_user != NULL) {
- if (aa_new_passwd == NULL)
- aa_new_passwd = empty_str;
- if (aa_new_passwd_retype == NULL)
- aa_new_passwd_retype = empty_str;
- if (strcmp(aa_new_passwd, aa_new_passwd_retype) == 0) {
- // allocating memory on aa_new_epasswd
- TSEncryptPassword(aa_new_passwd, &aa_new_epasswd);
- } else {
- ink_hash_table_insert(whc->submit_warn_ht, "additional_administrative_accounts", NULL);
- ink_hash_table_insert(whc->submit_warn_ht, "add_new_administrative_user", NULL);
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_NEW_PASSWD_MISTYPE);
- HtmlRndrBr(whc->submit_warn);
- }
- }
- // check if the new_user is the same as the proxy.config.admin.admin_user
- if (aa_new_user != NULL) {
- varStrFromName("proxy.config.admin.admin_user", admin_user, MAX_VAL_LENGTH + 1);
- if (strcmp(aa_new_user, admin_user) == 0) {
- ink_hash_table_insert(whc->submit_warn_ht, "additional_administrative_accounts", NULL);
- ink_hash_table_insert(whc->submit_warn_ht, "add_new_administrative_user", NULL);
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_NEW_USER_DUPLICATE);
- HtmlRndrBr(whc->submit_warn);
- aa_new_user = NULL;
- }
- }
- }
- // Walk through members and update settings in ctx backwards.
- // Client submitted values should be in the same order as the ctx
- // since we originally created this page from the same ctx.
- // Looping backwards helps so that we can delete elements by
- // index.
- ctx_updated = false;
- user_count = ink_atoi(aa_user_count);
- for (user = user_count - 1; user >= 0; user--) {
- snprintf(tmp_a, sizeof(tmp_a), "user:%d", user);
- snprintf(tmp_b, sizeof(tmp_b), "access:%d", user);
- if (ink_hash_table_lookup(whc->post_data_ht, tmp_a, (void **) &aa_user) &&
- ink_hash_table_lookup(whc->post_data_ht, tmp_b, (void **) &aa_access)) {
- snprintf(tmp_a, sizeof(tmp_a), "delete:%d", user);
- if (ink_hash_table_lookup(whc->post_data_ht, tmp_a, (void **) &aa_delete)) {
- TSCfgContextRemoveEleAt(ctx, user);
- ctx_updated = true;
- continue;
- }
- ele = (TSAdminAccessEle *) TSCfgContextGetEleAt(ctx, user);
- if (strcmp(ele->user, aa_user) != 0) {
- goto Lunable_to_submit;
- }
- if (aa_new_user && (strcmp(aa_new_user, aa_user) == 0)) {
- ink_hash_table_insert(whc->submit_warn_ht, "additional_administrative_accounts", NULL);
- ink_hash_table_insert(whc->submit_warn_ht, "add_new_administrative_user", NULL);
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_NEW_USER_DUPLICATE);
- HtmlRndrBr(whc->submit_warn);
- aa_new_user = NULL;
- }
- access_t = (TSAccessT) ink_atoi(aa_access);
- if (ele->access != access_t) {
- ele->access = access_t;
- ctx_updated = true;
- }
- } else {
- goto Lunable_to_submit;
- }
- }
- // add new user
- if ((aa_new_user != NULL) && (aa_new_epasswd != NULL)) {
- ele = TSAdminAccessEleCreate();
- ele->user = xstrdup(aa_new_user);
- ele->password = xstrdup(aa_new_epasswd);
- // FIXME: no access for now, add back later?
- //ele->access = aa_new_access ? (TSAccessT)ink_atoi(aa_new_access) : TS_ACCESS_NONE;
- ele->access = TS_ACCESS_NONE;
- TSCfgContextAppendEle(ctx, (TSCfgEle *) ele);
- ctx_updated = true;
- }
- if (ctx_updated) {
- if (TSCfgContextCommit(ctx, &action_need, NULL) != TS_ERR_OKAY) {
- WebHttpSessionDelete(aa_session_id);
- goto Lout_of_date;
- }
- TSActionDo(action_need);
- }
- WebHttpSessionDelete(aa_session_id);
- } else {
- goto Lunable_to_submit;
- }
- goto Ldone;
-
-Lout_of_date:
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_OUT_OF_DATE);
- HtmlRndrBr(whc->submit_warn);
- goto Ldone;
-
-Lunable_to_submit:
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_UNABLE_TO_SUBMIT);
- HtmlRndrBr(whc->submit_warn);
- goto Ldone;
-
-Ldone:
- if (aa_new_epasswd) {
- xfree(aa_new_epasswd);
- }
- return WebHttpRender(whc, HTML_MGMT_LOGIN_FILE);
-}
-
-
-//-------------------------------------------------------------------------
-// handle_submit_view_logs
-//-------------------------------------------------------------------------
-static int
-handle_submit_view_logs(WebHttpContext * whc, const char *file)
-{
- NOWARN_UNUSED(file);
- int err;
- char *submit_from_page;
- char *nlines;
- char *substring;
- char *action = NULL;
- char *logfile = NULL;
- char tmp[MAX_TMP_BUF_LEN + 1];
- int file_size;
- time_t file_date_gmt;
-
- // check for submit_from_page
- if (ink_hash_table_lookup(whc->post_data_ht, "submit_from_page", (void **) &submit_from_page)) {
- ink_hash_table_delete(whc->post_data_ht, "submit_from_page");
- whc->top_level_render_file = xstrdup(submit_from_page);
- } else {
- submit_from_page = NULL;
- }
-
-#if !defined(_WIN32)
-
- // handle remove/save file action before rendering
- if (!ink_hash_table_lookup(whc->post_data_ht, "logfile", (void **) &logfile))
- goto Ldone;
- if (!ink_hash_table_lookup(whc->post_data_ht, "action", (void **) &action))
- goto Ldone;
- if (!logfile || !action)
- goto Ldone;
- if (strcmp(logfile, "default") == 0)
- goto Ldone;
-
- if (strcmp(action, "view_last") == 0) {
- if (!ink_hash_table_lookup(whc->post_data_ht, "nlines", (void **) &nlines))
- goto Ldone;
- // 'nlines' entry is missing
- if (nlines == NULL) {
- ink_hash_table_insert(whc->submit_warn_ht, "view_last", NULL);
- goto Lmiss;
- }
-
- } else if (strcmp(action, "view_subset") == 0) {
- if (!ink_hash_table_lookup(whc->post_data_ht, "substring", (void **) &substring))
- goto Ldone;
- // 'substring' entry is missing
- if (substring == NULL) {
- ink_hash_table_insert(whc->submit_warn_ht, "view_subset", NULL);
- goto Lmiss;
- }
-
- } else if (strcmp(action, "remove") == 0) {
-
- snprintf(tmp, MAX_TMP_BUF_LEN, "/bin/rm -f %s", logfile);
- if (system(tmp)) {
- Debug("web2", "[handle_submit_view_logs] unable to execute \"%s\"", tmp);
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_LOG_REMOVE_FAILED);
- HtmlRndrBr(whc->submit_warn);
- }
- } else {
- // done removal - remove from post_data_ht not to display previous action
- ink_hash_table_delete(whc->post_data_ht, "action");
- ink_hash_table_delete(whc->post_data_ht, "logfile");
- xfree(logfile);
- xfree(action);
- }
- } else if (strcmp(action, "save") == 0) {
- WebHandle h_file;
- if ((h_file = WebFileOpenR(logfile)) == WEB_HANDLE_INVALID) {
- Debug("web2", "[handle_submit_view_logs] unable to open logfile \"%s\"", logfile);
-
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_LOG_SAVE_FAILED);
- HtmlRndrBr(whc->submit_warn);
- }
- } else {
- file_size = WebFileGetSize(h_file);
- file_date_gmt = WebFileGetDateGmt(h_file);
- whc->response_hdr->setStatus(STATUS_OK);
- whc->response_hdr->setLength(file_size);
- whc->response_hdr->setLastMod(file_date_gmt);
- whc->response_hdr->setContentType(TEXT_UNKNOWN);
- while (whc->response_bdy->rawReadFromFile(h_file) > 0);
- WebFileClose(h_file);
- return WEB_HTTP_ERR_OKAY;
- }
- } else {
- Debug("web2", "[handle_submit_view_logs] unknown action '%s' on '%s'", action, logfile);
- }
- goto Ldone;
-
-#endif
-
-Lmiss:
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_MISSING_ENTRY);
- HtmlRndrBr(whc->submit_warn);
- }
-
-Ldone:
- // nothing needs to be done, just start rendering
- if (submit_from_page) {
- err = WebHttpRender(whc, submit_from_page);
- xfree(submit_from_page);
- } else {
- err = WebHttpRender(whc, HTML_DEFAULT_MONITOR_FILE);
- }
- return err;
-}
-
-
-//-------------------------------------------------------------------------
-// network configuration
-//-------------------------------------------------------------------------
-
-
-bool
-NICCheck(WebHttpContext * whc, char *updown, char *arg)
-{
- bool result;
-
- result = true;
-
- if (strcmp(updown, "0") == 0) {
- result = false;
- ink_hash_table_insert(whc->submit_warn_ht, arg, NULL);
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_INVALID_ENTRY);
- HtmlRndrBr(whc->submit_warn);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- }
- return result;
-}
-
-void
-SetWarning(WebHttpContext * whc, char *arg)
-{
- ink_hash_table_insert(whc->submit_warn_ht, arg, NULL);
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_INVALID_ENTRY);
- HtmlRndrBr(whc->submit_warn);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-}
-
-
-//-------------------------------------------------------------------------
// handle_default
//-------------------------------------------------------------------------
static int
handle_default(WebHttpContext * whc, const char *file)
{
-
char *doc_root_file;
int file_size;
time_t file_date_gmt;
@@ -977,7 +250,7 @@ handle_default(WebHttpContext * whc, con
}
// append the appropriate doc_root on to the file
- doc_root_file = WebHttpAddDocRoot_Xmalloc(whc, request_file);
+ doc_root_file = WebHttpAddDocRoot_Xmalloc(whc, request_file, request_file_len);
// open the requested file
if ((h_file = WebFileOpenR(doc_root_file)) == WEB_HANDLE_INVALID) {
@@ -1025,15 +298,12 @@ handle_default(WebHttpContext * whc, con
}
-
//-------------------------------------------------------------------------
// read_request
//-------------------------------------------------------------------------
-
int
read_request(WebHttpContext * whc)
{
-
const int buffer_size = 2048;
char *buffer = (char *) alloca(buffer_size);
@@ -1055,6 +325,7 @@ read_request(WebHttpContext * whc)
WebHttpSetErrorResponse(whc, STATUS_BAD_REQUEST);
return WEB_HTTP_ERR_REQUEST_ERROR;
}
+
// Check for a scheme we do not understand
//
// If we undertand the scheme, it has
@@ -1123,7 +394,6 @@ read_request(WebHttpContext * whc)
#endif
return WEB_HTTP_ERR_OKAY;
-
}
//-------------------------------------------------------------------------
@@ -1136,6 +406,7 @@ write_response(WebHttpContext * whc)
char *buf_p;
int bytes_to_write;
int bytes_written;
+
// Make sure that we have a content length
if (whc->response_hdr->getLength() < 0) {
whc->response_hdr->setLength(whc->response_bdy->spaceUsed());
@@ -1193,7 +464,6 @@ process_query(WebHttpContext * whc)
//-------------------------------------------------------------------------
// process_post
//-------------------------------------------------------------------------
-
int
process_post(WebHttpContext * whc)
{
@@ -1252,50 +522,12 @@ signal_handler_init()
}
//-------------------------------------------------------------------------
-// ssl_init
-//-------------------------------------------------------------------------
-
-int
-ssl_init(WebHttpContext * whc)
-{
- SSL *SSL_con = NULL;
- unsigned int sslErrno;
- char ssl_Error[256];
- SSL_con = SSL_new(whc->ssl_ctx);
- SSL_set_fd(SSL_con, whc->si.fd);
- if (SSL_accept(SSL_con) < 0) {
- sslErrno = ERR_get_error();
- ERR_error_string(sslErrno, ssl_Error);
- mgmt_log(stderr, "[ssl_init] SSL_accept failed: %s", ssl_Error);
- return WEB_HTTP_ERR_FAIL;
- }
- whc->si.SSLcon = SSL_con;
-
- return WEB_HTTP_ERR_OKAY;
-}
-
-//-------------------------------------------------------------------------
-// ssl_free
-//-------------------------------------------------------------------------
-
-int
-ssl_free(WebHttpContext * whc)
-{
- if (whc->si.SSLcon != NULL) {
- SSL_free((SSL *) whc->si.SSLcon);
- }
-
- return WEB_HTTP_ERR_OKAY;
-}
-
-//-------------------------------------------------------------------------
// WebHttpInit
//-------------------------------------------------------------------------
void
WebHttpInit()
{
-
static int initialized = 0;
if (initialized != 0) {
@@ -1303,49 +535,19 @@ WebHttpInit()
}
initialized++;
- // initialize autoconf allow files
+ // initialize allow files
g_autoconf_allow_ht = ink_hash_table_create(InkHashTableKeyType_String);
ink_hash_table_insert(g_autoconf_allow_ht, "/proxy.pac", NULL);
ink_hash_table_insert(g_autoconf_allow_ht, "/wpad.dat", NULL);
ink_hash_table_insert(g_autoconf_allow_ht, "/public_key.der", NULL);
ink_hash_table_insert(g_autoconf_allow_ht, "/synthetic.txt", NULL);
- // initialize submit bindings
- g_submit_bindings_ht = ink_hash_table_create(InkHashTableKeyType_String);
- ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_MGMT_AUTH_FILE, (void *) handle_submit_mgmt_auth);
- //ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_SNAPSHOT_FILE, handle_submit_snapshot);
- ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_VIEW_LOGS_FILE, (void *) handle_submit_view_logs);
// initialize file bindings
g_file_bindings_ht = ink_hash_table_create(InkHashTableKeyType_String);
- ink_hash_table_insert(g_file_bindings_ht, HTML_SYNTHETIC_FILE, (void *) handle_synthetic);
-
- // initialize extension bindings
- g_extn_bindings_ht = ink_hash_table_create(InkHashTableKeyType_String);
- ink_hash_table_insert(g_extn_bindings_ht, ".cgi", (void *) handle_cgi_extn);
- ink_hash_table_insert(g_extn_bindings_ht, ".ink", (void *) handle_ink_extn);
-
- // initialize the configurator editing bindings which binds
- // configurator display filename (eg. f_cache_config.ink) to
- // its mgmt API config file type (TSFileNameT)
- g_display_config_ht = ink_hash_table_create(InkHashTableKeyType_String);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_CACHE_CONFIG, (void *) TS_FNAME_CACHE_OBJ);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_HOSTING_CONFIG, (void *) TS_FNAME_HOSTING);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_ICP_CONFIG, (void *) TS_FNAME_ICP_PEER);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_IP_ALLOW_CONFIG, (void *) TS_FNAME_IP_ALLOW);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_MGMT_ALLOW_CONFIG, (void *) TS_FNAME_MGMT_ALLOW);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_PARENT_CONFIG, (void *) TS_FNAME_PARENT_PROXY);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_VOLUME_CONFIG, (void *) TS_FNAME_VOLUME);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_REMAP_CONFIG, (void *) TS_FNAME_REMAP);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_SOCKS_CONFIG, (void *) TS_FNAME_SOCKS);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_SPLIT_DNS_CONFIG, (void *) TS_FNAME_SPLIT_DNS);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_UPDATE_CONFIG, (void *) TS_FNAME_UPDATE_URL);
- ink_hash_table_insert(g_display_config_ht, HTML_FILE_VADDRS_CONFIG, (void *) TS_FNAME_VADDRS);
+ ink_hash_table_insert(g_file_bindings_ht, "/synthetic.txt", (void *) handle_synthetic);
// initialize other modules
- WebHttpLogInit();
WebHttpSessionInit();
-
- return;
}
//-------------------------------------------------------------------------
@@ -1353,12 +555,10 @@ WebHttpInit()
//
// Handles http requests across the web management port
//-------------------------------------------------------------------------
-
void
WebHttpHandleConnection(WebHttpConInfo * whci)
{
int err = WEB_HTTP_ERR_OKAY;
-
WebHttpContext *whc;
WebHttpHandler handler;
char *file;
@@ -1371,9 +571,6 @@ WebHttpHandleConnection(WebHttpConInfo *
goto Ltransaction_close;
if (signal_handler_init() != WEB_HTTP_ERR_OKAY)
goto Ltransaction_close;
- if (whc->server_state & WEB_HTTP_SERVER_STATE_SSL_ENABLED)
- if (ssl_init(whc) != WEB_HTTP_ERR_OKAY)
- goto Ltransaction_close;
// read request
if ((err = read_request(whc)) != WEB_HTTP_ERR_OKAY)
@@ -1387,7 +584,6 @@ WebHttpHandleConnection(WebHttpConInfo *
Debug("web2", "[WebHttpHandleConnection] request file: %s", file);
-
if (whc->server_state & WEB_HTTP_SERVER_STATE_AUTOCONF) {
// security concern: special treatment if we're handling a request
@@ -1404,39 +600,16 @@ WebHttpHandleConnection(WebHttpConInfo *
// process query
process_query(whc);
- // check submit_binding;
- // if nothing, check file_binding;
- // if nothing, check extn_binding;
- // if still nothing, use the default handler;
- if (ink_hash_table_lookup(g_submit_bindings_ht, file, (void **) &handler)) {
- // workaround: sometimes we receive a GET for our submit cgi's
- // (rather than a resubmitted POST). In this case, just render
- // the default page since we can't do much else
- if (whc->request->getMethod() != METHOD_POST) {
- if ((strcmp(file, HTML_SUBMIT_INSPECTOR_DPY_FILE) != 0) && (strcmp(file, HTML_SUBMIT_CONFIG_DISPLAY) != 0)) {
- err = WebHttpRender(whc, HTML_DEFAULT_MONITOR_FILE);
- goto Lerror_switch;
- }
- }
- // process post
- process_post(whc);
- // only allow one submission at a time
- ink_mutex_acquire(&wGlobals.submitLock);
- err = handler(whc, file);
- ink_mutex_release(&wGlobals.submitLock);
- } else {
- if (!ink_hash_table_lookup(g_file_bindings_ht, file, (void **) &handler)) {
- extn = file;
- while (*extn != '\0')
- extn++;
- while ((extn > file) && (*extn != '.'))
- extn--;
- if (!ink_hash_table_lookup(g_extn_bindings_ht, extn, (void **) &handler)) {
- handler = handle_default;
- }
- }
- err = handler(whc, file);
+ // Lookup file handler
+ if (!ink_hash_table_lookup(g_file_bindings_ht, file, (void **) &handler)) {
+ extn = file;
+ while (*extn != '\0')
+ extn++;
+ while ((extn > file) && (*extn != '.'))
+ extn--;
+ handler = handle_default;
}
+ err = handler(whc, file);
Lerror_switch:
@@ -1469,10 +642,6 @@ Ltransaction_send:
close_socket(whc->si.fd);
whc->si.fd = -1;
- // log transaction
- if (wGlobals.logFD >= 0)
- WebHttpLogTransaction(whc);
-
Ltransaction_close:
// if we didn't close already, close connection
@@ -1488,15 +657,9 @@ Ltransaction_close:
#endif
close_socket(whc->si.fd);
}
- // clean up ssl
- if (whc->server_state & WEB_HTTP_SERVER_STATE_SSL_ENABLED)
- ssl_free(whc);
// clean up memory
WebHttpContextDestroy(whc);
-
- return;
-
}
//-------------------------------------------------------------------------
@@ -1508,7 +671,6 @@ Ltransaction_close:
void
WebHttpSetErrorResponse(WebHttpContext * whc, HttpStatus_t error)
{
-
//-----------------------------------------------------------------------
// FIXME: HARD-CODED HTML HELL!!!
//-----------------------------------------------------------------------
@@ -1527,7 +689,6 @@ WebHttpSetErrorResponse(WebHttpContext *
whc->response_bdy->copyFrom(b, strlen(b));
whc->response_bdy->copyFrom(httpStatStr[error], errorMsgLen);
whc->response_bdy->copyFrom(c, strlen(c));
-
}
//-------------------------------------------------------------------------
@@ -1535,19 +696,15 @@ WebHttpSetErrorResponse(WebHttpContext *
//-------------------------------------------------------------------------
char *
-WebHttpAddDocRoot_Xmalloc(WebHttpContext * whc, const char *file)
+WebHttpAddDocRoot_Xmalloc(WebHttpContext * whc, const char *file, int file_len)
{
+ char *doc_root_file = (char *)xmalloc(file_len + whc->doc_root_len + 1);
- int file_len = 0;
- char *doc_root_file;
-
- file_len = strlen(file);
- file_len += strlen(whc->doc_root);
- doc_root_file = (char *) xmalloc(file_len + 1);
-
- ink_strncpy(doc_root_file, whc->doc_root, file_len);
- strncat(doc_root_file, file, file_len - strlen(doc_root_file));
+ memcpy(doc_root_file, whc->doc_root, whc->doc_root_len);
+ memcpy(doc_root_file + whc->doc_root_len, file, file_len);
+ *(doc_root_file + whc->doc_root_len + file_len) = '\0';
+ Debug("web2", "DocRoot request file: %s", doc_root_file);
+
return doc_root_file;
-
}
Modified: trafficserver/traffic/trunk/mgmt/web2/WebHttp.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebHttp.h?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebHttp.h (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebHttp.h Sun Apr 3 18:34:48 2011
@@ -41,8 +41,5 @@ void WebHttpInit();
void WebHttpHandleConnection(WebHttpConInfo * whci);
void WebHttpSetErrorResponse(WebHttpContext * whc, HttpStatus_t error);
-char *WebHttpAddDocRoot_Xmalloc(WebHttpContext * whc, const char *file);
-
-int spawn_cgi(WebHttpContext * whc, const char *cgi_path, char **args, bool nowait, bool run_as_root);
-
+char *WebHttpAddDocRoot_Xmalloc(WebHttpContext * whc, const char *file, int file_len);
#endif // _WEB_HTTP_H_
Modified: trafficserver/traffic/trunk/mgmt/web2/WebHttpContext.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebHttpContext.cc?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebHttpContext.cc (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebHttpContext.cc Sun Apr 3 18:34:48 2011
@@ -50,7 +50,6 @@ WebHttpContextCreate(WebHttpConInfo * wh
// memset to 0; note strings are zero'd too
memset(whc, 0, sizeof(WebHttpContext));
- whc->current_user.access = WEB_HTTP_AUTH_ACCESS_NONE;
whc->request = NEW(new httpMessage());
whc->response_hdr = NEW(new httpResponse());
whc->response_bdy = NEW(new textBuffer(8192));
@@ -62,20 +61,11 @@ WebHttpContextCreate(WebHttpConInfo * wh
// keep pointers into the context passed to us
whc->client_info = whci->clientInfo;
- whc->ssl_ctx = whci->context->SSL_Context;
whc->default_file = whci->context->defaultFile;
whc->doc_root = whci->context->docRoot;
- whc->admin_user = whci->context->admin_user;
- whc->other_users_ht = whci->context->other_users_ht;
- whc->lang_dict_ht = whci->context->lang_dict_ht;
+ whc->doc_root_len = whci->context->docRootLen;
// set server_state
- if (whci->context->SSLenabled > 0) {
- whc->server_state |= WEB_HTTP_SERVER_STATE_SSL_ENABLED;
- }
- if (whci->context->adminAuthEnabled > 0) {
- whc->server_state |= WEB_HTTP_SERVER_STATE_AUTH_ENABLED;
- }
if (whci->context == &autoconfContext) {
whc->server_state |= WEB_HTTP_SERVER_STATE_AUTOCONF;
}
@@ -117,17 +107,3 @@ WebHttpContextDestroy(WebHttpContext * w
xfree(whc);
}
}
-
-//-------------------------------------------------------------------------
-// WebHttpContextPrint_Debug
-//-------------------------------------------------------------------------
-
-void
-WebHttpContextPrint_Debug(WebHttpContext * whc)
-{
- if (whc) {
- printf("[WebHttpContext]\n");
- printf("-> default_file : %s\n", whc->default_file);
- printf("-> doc_root : %s\n", whc->doc_root);
- }
-}
Modified: trafficserver/traffic/trunk/mgmt/web2/WebHttpContext.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebHttpContext.h?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebHttpContext.h (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebHttpContext.h Sun Apr 3 18:34:48 2011
@@ -35,14 +35,12 @@
#include "TextBuffer.h"
#include "WebGlobals.h"
-#include "WebHttpAuth.h"
+#include "mgmtapi.h"
#include "WebHttpMessage.h"
#include "WebUtils.h"
struct WebHttpContext
{
-
- WebHttpAuthUser current_user; // current user and access privileges
uint32_t request_state; // client request state
uint32_t server_state; // bit-mask of enabled server features
httpMessage *request; // client request
@@ -56,22 +54,16 @@ struct WebHttpContext
InkHashTable *submit_note_ht; // ht of info submission records
sockaddr_in *client_info; // client conection information
SocketInfo si; // socket information
- ssl_ctx_st *ssl_ctx; // SSL information
-
- WebHttpAuthUser admin_user; // admin user information
- MgmtHashTable *other_users_ht; // other user information
-
- MgmtHashTable *lang_dict_ht; // language dictionary
char *top_level_render_file; // top-level file to render
char *cache_query_result; // cache inspector query result
const char *default_file; // default file
const char *doc_root; // document root
+ int doc_root_len; // length of doc_root
};
WebHttpContext *WebHttpContextCreate(WebHttpConInfo * whci);
void WebHttpContextDestroy(WebHttpContext * whc);
-void WebHttpContextPrint_Debug(WebHttpContext * whc);
#endif // _WEB_HTTP_CONTEXT_H_
Modified: trafficserver/traffic/trunk/mgmt/web2/WebIntrMain.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebIntrMain.cc?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebIntrMain.cc (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebIntrMain.cc Sun Apr 3 18:34:48 2011
@@ -37,8 +37,6 @@
#include "MgmtUtils.h"
#include "WebMgmtUtils.h"
#include "WebIntrMain.h"
-#include "WebReconfig.h"
-#include "MgmtAllow.h"
#include "Diags.h"
#include "MgmtSocket.h"
@@ -54,10 +52,6 @@ extern "C"
}
#endif
-#include "openssl/ssl.h"
-#include "openssl/err.h"
-#include "openssl/crypto.h"
-
/* Ugly hack - define HEADER_MD_5 to prevent the SSLeay md5.h
* header file from being included since it conflicts with the
* md5 implememntation from ink_code.h
@@ -91,172 +85,11 @@ WebInterFaceGlobals wGlobals;
// in this catagory. The public key for the
// administration server is another example
//
-WebContext adminContext;
WebContext autoconfContext;
// Used for storing argument values
-int web_port_arg = -1;
int aconf_port_arg = -1;
-// Locks that SSleay uses
-static ink_mutex ssl_locks[CRYPTO_NUM_LOCKS];
-
-void
-SSLeay_mutex_cb(int mode, int type, const char *file, int line)
-{
- NOWARN_UNUSED(file);
- NOWARN_UNUSED(line);
- ink_release_assert(type < CRYPTO_NUM_LOCKS);
- ink_release_assert(type >= 0);
- if (mode & CRYPTO_LOCK) {
- Debug("ssl_lock", "Acquiring ssl lock %d", type);
- ink_mutex_acquire(&ssl_locks[type]);
- } else {
- Debug("ssl_lock", "Releasing ssl lock %d", type);
- ink_mutex_release(&ssl_locks[type]);
- }
-}
-
-unsigned long
-SSLeay_tid_cb()
-{
- return (unsigned long) ink_thread_self();
-}
-
-
-// init_SSL()
-//
-// Set up SSL info - code derived from SSL
-//
-int
-init_SSL(char *sslCertFile, WebContext * wContext)
-{
-
- // Hard coded error buffer size because that is how SSLeay
- // does it internally
- //
- char ssl_Error[256];
- unsigned long sslErrno;
-
- if (sslCertFile == NULL) {
- mgmt_log(stderr, "[initSSL] No Certificate File was specified\n");
- return -1;
- }
- // Setup thread/locking callbacks
- for (int i = 0; i < CRYPTO_NUM_LOCKS; i++) {
- ink_mutex_init(&ssl_locks[i], "SSLeay mutex");
- }
- CRYPTO_set_id_callback(SSLeay_tid_cb);
- CRYPTO_set_locking_callback(SSLeay_mutex_cb);
-
- SSL_load_error_strings();
-
- SSLeay_add_ssl_algorithms();
- wContext->SSL_Context = (SSL_CTX *) SSL_CTX_new(SSLv23_server_method());
-
- if (SSL_CTX_use_PrivateKey_file(wContext->SSL_Context, sslCertFile, SSL_FILETYPE_PEM) <= 0) {
- sslErrno = ERR_get_error();
- ERR_error_string(sslErrno, ssl_Error);
- mgmt_log(stderr, "[initSSL] Unable to set public key file: %s\n", ssl_Error);
- goto SSL_FAILED;
- }
-
- if (SSL_CTX_use_certificate_file(wContext->SSL_Context, sslCertFile, SSL_FILETYPE_PEM) <= 0) {
- sslErrno = ERR_get_error();
- ERR_error_string(sslErrno, ssl_Error);
- mgmt_log(stderr, "[initSSL] Unable to set certificate file: %s\n", ssl_Error);
- goto SSL_FAILED;
- }
-
- /* Now we know that a key and cert have been set against
- * the SSL context */
- if (!SSL_CTX_check_private_key(wContext->SSL_Context)) {
- sslErrno = ERR_get_error();
- ERR_error_string(sslErrno, ssl_Error);
- mgmt_log(stderr, "[initSSL] Private key does not match the certificate public key: %s\n", ssl_Error);
- goto SSL_FAILED;
- }
- // Set a timeout so users connecting with http:// will not
- // have to wait forever for a timeout
- SSL_CTX_set_timeout(wContext->SSL_Context, 3);
-
- // Set SSL Read Ahead for higher performance
- SSL_CTX_set_default_read_ahead(wContext->SSL_Context, 1);
-
-/* Since we are only shipping domestically right now, allow
- higher grade ciphers
- // Allow only Export Grade 40 bit secret ciphers
- if(!SSL_CTX_set_cipher_list(wContext->SSL_Context,
- "EXP-RC4-MD5")) {
- sslErrno = ERR_get_error();
- ERR_error_string(sslErrno, ssl_Error);
- mgmt_fatal(stderr,"[initSSL] Unable to set the prefered cipher list: %s\n", ssl_Error);
- }
- */
-
- return 0;
-
-SSL_FAILED:
- // Free up the SSL context on failure so we do not try to recycle
- // it if SSL gets turned off and back on again
- if (wContext->SSL_Context != NULL) {
- SSL_CTX_free(adminContext.SSL_Context);
- wContext->SSL_Context = NULL;
- }
- return -1;
-}
-
-// void tmpFileDestructor(void* ptr)
-//
-// Deletes the memory associated with the
-// tmp file TSD
-//
-void
-tmpFileDestructor(void *ptr)
-{
- xfree(ptr);
-}
-
-// static int setUpLogging()
-// Returns the file descriptor of the file to log mgmt
-// Web server access to. Creates it if necessary
-//
-static int
-setUpLogging()
-{
- struct stat s;
- int err;
- char *log_dir;
- char log_file[PATH_NAME_MAX+1];
-
- if ((err = stat(system_log_dir, &s)) < 0) {
- ink_assert(RecGetRecordString_Xmalloc("proxy.config.log.logfile_dir", &log_dir)
- == REC_ERR_OKAY);
- Layout::relative_to(system_log_dir, sizeof(system_log_dir),
- Layout::get()->prefix, log_dir);
- if ((err = stat(log_dir, &s)) < 0) {
- mgmt_elog("unable to stat() log dir'%s': %d %d, %s\n",
- system_log_dir, err, errno, strerror(errno));
- mgmt_elog("please set 'proxy.config.log.logfile_dir'\n");
- //_exit(1);
- } else {
- ink_strncpy(system_log_dir,log_dir,sizeof(system_log_dir));
- }
- }
- Layout::relative_to(log_file, sizeof(log_file),
- system_log_dir, log_dir);
-
- int diskFD = open(log_file, O_WRONLY | O_APPEND | O_CREAT, 0644);
-
- if (diskFD < 0) {
- mgmt_log(stderr, "[setUpLogging] Unable to open log file (%s). No logging will occur: %s\n", log_file,strerror(errno));
- }
-
- fcntl(diskFD, F_SETFD, 1);
-
- return diskFD;
-}
-
// int checkWebContext(WebContext* wctx, char* desc)
//
// Checks out a WebContext to make sure that the
@@ -433,26 +266,6 @@ newTcpSocket(int port)
// purposes
static volatile int32_t numServiceThr = 0;
-void
-printServiceThr(int sig)
-{
- NOWARN_UNUSED(sig);
-
- fprintf(stderr, "Service Thread Array\n");
- fprintf(stderr, " Service Thread Count : %d\n", numServiceThr);
- for (int i = 0; i < MAX_SERVICE_THREADS; i++) {
- if (wGlobals.serviceThrArray[i].threadId != 0 || wGlobals.serviceThrArray[i].fd != -1) {
- fprintf(stderr,
- " Slot %d : FD %d : ThrId %lu : StartTime %d : WaitForJoin %s : Shutdown %s\n",
- i, wGlobals.serviceThrArray[i].fd,
- (unsigned long) wGlobals.serviceThrArray[i].threadId,
- (int) wGlobals.serviceThrArray[i].startTime,
- wGlobals.serviceThrArray[i].waitingForJoin ? "true" : "false",
- wGlobals.serviceThrArray[i].alreadyShutdown ? "true" : "false");
- }
- }
-}
-
void *
serviceThrReaper(void *arg)
{
@@ -489,29 +302,6 @@ serviceThrReaper(void *arg)
wGlobals.serviceThrArray[i].alreadyShutdown = false;
numJoined++;
-
- } else if ((currentTime > wGlobals.serviceThrArray[i].startTime + SOCKET_TIMEOUT) &&
- wGlobals.serviceThrArray[i].type == HTTP_THR &&
- wGlobals.serviceThrArray[i].alreadyShutdown == false) {
-
- // Socket is presumed stuck. Shutdown incoming
- // traffic on the socket so the thread handeling
- // socket will give up
- shutdown(wGlobals.serviceThrArray[i].fd, 0);
-
-#if !defined(freebsd) && !defined(darwin)
- ink_thread_cancel(wGlobals.serviceThrArray[i].threadId);
-#endif
-#if defined(darwin)
- ink_sem_post(wGlobals.serviceThrCount);
-#else
- ink_sem_post(&wGlobals.serviceThrCount);
-#endif
- ink_atomic_increment((int32_t *) & numServiceThr, -1);
-
- wGlobals.serviceThrArray[i].alreadyShutdown = true;
- Debug("ui", "%s %d %s %d\n", "Shuting Down Socket FD ",
- wGlobals.serviceThrArray[i].fd, "for thread", wGlobals.serviceThrArray[i].threadId);
}
}
}
@@ -549,9 +339,7 @@ webIntr_main(void *x)
struct sockaddr_in *clientInfo; // Info about client connection
ink_thread thrId; // ID of service thread we just spawned
fd_set selectFDs; // FD set passed to select
- int webPort = -1; // Port for incoming HTTP connections
int publicPort = -1; // Port for incoming autoconf connections
- int loggingEnabled; // Whether to log accesses the mgmt server
#if !defined(linux)
sigset_t allSigs; // Set of all signals
#endif
@@ -604,50 +392,11 @@ webIntr_main(void *x)
// Init mutex to only allow one submissions at a time
ink_mutex_init(&wGlobals.submitLock, "Submission Mutex");
- // Get our configuration information
- //
- // Set up the administration context
- //
- if (web_port_arg > 0) {
- webPort = web_port_arg;
- } else {
- found = (RecGetRecordInt("proxy.config.admin.web_interface_port", &tempInt) == REC_ERR_OKAY);
- webPort = (int) tempInt;
- ink_assert(found);
- }
- Debug("ui", "[WebIntrMain] Starting up Web Server on Port %d\n", webPort);
- wGlobals.webPort = webPort;
-
// Fix for INKqa10514
found = (RecGetRecordInt("proxy.config.admin.autoconf.localhost_only", &tempInt) == REC_ERR_OKAY);
autoconf_localhost_only = (int) tempInt;
ink_assert(found);
- // Figure out the document root
- found = (RecGetRecordString_Xmalloc("proxy.config.admin.html_doc_root", &(adminContext.docRoot)) == REC_ERR_OKAY);
- ink_assert(found);
-
- if (adminContext.docRoot == NULL) {
- mgmt_fatal(stderr, "[WebIntrMain] No Document Root\n");
- } else {
- adminContext.docRootLen = strlen(adminContext.docRoot);
- }
-
- adminContext.defaultFile = "/index.ink";
-
- // setup our other_users hash-table (for WebHttpAuth)
- adminContext.other_users_ht = new MgmtHashTable("other_users_ht", false, InkHashTableKeyType_String);
-
- // setup our language dictionary hash-table
- adminContext.lang_dict_ht = new MgmtHashTable("lang_dict_ht", false, InkHashTableKeyType_String);
- adminContext.SSL_Context = NULL;
-
- configSSLenable();
- Debug("ui", "SSL enabled is %d\n", adminContext.SSLenabled);
-
- // Set up the ip based access control
- configMgmtIpAllow();
-
// Set up the client autoconfiguration context
//
// Since autoconf is public access, turn security
@@ -655,14 +404,13 @@ webIntr_main(void *x)
if (aconf_port_arg > 0) {
publicPort = aconf_port_arg;
} else {
- found = (RecGetRecordInt("proxy.config.admin.autoconf_port", &tempInt) == REC_ERR_OKAY);
+ found = (RecGetRecordInt("proxy.config.admin.autoconf.port", &tempInt) == REC_ERR_OKAY);
publicPort = (int) tempInt;
ink_assert(found);
}
Debug("ui", "[WebIntrMain] Starting Client AutoConfig Server on Port %d\n", publicPort);
- found = (RecGetRecordString_Xmalloc("proxy.config.config_dir", &(autoconfContext.docRoot))
- == REC_ERR_OKAY);
+ found = (RecGetRecordString_Xmalloc("proxy.config.admin.autoconf.doc_root", &(autoconfContext.docRoot)) == REC_ERR_OKAY);
ink_assert(found);
if (autoconfContext.docRoot == NULL) {
@@ -670,6 +418,7 @@ webIntr_main(void *x)
} else {
struct stat s;
int err;
+
if ((err = stat(autoconfContext.docRoot, &s)) < 0) {
xfree(autoconfContext.docRoot);
autoconfContext.docRoot = xstrdup(system_config_directory);
@@ -682,50 +431,7 @@ webIntr_main(void *x)
}
autoconfContext.docRootLen = strlen(autoconfContext.docRoot);
}
- autoconfContext.adminAuthEnabled = 0;
- autoconfContext.admin_user.user[0] = '\0';
- autoconfContext.admin_user.encrypt_passwd[0] = '\0';
- autoconfContext.other_users_ht = 0;
- autoconfContext.lang_dict_ht = 0;
- autoconfContext.SSLenabled = 0;
- autoconfContext.SSL_Context = NULL;
autoconfContext.defaultFile = "/proxy.pac";
- autoconfContext.AdvUIEnabled = 1; // full Web UI by default
- autoconfContext.FeatureSet = 1; // default should be ?
-
- // Set up a TSD key for use by WebFileEdit
- ink_thread_key_create(&wGlobals.tmpFile, tmpFileDestructor);
-
- // Set up a TSD for storing the request structure. I would have
- // perfered to pass this along the call chain but I didn't think
- // of it until too late so I'm using a TSD
- ink_thread_key_create(&wGlobals.requestTSD, NULL);
-
- // Set up refresh Info
- found = (RecGetRecordInt("proxy.config.admin.ui_refresh_rate", &tempInt) == REC_ERR_OKAY);
- wGlobals.refreshRate = (int) tempInt;
- ink_assert(found);
-
- // Set up our logging configuration
- found = (RecGetRecordInt("proxy.config.admin.log_mgmt_access", &tempInt) == REC_ERR_OKAY);
- loggingEnabled = (int) tempInt;
- if (found == true && loggingEnabled != 0) {
- wGlobals.logFD = setUpLogging();
- } else {
- wGlobals.logFD = -1;
-
- }
- found = (RecGetRecordInt("proxy.config.admin.log_resolve_hostname", &tempInt) == REC_ERR_OKAY);
- loggingEnabled = (int) tempInt;
- if (found == true && loggingEnabled != 0) {
- wGlobals.logResolve = true;
- } else {
- wGlobals.logResolve = false;
- }
-
- // Set for reconfiguration callbacks
- setUpWebCB();
-
// INKqa09866
// fire up interface for ts configuration through API; use absolute path from root to
@@ -789,11 +495,7 @@ webIntr_main(void *x)
// TODO: Should we check return value?
mgmt_select(32, &selectFDs, (fd_set *) NULL, (fd_set *) NULL, NULL);
- if (socketFD >= 0 && FD_ISSET(socketFD, &selectFDs)) {
- // new HTTP Connection
- acceptFD = socketFD;
- serviceThr = HTTP_THR;
- } else if (autoconfFD >= 0 && FD_ISSET(autoconfFD, &selectFDs)) {
+ if (autoconfFD >= 0 && FD_ISSET(autoconfFD, &selectFDs)) {
acceptFD = autoconfFD;
serviceThr = AUTOCONF_THR;
} else {
@@ -820,13 +522,6 @@ webIntr_main(void *x)
#endif
ink_atomic_increment((int32_t *) & numServiceThr, -1);
} else { // Accept succeeded
-
- if (serviceThr == HTTP_THR) {
- if (fcntl(clientFD, F_SETFD, FD_CLOEXEC) < 0) {
- mgmt_elog(stderr, "[WebIntrMain] Unable to set close on exec flag\n");
- }
- }
-
if (safe_setsockopt(clientFD, IPPROTO_TCP, TCP_NODELAY, ON, sizeof(int)) < 0) {
mgmt_log(stderr, "[WebIntrMain]Failed to set sock options: %s\n", strerror(errno));
}
@@ -835,11 +530,8 @@ webIntr_main(void *x)
ink_mutex_acquire(&wGlobals.serviceThrLock);
// If this a web manager, make sure that it is from an allowed ip addr
- if (((serviceThr == HTTP_THR) &&
- mgmt_allow_table->match(clientInfo->sin_addr.s_addr) == false)
- // Fix for INKqa10514
- || (serviceThr == AUTOCONF_THR && autoconf_localhost_only != 0 &&
- strcmp(inet_ntoa(clientInfo->sin_addr), "127.0.0.1") != 0)) {
+ if (serviceThr == AUTOCONF_THR && autoconf_localhost_only != 0 &&
+ strcmp(inet_ntoa(clientInfo->sin_addr), "127.0.0.1") != 0) {
mgmt_log("WARNING: connect by disallowed client %s, closing\n", inet_ntoa(clientInfo->sin_addr));
#if defined(darwin)
ink_sem_post(wGlobals.serviceThrCount);
@@ -902,41 +594,15 @@ void *
serviceThrMain(void *info)
{
serviceThr_t *threadInfo = (serviceThr_t *) info;
- ink_thread ourId;
WebHttpConInfo httpInfo;
- // dg: Added init to get rid of warning, ok since HTTP_THR must be #t
- WebContext *secureCTX = NULL;
-
lmgmt->syslogThrInit();
- // Find out what our Id is. We need to wait
- // for our spawning thread to update the
- // thread info structure
- ink_mutex_acquire(&wGlobals.serviceThrLock);
- ourId = threadInfo->threadId;
-
- // While we have the lock, make a copy of
- // the web context if are on the secure admin port
- if (threadInfo->type == HTTP_THR) {
- secureCTX = (WebContext *) xmalloc(sizeof(WebContext));
- memcpy(secureCTX, &adminContext, sizeof(WebContext));
- }
- ink_mutex_release(&wGlobals.serviceThrLock);
-
-
// Do our work
switch (threadInfo->type) {
case NO_THR: // dg: added to handle init value
ink_assert(false);
break;
- case HTTP_THR:
- httpInfo.fd = threadInfo->fd;
- httpInfo.context = secureCTX;
- httpInfo.clientInfo = threadInfo->clientInfo;
- WebHttpHandleConnection(&httpInfo);
- xfree(secureCTX);
- break;
case AUTOCONF_THR:
httpInfo.fd = threadInfo->fd;
httpInfo.context = &autoconfContext;
@@ -954,8 +620,6 @@ serviceThrMain(void *info)
// Mark ourselves ready to be reaped
ink_mutex_acquire(&wGlobals.serviceThrLock);
- ink_assert(ourId == threadInfo->threadId);
-
threadInfo->waitingForJoin = true;
threadInfo->fd = -1;
Modified: trafficserver/traffic/trunk/mgmt/web2/WebIntrMain.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebIntrMain.h?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebIntrMain.h (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebIntrMain.h Sun Apr 3 18:34:48 2011
@@ -28,8 +28,6 @@
*
* WebIntrMain.h - main loop for the Web Interface
*
- *
- *
****************************************************************************/
struct WebContext;
@@ -38,9 +36,7 @@ struct WebContext;
void *webIntr_main(void *);
void *serviceThrMain(void *info);
-int init_SSL(char *sslCertFile, WebContext * wContext);
-extern int web_port_arg;
extern int aconf_port_arg;
#endif
Modified: trafficserver/traffic/trunk/mgmt/web2/WebOverview.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebOverview.cc?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebOverview.cc (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebOverview.cc Sun Apr 3 18:34:48 2011
@@ -33,7 +33,6 @@
#include "WebOverview.h"
#include "WebGlobals.h"
-#include "WebHttpRender.h"
#include "WebMgmtUtils.h"
#include "LocalManager.h"
Modified: trafficserver/traffic/trunk/mgmt/web2/WebUtils.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebUtils.cc?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebUtils.cc (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebUtils.cc Sun Apr 3 18:34:48 2011
@@ -48,76 +48,8 @@
*/
#define HEAP_H
#define STACK_H
-
#endif // !_WIN32
-/* Converts a printable character to it's six bit representation */
-const unsigned char printableToSixBit[256] = {
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, 64, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
-};
-
-
-#define DECODE(x) printableToSixBit[(unsigned int)x]
-#define MAX_PRINT_VAL 63
-
-int
-UU_decode(const char *inBuffer, int outBufSize, unsigned char *outBuffer)
-{
-
- int inBytes = 0;
- int decodedBytes = 0;
- unsigned char *outStart = outBuffer;
- int inputBytesDecoded = 0;
-
- // Figure out much encoded string is really there
- while (printableToSixBit[(uint8_t)inBuffer[inBytes]] <= MAX_PRINT_VAL) {
- inBytes++;
- }
-
- // Make sure there is sufficient space in the output buffer
- // if not shorten the number of bytes in
- if ((((inBytes + 3) / 4) * 3) > outBufSize - 1) {
- inBytes = ((outBufSize - 1) * 4) / 3;
- }
-
- for (int i = 0; i < inBytes; i += 4) {
-
- outBuffer[0] = (unsigned char) (DECODE(inBuffer[0]) << 2 | DECODE(inBuffer[1]) >> 4);
-
- outBuffer[1] = (unsigned char) (DECODE(inBuffer[1]) << 4 | DECODE(inBuffer[2]) >> 2);
- outBuffer[2] = (unsigned char) (DECODE(inBuffer[2]) << 6 | DECODE(inBuffer[3]));
-
- outBuffer += 3;
- inBuffer += 4;
- decodedBytes += 3;
- inputBytesDecoded += 4;
- }
-
- // Check to see if we decoded a multiple of 4 four
- // bytes
- if ((inBytes - inputBytesDecoded) & 0x3) {
- if (DECODE(inBuffer[-2]) > MAX_PRINT_VAL) {
- decodedBytes -= 2;
- } else {
- decodedBytes -= 1;
- }
- }
-
- outStart[decodedBytes] = '\0';
-
- return decodedBytes;
-}
-
ssize_t
socket_write(SocketInfo socketD, const char *buf, size_t nbyte)
{
Modified: trafficserver/traffic/trunk/mgmt/web2/WebUtils.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebUtils.h?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebUtils.h (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebUtils.h Sun Apr 3 18:34:48 2011
@@ -28,8 +28,6 @@
*
* WebUtils.h - Misc Utility Functions for the web server internface
*
- *
- *
****************************************************************************/
#include "ink_platform.h"
@@ -45,11 +43,9 @@ struct WebContext;
struct SocketInfo
{
int fd;
- void *SSLcon;
+ void *SSLcon; /* Currently unused */
};
-int UU_decode(const char *inBuffer, int outBufSize, unsigned char *outBuffer);
-
ssize_t socket_write(SocketInfo socketD, const char *buf, size_t nbyte);
ssize_t socket_read(SocketInfo socketD, char *buf, size_t nbyte);
int sigfdrdln(SocketInfo socketD, char *s, int len);
Modified: trafficserver/traffic/trunk/proxy/ReverseProxy.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/ReverseProxy.cc?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/ReverseProxy.cc (original)
+++ trafficserver/traffic/trunk/proxy/ReverseProxy.cc Sun Apr 3 18:34:48 2011
@@ -81,7 +81,7 @@ init_reverse_proxy()
REVERSE_RegisterConfigUpdateFunc("proxy.config.url_remap.filename", url_rewrite_CB, (void *) FILE_CHANGED);
REVERSE_RegisterConfigUpdateFunc("proxy.config.proxy_name", url_rewrite_CB, (void *) TSNAME_CHANGED);
REVERSE_RegisterConfigUpdateFunc("proxy.config.reverse_proxy.enabled", url_rewrite_CB, (void *) REVERSE_CHANGED);
- REVERSE_RegisterConfigUpdateFunc("proxy.config.admin.autoconf_port", url_rewrite_CB, (void *) AC_PORT_CHANGED);
+ REVERSE_RegisterConfigUpdateFunc("proxy.config.admin.autoconf.port", url_rewrite_CB, (void *) AC_PORT_CHANGED);
REVERSE_RegisterConfigUpdateFunc("proxy.config.url_remap.default_to_server_pac", url_rewrite_CB, (void *) DEFAULT_TO_PAC_CHANGED);
REVERSE_RegisterConfigUpdateFunc("proxy.config.url_remap.default_to_server_pac_port", url_rewrite_CB, (void *) DEFAULT_TO_PAC_PORT_CHANGED);
REVERSE_RegisterConfigUpdateFunc("proxy.config.url_remap.url_remap_mode", url_rewrite_CB, (void *) URL_REMAP_MODE_CHANGED);
Modified: trafficserver/traffic/trunk/proxy/config/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/config/Makefile.am?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/config/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/config/Makefile.am Sun Apr 3 18:34:48 2011
@@ -36,7 +36,6 @@ dist_sysconf_DATA = \
ip_allow.config.default \
log_hosts.config.default \
logs_xml.config.default \
- mgmt_allow.config.default \
mgr.cnf.default \
parent.config.default \
volume.config.default \
Modified: trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc?rev=1088371&r1=1088370&r2=1088371&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc Sun Apr 3 18:34:48 2011
@@ -516,7 +516,7 @@ UrlRewrite::UrlRewrite(const char *file_
}
REVERSE_ReadConfigInteger(reverse_proxy, "proxy.config.reverse_proxy.enabled");
- REVERSE_ReadConfigInteger(mgmt_autoconf_port, "proxy.config.admin.autoconf_port");
+ REVERSE_ReadConfigInteger(mgmt_autoconf_port, "proxy.config.admin.autoconf.port");
REVERSE_ReadConfigInteger(default_to_pac, "proxy.config.url_remap.default_to_server_pac");
REVERSE_ReadConfigInteger(default_to_pac_port, "proxy.config.url_remap.default_to_server_pac_port");
REVERSE_ReadConfigInteger(url_remap_mode, "proxy.config.url_remap.url_remap_mode");