You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ig...@apache.org on 2011/02/15 01:56:17 UTC
svn commit: r1070712 - in /trafficserver/traffic/trunk/mgmt:
html2/configure/Makefile.am html2/configure/c_basic.ink
html2/configure/c_basic.ink.win web2/WebHttp.cc web2/WebHttpRender.h
Author: igalic
Date: Tue Feb 15 00:56:16 2011
New Revision: 1070712
URL: http://svn.apache.org/viewvc?rev=1070712&view=rev
Log:
[TS-641] removing c_basic.ink
Removed:
trafficserver/traffic/trunk/mgmt/html2/configure/c_basic.ink
trafficserver/traffic/trunk/mgmt/html2/configure/c_basic.ink.win
Modified:
trafficserver/traffic/trunk/mgmt/html2/configure/Makefile.am
trafficserver/traffic/trunk/mgmt/web2/WebHttp.cc
trafficserver/traffic/trunk/mgmt/web2/WebHttpRender.h
Modified: trafficserver/traffic/trunk/mgmt/html2/configure/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/html2/configure/Makefile.am?rev=1070712&r1=1070711&r2=1070712&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/html2/configure/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/html2/configure/Makefile.am Tue Feb 15 00:56:16 2011
@@ -18,8 +18,6 @@ webuidir = $(pkgdatadir)/configure
dist_webui_DATA = \
c_autoconf_pac.ink \
c_autoconf_wpad.ink \
- c_basic.ink \
- c_basic.ink.win \
c_buttons_hide.ink \
c_buttons.ink \
c_cache_general.ink \
Modified: trafficserver/traffic/trunk/mgmt/web2/WebHttp.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebHttp.cc?rev=1070712&r1=1070711&r2=1070712&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebHttp.cc (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebHttp.cc Tue Feb 15 00:56:16 2011
@@ -204,57 +204,6 @@ set_record_value(WebHttpContext * whc, c
}
//-------------------------------------------------------------------------
-// set_config_file
-//-------------------------------------------------------------------------
-
-static bool
-set_config_file(WebHttpContext * whc, char *file_version, char *file_contents, char *file_checksum)
-{
-
- bool err = true;
-
- Rollback *rb;
- textBuffer *tb;
- version_t fversion;
- char frecord[MAX_VAR_LENGTH + 1];
- char fname[MAX_VAL_LENGTH + 1];
- char checksum[MAX_CHECKSUM_LENGTH + 1];
- int file_size;
-
- // coverity[secure_coding]
- if (sscanf(file_version, "%d:%s", &fversion, frecord) == 2) {
- if (varStrFromName(frecord, fname, MAX_VAL_LENGTH)) {
- if (configFiles->getRollbackObj(fname, &rb)) {
- // INKqa12198: remove ^M (CR) from each line in file_contents
- convertHtmlToUnix(file_contents);
- file_size = strlen(file_contents);
- tb = NEW(new textBuffer(file_size + 1));
- tb->copyFrom(file_contents, file_size); //orig
-
- // calculate checksum - skip file update if match checksum
- fileCheckSum(tb->bufPtr(), tb->spaceUsed(), checksum, sizeof(checksum));
- if (strcmp(file_checksum, checksum) != 0) {
- if (rb->updateVersion(tb, fversion) != OK_ROLLBACK) {
- err = false;
- }
- // put note if file update required restart
- if (recordRestartCheck(frecord)) {
- ink_hash_table_insert(whc->submit_note_ht, frecord, 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;
- }
- }
- delete tb;
- }
- }
- }
- return err;
-}
-
-//-------------------------------------------------------------------------
// spawn_cgi
//-------------------------------------------------------------------------
@@ -1048,463 +997,6 @@ Ldone:
}
-
-
-
-
-
-//-------------------------------------------------------------------------
-// handle_submit_snapshot_to_filesystem
-//-------------------------------------------------------------------------
-
-static int
-handle_submit_snapshot_to_filesystem(WebHttpContext * whc, const char *file)
-{
- NOWARN_UNUSED(file);
- int err = 0;
- SnapResult snap_result = SNAP_OK;
- char *submit_from_page;
- char *snap_action;
- char *snap_name;
- char *snap_directory;
- char *snapDirFromRecordsConf;
- char *cancel;
- bool found = false;
- struct stat snapDirStat;
- char config_dir[256];
- char *record_version;
- ExpandingArray snap_list(25, true);
- int num_snaps;
-
- if (varStrFromName("proxy.config.config_dir", config_dir, 256) == false)
- mgmt_fatal(stderr,
- "[WebHttp::handle_submit_snapshot] Unable to find configuration directory from proxy.config.config_dir\n");
-
- // 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)) {
- whc->post_data_ht = NULL;
- goto Ldone;
- }
- // check for record_version
- if (ink_hash_table_lookup(whc->post_data_ht, "record_version", (void **) &record_version)) {
- // TODO: Check return value?
- record_version_valid(record_version);
- ink_hash_table_delete(whc->post_data_ht, "record_version");
- xfree(record_version);
- }
-
- if (ink_hash_table_lookup(whc->post_data_ht, "Change Directory", (void **) &snap_directory)) {
- if (snap_directory == NULL) {
- mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_filesystem] Change Directory not specified.");
- ink_hash_table_insert(whc->submit_warn_ht, "proxy.config.snapshot_dir", snap_directory);
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_MISSING_ENTRY);
- HtmlRndrBr(whc->submit_warn);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- goto Ldone;
- } else {
-#ifndef _WIN32
- const char *valid_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._-/\\";
-#else
- const char *valid_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._-/\\ ";
-#endif
- int snapnameLength = strlen(snap_directory);
- int validnameLength = strspn(snap_directory, valid_chars);
- if (snapnameLength != validnameLength) {
- ink_hash_table_insert(whc->submit_warn_ht, "proxy.config.snapshot_dir", snap_directory);
- 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;
- goto Ldone;
- }
-
- RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf);
- ink_release_assert(found);
- if (snapDirFromRecordsConf == NULL) {
- snapDirFromRecordsConf = new char[strlen("snapshots")];
- snprintf(snapDirFromRecordsConf, strlen("snapshots"), "%s", "snapshots");
- RecSetRecordString("proxy.config.snapshot_dir", snapDirFromRecordsConf);
- }
- if (strcasecmp(snapDirFromRecordsConf, snap_directory)) {
- RecSetRecordString("proxy.config.snapshot_dir", snapDirFromRecordsConf);
- // Create a directory for the snap shot
- if (snap_directory[0] != '/') {
- char *snap_dir_cpy = xstrdup(snap_directory);
- int newLen;
-
- newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
- snap_directory = new char[newLen];
- ink_assert(snap_directory != NULL);
- snprintf(snap_directory, newLen, "%s%s%s", config_dir, DIR_SEP, snap_dir_cpy);
- RecSetRecordString("proxy.config.snapshot_dir", snap_dir_cpy);
- if (snap_dir_cpy)
- free(snap_dir_cpy);
- }
- if (!stat(snap_directory, &snapDirStat)) {
- bool write_possible = true;
- bool read_possible = true;
-#ifndef _WIN32
- if (snapDirStat.st_uid != getuid()) {
- if (snapDirStat.st_gid != getgid()) {
- if (!(snapDirStat.st_mode & 00002)) {
- write_possible = false;
- } else {
- write_possible = true;
- }
- } else {
- if (!(snapDirStat.st_mode & 00020)) {
- write_possible = false;
- } else {
- write_possible = true;
- }
- }
- }
-
- if (snapDirStat.st_uid != getuid()) {
- if (snapDirStat.st_gid != getgid()) {
- if (!(snapDirStat.st_mode & 00004)) {
- read_possible = false;
- } else {
- read_possible = true;
- }
- } else {
- if (!(snapDirStat.st_mode & 00040)) {
- read_possible = false;
- } else {
- read_possible = true;
- }
- }
- }
-#else
- DWORD attr;
- attr = GetFileAttributes(snap_directory);
- if ((attr & FILE_ATTRIBUTE_READONLY) != 0) { // read only dir
- write_possible = false;
- read_possible = false;
- } else {
- write_possible = true;
- read_possible = true;
- }
-#endif // _WIN32
- if (!write_possible) {
- if (!read_possible) {
- ink_hash_table_insert(whc->submit_warn_ht, "proxy.config.snapshot_dir", snap_directory);
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_PERMISSION_DENIED);
- HtmlRndrBr(whc->submit_warn);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- RecSetRecordString("proxy.config.snapshot_dir", snap_directory);
- goto Ldone;
- }
- }
- }
-
- if (stat(snap_directory, &snapDirStat)) {
- SimpleTokenizer snapDirPathTok(snap_directory, '/');
- int dirDepth = snapDirPathTok.getNumTokensRemaining();
-
- for (int i = 1; i <= dirDepth; i++) {
- if (snap_directory[0] == '/') {
- int newLen;
- char *absoluteDir;
- const char *tok = snapDirPathTok.getNext(i);
-
- newLen = strlen(tok) + 2;
- absoluteDir = new char[newLen];
- ink_assert(absoluteDir != NULL);
- snprintf(absoluteDir, newLen, "/%s", tok);
-
-#ifndef _WIN32
- if (mkdir(absoluteDir, DIR_MODE) < 0) {
-#else
- if (mkdir(absoluteDir) < 0) {
-#endif
- perror("[WebHttp::handle_submit_snapshot_to_filesystem] Absolute snapPath Directory creation:");
- }
- delete[]absoluteDir;
- } else {
- const char *tok = snapDirPathTok.getNext(i);
-#ifndef _WIN32
- if (mkdir(tok, DIR_MODE) < 0) {
-#else
- if (mkdir(tok) < 0) {
-#endif
- perror("[WebHttp::handle_submit_snapshot_to_filesystem] Relative snapPath Directory creation:");
- }
- }
- snapDirPathTok.setString(snap_directory);
- }
- }
- }
- }
- }
-
- if (ink_hash_table_lookup(whc->post_data_ht, "SnapshotName", (void **) &snap_name)) {
- if (snap_name != NULL) {
-#ifndef _WIN32
- const char *valid_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._";
-#else
- const char *valid_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._ ";
-#endif
- int snapnameLength = strlen(snap_name);
- int validnameLength = strspn(snap_name, valid_chars);
- if (snapnameLength != validnameLength) {
- ink_hash_table_insert(whc->submit_warn_ht, "SnapShotName", 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;
- goto Ldone;
- }
-
-
- snap_result = configFiles->WalkSnaps(&snap_list);
- if (snap_result == SNAP_OK) {
- num_snaps = snap_list.getNumEntries();
- if (num_snaps > 0) {
- for (int i = 0; i < num_snaps; i++)
- if (!strcmp((char *) snap_list[i], snap_name)) {
- if (ink_hash_table_lookup(whc->post_data_ht, "Delete Snapshot", (void **) &snap_action)) {
- if (ink_hash_table_lookup(whc->post_data_ht, "restore_delete_name", (void **) &snap_action)) {
- if (snap_action != NULL) {
- if (!strcmp(snap_name, snap_action))
- goto Ldelete;
- }
- }
- }
- ink_hash_table_insert(whc->submit_warn_ht, "SnapShotName", NULL);
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_DUPLICATE_ENTRY);
- HtmlRndrBr(whc->submit_warn);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- goto Ldone;
- }
- }
- ink_hash_table_delete(whc->post_data_ht, "SnapshotName");
- }
-
- RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snap_directory);
- ink_release_assert(found);
-
- if (snap_directory[0] != '/') {
- char *snap_dir_cpy = xstrdup(snap_directory);
- int newLen;
-
- newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
- snap_directory = new char[newLen];
- ink_assert(snap_directory != NULL);
- snprintf(snap_directory, newLen, "%s%s%s", config_dir, DIR_SEP, snap_dir_cpy);
- if (snap_dir_cpy)
- free(snap_dir_cpy);
- }
- snap_result = configFiles->takeSnap(snap_name, snap_directory);
- if (snap_result == 3) {
- ink_hash_table_insert(whc->submit_warn_ht, "proxy.config.snapshot_dir", snap_directory);
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_PERMISSION_DENIED);
- HtmlRndrBr(whc->submit_warn);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- RecSetRecordString("proxy.config.snapshot_dir", snap_directory);
- goto Ldone;
- }
- }
- }
-
- if (ink_hash_table_lookup(whc->post_data_ht, "Restore Snapshot", (void **) &snap_action)) {
- if (ink_hash_table_lookup(whc->post_data_ht, "restore_delete_name", (void **) &snap_name)) {
- if (strcmp(snap_name, "- select a snapshot -")) {
- RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf);
- ink_release_assert(found);
- if (snapDirFromRecordsConf[0] != '/') {
- char *snap_dir_cpy = xstrdup(snapDirFromRecordsConf);
- ink_assert(snap_dir_cpy);
- int newLen;
- newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
- snapDirFromRecordsConf = new char[newLen];
- ink_assert(snapDirFromRecordsConf != NULL);
- snprintf(snapDirFromRecordsConf, newLen, "%s%s%s", config_dir, DIR_SEP, snap_dir_cpy);
- if (snap_dir_cpy)
- free(snap_dir_cpy);
- }
- snap_result = configFiles->restoreSnap(snap_name, snapDirFromRecordsConf);
- if (snap_result < 0) {
- mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_filesystem] Restore snapshot failed");
- }
- }
- }
- }
-
-Ldelete:
- if (ink_hash_table_lookup(whc->post_data_ht, "Delete Snapshot", (void **) &snap_action)) {
- if (ink_hash_table_lookup(whc->post_data_ht, "restore_delete_name", (void **) &snap_name)) {
- if (strcmp(snap_name, "- select a snapshot -")) {
- RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf);
- ink_release_assert(found);
- if (snapDirFromRecordsConf[0] != '/') {
- char *snap_dir_cpy = xstrdup(snapDirFromRecordsConf);
- ink_assert(snap_dir_cpy);
- int newLen;
- newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
- snapDirFromRecordsConf = new char[newLen];
- ink_assert(snapDirFromRecordsConf != NULL);
- snprintf(snapDirFromRecordsConf, newLen, "%s%s%s", config_dir, DIR_SEP, snap_dir_cpy);
- if (snap_dir_cpy)
- free(snap_dir_cpy);
- }
- snap_result = configFiles->removeSnap(snap_name, snapDirFromRecordsConf);
- if (snap_result < 0) {
- mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_filesystem] Remove snapshot failed");
- }
- }
- }
- }
-
-
-
-Ldone:
- if (submit_from_page) {
- err = WebHttpRender(whc, submit_from_page);
- xfree(submit_from_page);
- } else {
- err = WebHttpRender(whc, HTML_DEFAULT_CONFIGURE_FILE);
- }
- return err;
-}
-
-
-//-------------------------------------------------------------------------
-// handle_submit_inspector
-//-------------------------------------------------------------------------
-static int
-handle_submit_inspector(WebHttpContext * whc, const char *file)
-{
- NOWARN_UNUSED(file);
- int err = 0;
- char *submit_from_page;
- char *regex;
- char *regex_action;
- char *list;
-
- // 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;
- }
-
- // FIXME: button names here are going to be hard to
- // internationalize. we should put the button names into the
- // dictionary.
-
- // handle URL Regex operation
- if (ink_hash_table_lookup(whc->post_data_ht, "regex_op", (void **) ®ex_action)) {
- if (strcmp(regex_action, "Lookup") == 0) {
- // handle regex lookup
- if (ink_hash_table_lookup(whc->post_data_ht, "regex", (void **) ®ex)) {
- if ((err = TSLookupFromCacheUrlRegex(regex, &list)) == TS_ERR_OKAY) {
- whc->cache_query_result = list;
- }
- }
- } else if (strcmp(regex_action, "Delete") == 0) {
- // handle regex delete
- if (ink_hash_table_lookup(whc->post_data_ht, "regex", (void **) ®ex)) {
- if ((err = TSDeleteFromCacheUrlRegex(regex, &list)) == TS_ERR_OKAY) {
- whc->cache_query_result = list;
- }
- }
- } else if (strcmp(regex_action, "Invalidate") == 0) {
- // handle regex invalidate
- if (ink_hash_table_lookup(whc->post_data_ht, "regex", (void **) ®ex)) {
- if ((err = TSInvalidateFromCacheUrlRegex(regex, &list)) == TS_ERR_OKAY) {
- whc->cache_query_result = list;
- }
- }
- }
- }
- // Error: unknown action
- else {
- mgmt_log(stderr, "Unknown action is specified.");
- }
-
- if (err != TS_ERR_OKAY) {
- // FIXME: show alarm error for cache inspector!
- }
-
- if (submit_from_page) {
- err = WebHttpRender(whc, submit_from_page);
- xfree(submit_from_page);
- } else {
- err = WebHttpRender(whc, HTML_DEFAULT_CONFIGURE_FILE);
- }
- return err;
-}
-
-
-//-------------------------------------------------------------------------
-// handle_submit_inspector_display
-//-------------------------------------------------------------------------
-
-static int
-handle_submit_inspector_display(WebHttpContext * whc, const char *file)
-{
- NOWARN_UNUSED(file);
- int err = 0;
- char *url;
- char *url_action;
- char *buf;
- InkHashTable *ht;
- InkHashTable *query_ht;
-
- // processFormSubmission will substituteUnsafeChars()
- ht = whc->query_data_ht;
- // extract some basic info for easier access later
- if (ink_hash_table_lookup(ht, "url_op", (void **) &url_action)) {
- // handle URL operation
- if (strcmp(url_action, "Lookup") == 0) {
- // handle url lookup
- if (ink_hash_table_lookup(ht, "url", (void **) &url)) {
- if ((err = TSLookupFromCacheUrl(url, &buf)) == TS_ERR_OKAY) {
- whc->cache_query_result = buf;
- }
- }
- } else if (strcmp(url_action, "Delete") == 0) {
- // the url that cache_inspector takes has to be w/o substituteUnsafeChars()
- if ((query_ht = processFormSubmission_noSubstitute((char *) (whc->request->getQuery()))) != NULL) {
- if (ink_hash_table_lookup(query_ht, "url", (void **) &url)) {
- // handle url delete
- if ((err = TSDeleteFromCacheUrl(url, &buf)) == TS_ERR_OKAY) {
- whc->cache_query_result = buf;
- }
- }
- ink_hash_table_destroy_and_xfree_values(query_ht);
- }
- }
- }
- // Error: unknown action
- else {
- mgmt_log(stderr, "Unknown action is specified.");
- }
-
- err = WebHttpRender(whc, HTML_INSPECTOR_DISPLAY_FILE);
- return err;
-}
-
//-------------------------------------------------------------------------
// handle_submit_view_logs
//-------------------------------------------------------------------------
@@ -1624,165 +1116,6 @@ Ldone:
}
//-------------------------------------------------------------------------
-// handle_submit_update
-//-------------------------------------------------------------------------
-
-static int
-handle_submit_update(WebHttpContext * whc, const char *file)
-{
- NOWARN_UNUSED(file);
- int err;
- char *submit_from_page;
- bool recs_out_of_date;
- bool file_out_of_date;
- char *record_version;
- char *file_version;
- char *file_contents;
- char *file_checksum;
- char *apply;
- char *cancel;
- char *clear;
- char *clear_cluster;
- bool use_ssl_updated;
-
- // 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 restart
- if (ink_hash_table_lookup(whc->post_data_ht, "restart", (void **) &cancel)) {
-#if TS_HAS_WEBUI
- char *link = WebHttpGetLink_Xmalloc(HTML_DEFAULT_CONFIGURE_FILE);
- whc->response_hdr->setRefreshURL(link);
- xfree(link);
-#endif
- lmgmt->ccom->sendClusterMessage(CLUSTER_MSG_SHUTDOWN_MANAGER);
- whc->response_hdr->setRefresh(15);
- if (submit_from_page)
- xfree(submit_from_page);
- submit_from_page = xstrdup("/restart.ink");
- goto Ldone;
- }
- // check for clear statistics
- if (ink_hash_table_lookup(whc->post_data_ht, "clear_stats", (void **) &clear)) {
- lmgmt->clearStats();
- goto Ldone;
- }
- // check for cluster clear statistics
- if (ink_hash_table_lookup(whc->post_data_ht, "clear_cluster_stats", (void **) &clear_cluster)) {
- lmgmt->clearStats();
- lmgmt->ccom->sendClusterMessage(CLUSTER_MSG_CLEAR_STATS);
- goto Ldone;
- }
- // check for roll_logs
- if (ink_hash_table_lookup(whc->post_data_ht, "roll_logs", (void **) &cancel)) {
- lmgmt->rollLogFiles();
- goto Ldone;
- }
- // check for apply
- if (ink_hash_table_lookup(whc->post_data_ht, "apply", (void **) &apply)) {
- ink_hash_table_delete(whc->post_data_ht, "apply");
- xfree(apply);
- }
- // check for record_version
- recs_out_of_date = true;
- if (ink_hash_table_lookup(whc->post_data_ht, "record_version", (void **) &record_version)) {
- // TODO: Check return value?
- recs_out_of_date = !record_version_valid(record_version);
- ink_hash_table_delete(whc->post_data_ht, "record_version");
- xfree(record_version);
- }
- // check for a file_version and file_contents
- file_out_of_date = false;
- if (ink_hash_table_lookup(whc->post_data_ht, "file_version", (void **) &file_version)) {
- if (ink_hash_table_lookup(whc->post_data_ht, "file_contents", (void **) &file_contents)) {
- file_out_of_date = true;
- if (ink_hash_table_lookup(whc->post_data_ht, "file_checksum", (void **) &file_checksum)) {
- if (!file_version) {
- file_version = (char *) xstrdup("");
- }
- if (!file_contents) {
- file_contents = (char *) xstrdup("");
- }
- if (!file_checksum) {
- file_checksum = (char *) xstrdup("");
- }
- file_out_of_date = !set_config_file(whc, file_version, file_contents, file_checksum);
- ink_hash_table_delete(whc->post_data_ht, "file_checksum");
- if (file_checksum)
- xfree(file_checksum);
- }
- ink_hash_table_delete(whc->post_data_ht, "file_contents");
- if (file_contents)
- xfree(file_contents);
- }
- ink_hash_table_delete(whc->post_data_ht, "file_version");
- if (file_version)
- xfree(file_version);
- }
- // everything else should be records. if the user modifies the
- // 'proxy.config.admin.use_ssl' variable, we'll have to redirect
- // them appropriately.
- use_ssl_updated = false;
- if (!recs_out_of_date) {
- InkHashTableIteratorState htis;
- InkHashTableEntry *hte;
- char *record;
- char *value;
- for (hte = ink_hash_table_iterator_first(whc->post_data_ht, &htis);
- hte != NULL; hte = ink_hash_table_iterator_next(whc->post_data_ht, &htis)) {
- record = (char *) ink_hash_table_entry_key(whc->post_data_ht, hte);
- value = (char *) ink_hash_table_entry_value(whc->post_data_ht, hte);
- // check for ssl redirect
- if (strcasecmp(record, "proxy.config.admin.use_ssl") == 0) {
- char use_ssl_value[MAX_VAL_LENGTH]; // The value of the current variable
- if ((varStrFromName(record, use_ssl_value, MAX_VAL_LENGTH)) && (ink_atoi(value) != ink_atoi(use_ssl_value))
- ) {
- use_ssl_updated = true;
- }
- }
- }
- }
- // warn if out of date submission
- if (recs_out_of_date || file_out_of_date) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_OUT_OF_DATE);
- HtmlRndrBr(whc->submit_warn);
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- }
-
- if (use_ssl_updated) {
- if (submit_from_page) {
- xfree(submit_from_page);
- }
- submit_from_page = xstrdup("/ssl_redirect.ink");
- }
-
-#if TS_HAS_WEBUI
- if (submit_from_page && strcmp(submit_from_page, HTML_FEATURE_ON_OFF_FILE) == 0) {
- WebHttpTreeRebuildJsTree();
- }
-#endif
-
-Ldone:
- if (submit_from_page) {
- err = WebHttpRender(whc, submit_from_page);
- xfree(submit_from_page);
- } else {
- err = WebHttpRender(whc, HTML_DEFAULT_CONFIGURE_FILE);
- }
- return err;
-
-}
-
-//-------------------------------------------------------------------------
// handle_submit_update_config
//-------------------------------------------------------------------------
// This handler is called when submit a post form for Configuration File Editor.
@@ -2005,383 +1338,6 @@ SetWarning(WebHttpContext * whc, char *a
whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
}
-//-------------------------------------------------------------------------
-// handle_submit_net_config
-//-------------------------------------------------------------------------
-// This handler is called when user wants to setup network of the appliance
-
-static int
-handle_submit_net_config(WebHttpContext * whc, const char *file)
-{
- NOWARN_UNUSED(file);
- char *cancel;
- char *record_version;
- char *submit_from_page;
-// FILE* tmp;
-
-// tmp=fopen("tmp","a");
-// fprintf(tmp,"enter submit\n");
-
- 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))
- return WebHttpRender(whc, submit_from_page);
-
- // check for record_version
- if (ink_hash_table_lookup(whc->post_data_ht, "record_version", (void **) &record_version)) {
- // TODO: Check return value?
- 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;
-
-#if defined(linux) || defined(solaris)
-
- InkHashTableIteratorState htis;
- InkHashTableEntry *hte;
- char *key;
- char *value;
- int hn_change, gw_change, dn_change, dns_change;
- int nic_change[5];
- // int nic_up[5];
- char *dns_ip[3], old_value[265], old_hostname[80], old_gw_ip[80];
- char nic_name[5][10], *nic[5][6], interface[80], *param;
- char *hostname = 0, *gw_ip = 0;
- const char *dn = 0;
- int i, j, no;
- char dns_ips[80];
- bool warning, fail;
-
- //This will be used as flags to verify whether anything changed by the user
- hn_change = 0;
- gw_change = 0;
- dn_change = 0;
- dns_change = 0;
- warning = (fail = false);
- //FIXNOW - we need to use SysAPI to find the numver of NICs instead of just constant 5
- for (i = 0; i < 5; i++) {
- nic_change[i] = 0;
- ink_strncpy(nic_name[i], "", 1);
- for (j = 0; j < 6; j++) {
- nic[i][j] = NULL;
- }
- }
-
- int old_euid;
- Config_User_Root(&old_euid);
- // Get the values the user entered
- for (hte = ink_hash_table_iterator_first(whc->post_data_ht, &htis);
- hte != NULL; hte = ink_hash_table_iterator_next(whc->post_data_ht, &htis)) {
- key = (char *) ink_hash_table_entry_key(whc->post_data_ht, hte);
- value = (char *) ink_hash_table_entry_value(whc->post_data_ht, hte);
-
-// fprintf(stderr,"key=%s, value=%s\n",key,value);
-
- if (strcmp(key, "HOSTNAME") == 0) {
- hostname = value;
- if (!Net_IsValid_Hostname(hostname)) {
- SetWarning(whc, key);
- warning = true;
- } else {
- if (!Config_GetHostname(old_value, sizeof(old_value))) {
- if (hostname != NULL && strcmp(hostname, old_value) != 0) {
- hn_change = 1;
- ink_strncpy(old_hostname, old_value, sizeof(old_hostname)); //old hostname is used in MGMT API
- }
- } else if (hostname != NULL) {
- hn_change = 1;
- }
- }
- } else if (strcmp(key, "GATEWAY") == 0) {
- gw_ip = value;
- if (!Net_IsValid_IP(gw_ip)) {
- SetWarning(whc, key);
- warning = true;
- } else {
- if (!Config_GetDefaultRouter(old_value, sizeof(old_value))) {
- if (gw_ip != NULL && strcmp(gw_ip, old_value) != 0) {
- ink_strncpy(old_gw_ip, old_value, sizeof(old_gw_ip));
- gw_change = 1;
- }
- } else if (gw_ip != NULL) {
- gw_change = 1;
- }
- }
- } else if (strcmp(key, "domain") == 0) {
- dn = value;
- if (!Config_GetDomain(old_value, sizeof(old_value))) {
- if (dn != NULL && strcmp(dn, old_value) != 0) {
- dn_change = 1;
- } else if (dn == NULL) {
- dn_change = 1;
- dn = "";
- }
- } else if (dn != NULL) {
- dn_change = 1;
- }
- } else if (strstr(key, "DNS") != NULL) {
- no = atoi(key + 3) - 1;
- dns_ip[no] = value;
- if (!Net_IsValid_IP(dns_ip[no])) {
- SetWarning(whc, key);
- warning = true;
- } else {
- if (Config_GetDNS_Server(old_value, sizeof(old_value), no)) {
- if (dns_ip[no] != NULL && strcmp(dns_ip[no], old_value) != 0) {
- dns_change = 1;
- } else if (dns_ip[no] == NULL) {
- dns_change = 1;
- }
- } else if (dns_ip[no] != NULL) {
- dns_change = 1;
- }
- }
- } else if (strstr(key, "NIC") != NULL) {
- ink_strncpy(interface, key + 4, sizeof(interface));
- param = strchr(interface, '_');
- *param = '\0';
- param++;
- no = atoi(interface + 3);
- ink_strncpy(nic_name[no], interface, sizeof(nic_name[no]));
-
- //No DHCP support any more, hacking way is set it be static always
- nic[no][2] = xstrdup("1");
- if (strcmp(param, "enabled") == 0) {
- nic[no][0] = value;
-
- if (no == 0) {
- //FIXNOW use SysAPI
- if (strcmp(nic[no][0], "0") == 0) {
- SetWarning(whc, key);
- warning = true;
- }
- }
- //FIXNOW - Use SysAPI
- Config_GetNIC_Status(interface, old_value, sizeof(old_value));
- if (strcmp(old_value, "up") == 0 && strcmp(nic[no][0], "0") == 0) {
- nic_change[no] = 1;
- } else if (strcmp(old_value, "down") == 0 && strcmp(nic[no][0], "1") == 0) {
- nic_change[no] = 1;
- }
- } else if (strcmp(param, "ONBOOT") == 0) {
- nic[no][1] = value;
-
- if (no == 0) {
- //FIXNOW use SysAPI
- if (strcmp(nic[no][1], "0") == 0) {
- SetWarning(whc, key);
- warning = true;
- }
- }
- //FIXNOW - Use SysAPI
- if (!Config_GetNIC_Start(interface, old_value, sizeof(old_value))) {
- if (strcmp(nic[no][1], "1") == 0 && strcmp(old_value, "not-onboot") == 0) {
- nic_change[no] = 1;
- } else if (strcmp(nic[no][1], "0") == 0 && strcmp(old_value, "onboot") == 0) {
- nic_change[no] = 1;
- }
- } else {
- nic_change[no] = 1;
- }
- } else if (strcmp(param, "BOOTPROTO") == 0) {
- nic[no][2] = value;
- //FIXNOW - Use SysAPI
- if (!Config_GetNIC_Protocol(interface, old_value, sizeof(old_value))) {
- if (strcmp(nic[no][2], "0") == 0 && (strcmp(old_value, "none") == 0 || strcmp(old_value, "static") == 0)) {
- nic_change[no] = 1;
- } else if (strcmp(nic[no][2], "1") == 0 && strcmp(old_value, "dhcp") == 0) {
- nic_change[no] = 1;
- }
- } else {
- nic_change[no] = 1;
- }
-
- //currently, force the protocol to become static if the old one is dhcp
- if (strcmp(old_value, "dhcp") == 0) {
- // XXX - changed it so we don't change value and instead duplicate the string
- nic[no][2] = xstrdup("1");
- nic_change[no] = 1;
- }
- } else if (strcmp(param, "IPADDR") == 0) {
- nic[no][3] = value;
- //FIXNOW - Use SysAPI
- if (!Net_IsValid_IP(nic[no][3])) {
- SetWarning(whc, key);
- warning = true;
- }
- //FIXNOW - Use SysAPI
- if (!Config_GetNIC_IP(interface, old_value, sizeof(old_value))) {
- if (nic[no][3] != NULL && strcmp(nic[no][3], old_value) != 0) {
- nic_change[no] = 1;
- }
- //For dhcp start, the static IP maybe same with the dhcp value
- else {
- char protocol[80];
- Config_GetNIC_Protocol(interface, protocol, sizeof(protocol));
- if (strcmp(protocol, "dhcp") == 0) {
- nic_change[no] = 1;
- }
-
- if (nic[no][3] == NULL) {
- nic_change[no] = 1;
- }
- }
- } else if (nic[no][3] != NULL) {
- nic_change[no] = 1;
- }
- } else if (strcmp(param, "NETMASK") == 0) {
- nic[no][4] = value;
- //FIXNOW - Use SysAPI
- if (!Net_IsValid_IP(nic[no][4])) {
- SetWarning(whc, key);
- warning = true;
- }
- //FIXNOW - Use SysAPI
- if (!Config_GetNIC_Netmask(interface, old_value, sizeof(old_value))) {
- if (nic[no][4] != NULL && strcmp(nic[no][4], old_value) != 0) {
- nic_change[no] = 1;
- }
- //For dhcp start, the static netmask maybe same with the dhcp value
- else {
- char protocol[80];
- Config_GetNIC_Protocol(interface, protocol, sizeof(protocol));
- if (strcmp(protocol, "dhcp") == 0) {
- nic_change[no] = 1;
- }
-
- if (nic[no][4] == NULL) {
- nic_change[no] = 1;
- }
- }
- } else if (nic[no][4] != NULL) {
- nic_change[no] = 1;
- }
- } else if (strcmp(param, "GATEWAY") == 0) {
- nic[no][5] = value;
- //FIXNOW - Use SysAPI
- if (!Net_IsValid_IP(nic[no][5])) {
- SetWarning(whc, key);
- warning = true;
- }
- //FIXNOW - Use SysAPI
- if (!Config_GetNIC_Gateway(interface, old_value, sizeof(old_value))) {
- if (nic[no][5] != NULL && strcmp(nic[no][5], old_value) != 0) {
- nic_change[no] = 1;
- }
- //For dhcp start, the gateway maybe same with the dhcp value
- else {
- char protocol[80];
- Config_GetNIC_Protocol(interface, protocol, sizeof(protocol));
- if (strcmp(protocol, "dhcp") == 0) {
- nic_change[no] = 1;
- }
-
- if (nic[no][5] == NULL) {
- nic_change[no] = 1;
- }
- }
- } else if (nic[no][5] != NULL) {
- nic_change[no] = 1;
- }
- }
- }
- }
- Config_User_Inktomi(old_euid);
-
- if (!warning) {
- if (hn_change) {
- if (Config_SetHostname(hostname) != 0) {
- fail = true;
- }
- }
- if (gw_change) {
- if (Config_SetDefaultRouter(gw_ip) != 0) {
- fail = true;
- }
- }
- if (dn_change) {
- if (Config_SetDomain(dn) != 0) {
- fail = true;
- }
- }
- if (dns_change) {
- ink_strncpy(dns_ips, "", sizeof(dns_ips));
- //FIXNOW - do we have no. of dns servers from SysAPI?
- for (i = 0; i < 3; i++) {
- if (dns_ip[i] != NULL) {
- strncat(dns_ips, dns_ip[i], sizeof(dns_ips) - strlen(dns_ips) - 1);
- strncat(dns_ips, " ", sizeof(dns_ips) - strlen(dns_ips) - 1);
- }
- }
-
- if (Config_SetDNS_Servers(dns_ips) != 0) {
- fail = true;
- }
- }
- //FIXNOW - get the no. from SysAPI
- for (i = 0; i < 5; i++) {
- if (strlen(nic_name[i]) != 0) {
- if (nic_change[i]) {
- if (nic[i][0] != NULL && strcmp(nic[i][0], "1") == 0) {
- char onboot[20], protocol[20];
- if (strcmp(nic[i][1], "1") == 0) {
- ink_strncpy(onboot, "onboot", sizeof(onboot));
- } else {
- ink_strncpy(onboot, "not-onboot", sizeof(onboot));
- }
-
- if (strcmp(nic[i][2], "1") == 0) {
- ink_strncpy(protocol, "static", sizeof(protocol));
- } else {
- ink_strncpy(protocol, "dhcp", sizeof(protocol));
- }
- if (Config_SetNIC_Up(nic_name[i], onboot, protocol, nic[i][3], nic[i][4], nic[i][5]) != 0) {
- fail = true;
- }
- } else {
- char status[80];
- Config_GetNIC_Status(nic_name[i], status, sizeof(status));
- if (strcmp(status, "up") == 0) { //NIC is disabled
- if (Config_SetNIC_Down(nic_name[i]) != 0) {
- fail = true;
- }
- } else { //NIC is down&changed, such changes are disallowed.
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_NETWORK_CONFIG_DISALLOW);
- HtmlRndrBr(whc->submit_warn);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- }
- } //nic[i][0]
- } //nic_change
- } //nic_name
- } //for
- } //warning
-//FIXME, need a complete fail message system
- if (fail == true) {
- if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
- HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_NETWORK_CONFIG_FAIL);
- HtmlRndrBr(whc->submit_warn);
- }
- whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
- }
-
- if (hn_change) {
- if (submit_from_page)
- xfree(submit_from_page);
- submit_from_page = xstrdup("/rename.ink");
- }
-#endif
- return WebHttpRender(whc, submit_from_page);
-}
-
//-------------------------------------------------------------------------
// handle_default
@@ -2802,15 +1758,9 @@ WebHttpInit()
ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_ALARM_FILE, (void *) handle_submit_alarm);
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_SNAPSHOT_FILESYSTEM,
- (void *) handle_submit_snapshot_to_filesystem);
- ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_INSPECTOR_FILE, (void *) handle_submit_inspector);
- ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_INSPECTOR_DPY_FILE, (void *) handle_submit_inspector_display);
ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_VIEW_LOGS_FILE, (void *) handle_submit_view_logs);
- ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_UPDATE_FILE, (void *) handle_submit_update);
ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_UPDATE_CONFIG, (void *) handle_submit_update_config);
ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_CONFIG_DISPLAY, (void *) handle_submit_config_display);
- ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_NET_CONFIG, (void *) handle_submit_net_config);
// initialize file bindings
g_file_bindings_ht = ink_hash_table_create(InkHashTableKeyType_String);
ink_hash_table_insert(g_file_bindings_ht, HTML_CHART_FILE, (void *) handle_chart);
Modified: trafficserver/traffic/trunk/mgmt/web2/WebHttpRender.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/web2/WebHttpRender.h?rev=1070712&r1=1070711&r2=1070712&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/web2/WebHttpRender.h (original)
+++ trafficserver/traffic/trunk/mgmt/web2/WebHttpRender.h Tue Feb 15 00:56:16 2011
@@ -391,7 +391,6 @@
#define HTML_TREE_HEADER_FILE "/include/tree_header.ink"
#define HTML_TREE_FOOTER_FILE "/include/tree_footer.ink"
#define HTML_DEFAULT_MONITOR_FILE "/monitor/m_overview.ink"
-#define HTML_DEFAULT_CONFIGURE_FILE "/configure/c_basic.ink"
#define HTML_FEATURE_ON_OFF_FILE "/configure/c_basic.ink"
#define HTML_DEFAULT_HELP_FILE "/help/ts.ink"