trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject svn commit: r941419 [2/4] - in /trafficserver/traffic/trunk: proxy/logging/ proxy/mgmt2/ proxy/mgmt2/api2/ proxy/mgmt2/api2/include/ proxy/mgmt2/cluster/ proxy/mgmt2/tools/ proxy/mgmt2/utils/ proxy/mgmt2/web2/ test/SDKtest/synth_server/ test/plugin/INK...
Date Wed, 05 May 2010 18:35:53 GMT
Modified: trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc?rev=941419&r1=941418&r2=941419&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc Wed May  5 18:35:52 2010
@@ -58,12 +58,6 @@
 
 #include "ConfigAPI.h"
 #include "SysAPI.h"
-#if defined(OEM)
-#include "CfgContextManager.h"
-#include "CoreAPI.h"
-#include "SysAPI.h"
-#include "XmlUtils.h"
-#endif
 
 #ifdef HAVE_LIBSSL
 #include "openssl/ssl.h"
@@ -197,14 +191,6 @@ set_record_value(WebHttpContext * whc, c
         xfree(script_path);
       }
 #endif
-#ifdef OEM
-      if (strcasecmp(record, "proxy.config.http.server_port") == 0) {
-        int status = INKSetProxyPort(value);
-        if (status) {
-          DPRINTF(("WebHTTP: INKSetProxyPort returned %d\n", status));
-        }
-      }
-#endif
     } else {
       ink_hash_table_insert(whc->submit_warn_ht, record, NULL);
       if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
@@ -1538,231 +1524,8 @@ Ldone:
 }
 
 
-#ifdef OEM
-//-------------------------------------------------------------------------
-// handle_submit_session
-//-------------------------------------------------------------------------
-
-static int
-handle_submit_session(WebHttpContext * whc, const char *file)
-{
-
-  int err;
-  int restart;
-  char *submit_from_page;
-  bool recs_out_of_date;
-  bool file_out_of_date;
-  bool found;
-  char *record_version;
-  char *file_version;
-  char *sessionTimout;
-  char *session;
-  char *apply;
-  char *cancel;
-  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;
-  }
-
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "apply", (void **) &apply)) {
-    if (ink_hash_table_lookup(whc->post_data_ht, "proxy.config.admin.session", (void **) &session)) {
-      RecInt SessionValue = atoi(session);
-      RecSetRecordInt("proxy.config.admin.session", SessionValue);
-    }
-    if (ink_hash_table_lookup(whc->post_data_ht, "proxy.config.admin.session.timeout", (void **) &sessionTimout)) {
-      if (sessionTimout != NULL) {
-        const char *valid_chars = "1234567890";
-        int sessionTimeoutDigits = strlen(sessionTimout);
-        int validnameLength = strspn(sessionTimout, valid_chars);
-        if (sessionTimeoutDigits != validnameLength) {
-          ink_hash_table_insert(whc->submit_warn_ht, "proxy.config.admin.session.timeout", sessionTimout);
-          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;
-        }
-
-        MgmtInt sessionTimeoutIntegerValue = atoi(sessionTimout);
-        if (sessionTimeoutIntegerValue <= 30) {
-          ink_hash_table_insert(whc->submit_warn_ht, "proxy.config.admin.session.timeout", sessionTimout);
-          if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-            HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_SESSION_VALUE_LIMIT);
-            HtmlRndrBr(whc->submit_warn);
-          }
-          whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-          goto Ldone;
-        }
-
-        RecSetRecordInt("proxy.config.admin.session.timeout", (RecInt) sessionTimeoutIntegerValue);
-      }
-    }
-  }
-
-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_relogin
-//-------------------------------------------------------------------------
-
-static int
-handle_submit_relogin(WebHttpContext * whc, const char *file)
-{
-
-  int err;
-  int restart;
-  char *submit_from_page;
-  bool recs_out_of_date;
-  bool file_out_of_date;
-  bool found;
-  char *record_version;
-  char *file_version;
-  char *sessionTimout;
-  char *session;
-  char *apply;
-  char *cancel;
-  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;
-  }
-
-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;
-
-}
-
-#endif //OEM
-
-#ifdef OEM
-#if (HOST_OS == linux)
-char *
-insertquotes(char *find)
-{
-  char *newword = new char[1024];
-  newword[0] = '\0';
-  strcat(newword, "\"");
-  strcat(newword, find);
-  strcat(newword, "\"");
-  return newword;
-}
-#endif
-#endif
-
-#ifdef OEM
-#if (HOST_OS == linux)
-//------------------------------------------------------------------------
-//handle_submit_snmp_config
-//------------------------------------------------------------------------
-
-static int
-handle_submit_snmp_config(WebHttpContext * whc, const char *file)
-{
-  int err = WEB_HTTP_ERR_OKAY;
-  char *dummy;
-  char *temp;
-  char *submit_from_page, *link;
-  char *record_version, *systemname, *syslocation, *syscontact, *authenable, *trapcommun, *traphost, *enabled,
-    *disabled, *auth_enabled;
-  bool warning = false, apply = false, restart = false, fail = false;
-  int old_euid;
-  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 (ink_hash_table_lookup(whc->post_data_ht, "cancel", (void **) &dummy)) {
-    goto Ldone;
-  }
-  if (ink_hash_table_lookup(whc->post_data_ht, "apply", (void **) &dummy)) {
-    apply = true;
-    restart = true;
-  }
-
-  ink_hash_table_lookup(whc->post_data_ht, "SNMP_SYSTEM_NAME", (void **) &systemname);
-  ink_hash_table_lookup(whc->post_data_ht, "SYS_LOCATION", (void **) &syslocation);
-  ink_hash_table_lookup(whc->post_data_ht, "SYS_CONTACT", (void **) &syscontact);
-  ink_hash_table_lookup(whc->post_data_ht, "COMMUNITY_NAME", (void **) &trapcommun);
-  ink_hash_table_lookup(whc->post_data_ht, "SNMP_TRAP_IP", (void **) &traphost);
-  ink_hash_table_lookup(whc->post_data_ht, "AUTH_TRAP_ENABLE", (void **) &authenable);
-  ink_hash_table_lookup(whc->post_data_ht, "auth_trap_enable", (void **) &enabled);
-  ink_hash_table_lookup(whc->post_data_ht, "auth_trap_disable", (void **) &disabled);
-
-  temp = insertquotes(systemname);
-  strcpy(systemname, temp);
-  delete[]temp;
-  temp = insertquotes(syscontact);
-  strcpy(syscontact, temp);
-  delete[]temp;
-  temp = insertquotes(syslocation);
-  strcpy(syslocation, temp);
-  delete[]temp;
-  Config_User_Root(&old_euid);
-  if (apply) {
-
-    if (!Net_IsValid_IP(traphost)) {
-      //SetWarning(whc, "SNMP_TRAP_IP");
-      warning = true;
-    }
-
-    if (!(warning)) {
-      if (Config_SNMPSetUp(syslocation, syscontact, systemname, authenable, trapcommun, traphost) != 0)
-        fail = true;
-    }
-  }
-  if (fail) {
-    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;
-  }
-
-  Config_User_Inktomi(old_euid);
 
 
-Ldone:
-  err = WebHttpRender(whc, submit_from_page);
-  return err;
-}
-#endif
-#endif
 
 
 //-------------------------------------------------------------------------
@@ -2311,36 +2074,6 @@ handle_submit_snapshot_to_filesystem(Web
       }
     }
   }
-#if defined(OEM)
-
- /**
-  Save the current system and network settings.
- **/
-  char *NWSnapshotType;
-  if (ink_hash_table_lookup(whc->post_data_ht, "NWSnapshot", (void **) &NWSnapshotType)) {
-    if (NWSnapshotType != NULL) {
-      if (strcmp(NWSnapshotType, "Network Settings Snapshot") == 0) {
-        int newLen;
-        newLen = strlen(config_dir) + strlen("net.config.xml") + 2;
-        char *fileName = new char[newLen];
-        ink_assert(fileName != NULL);
-        ink_snprintf(fileName, newLen, "%s%s%s", config_dir, DIR_SEP, "net.config.xml");
-        unlink(fileName);
-        Config_SaveNetConfig(fileName);
-      }
-    }
-  } else                        //NWSnapshot=NULL
-  {
-    int Len = strlen(config_dir) + strlen("net.config.xml") + 2;
-    char *fName = new char[Len];
-    ink_assert(fName != NULL);
-    ink_snprintf(fName, Len, "%s%s%s", config_dir, DIR_SEP, "net.config.xml");
-    unlink(fName);
-    Config_SaveVersion(fName);
-  }
-
-
-#endif //OEM
 
   if (ink_hash_table_lookup(whc->post_data_ht, "SnapshotName", (void **) &snap_name)) {
     if (snap_name != NULL) {
@@ -2464,41 +2197,6 @@ Ldelete:
       }
     }
   }
-#if defined(OEM)
-
- /**
-  Restore the current system and network settings.
- **/
-  if (ink_hash_table_lookup(whc->post_data_ht, "Restore Network Snapshot", (void **) &NWSnapshotType)) {
-    if (NWSnapshotType != NULL) {
-
-      if (strcmp(NWSnapshotType, "Restore NW Snapshot") == 0) {
-        int newLen;
-        newLen = strlen(config_dir) + strlen("net.config.xml") + 3;
-        char *fileName = new char[newLen];
-        ink_assert(fileName != NULL);
-        ink_snprintf(fileName, newLen, "%s%s%s", config_dir, DIR_SEP, "net.config.xml");
-
-        int pid = 0;
-        if ((pid = fork()) < 0) {
-          goto Ldone;
-        } else if (pid == 0) {
-          Config_RestoreNetConfig(fileName);
-          //goto Ldone;
-          _exit(0);
-        }
-
-        char *link = WebHttpGetLink_Xmalloc("/configure/c_snapshot_filesystem.ink");
-        whc->response_hdr->setRefresh(60);
-        whc->response_hdr->setRefreshURL(link);
-        if (submit_from_page)
-          xfree(submit_from_page);
-        submit_from_page = xstrdup("/restart.ink");
-        xfree(link);
-      }
-    }
-  }
-#endif //OEM
 
 
 
@@ -2543,9 +2241,6 @@ handle_submit_snapshot_to_ftpserver(WebH
   char config_dir[256];
   bool recs_out_of_date;
   char *record_version;
-#if defined(OEM)
-  char *NWSnapshotType;
-#endif
   ExpandingArray snap_list(25, true);
 
   if (varStrFromName("proxy.config.config_dir", config_dir, 256) == false)
@@ -2688,77 +2383,13 @@ handle_submit_snapshot_to_ftpserver(WebH
       }
       snap_result = configFiles->restoreSnap(snap_name, tempDirFromRecordsConf);
       snap_result = configFiles->removeSnap(snap_name, tempDirFromRecordsConf);
-#if defined(OEM)
-
-           /**
-            Restore the current system and network settings.
-           **/
-      if (ink_hash_table_lookup(whc->post_data_ht, "Restore Network Snapshot", (void **) &NWSnapshotType)) {
-        if (NWSnapshotType != NULL) {
-          if (strcmp(NWSnapshotType, "Restore NW Snapshot") == 0) {
-            int newLen;
-            newLen = strlen(config_dir) + strlen("net.config.xml") + 3;
-            char *fileName = new char[newLen];
-            ink_assert(fileName != NULL);
-            ink_snprintf(fileName, newLen, "%s%s%s", config_dir, DIR_SEP, "net.config.xml");
-
-            int pid = 0;
-            if ((pid = fork()) < 0) {
-              goto Ldone;
-            } else if (pid == 0) {
-              Config_RestoreNetConfig(fileName);
-              //goto Ldone;
-              _exit(0);
-            }
-
-            char *link = WebHttpGetLink_Xmalloc("/configure/c_snapshot_ftpsystem.ink");
-            whc->response_hdr->setRefresh(60);
-            whc->response_hdr->setRefreshURL(link);
-            if (submit_from_page)
-              xfree(submit_from_page);
-            submit_from_page = xstrdup("/restart.ink");
-            xfree(link);
-            goto Ldone;
-          }
-        }
-      }
-#endif //OEM
-
 
 
-    }
-  }
-#if defined(OEM)
 
- /**
-  Save the current system and network settings.
- **/
-  if (ink_hash_table_lookup(whc->post_data_ht, "NWSnapshot", (void **) &NWSnapshotType)) {
-    if (NWSnapshotType != NULL) {
-      if (strcmp(NWSnapshotType, "Network Settings Snapshot") == 0) {
-        int newLen;
-        newLen = strlen(config_dir) + strlen("net.config.xml") + 2;
-        char *fileName = new char[newLen];
-        ink_assert(fileName != NULL);
-        ink_snprintf(fileName, newLen, "%s%s%s", config_dir, DIR_SEP, "net.config.xml");
-        unlink(fileName);
-        Config_SaveNetConfig(fileName);
-      }
     }
-  } else                        //NWSnapshot=NULL
-  {
-    int Len = strlen(config_dir) + strlen("net.config.xml") + 2;
-    char *fName = new char[Len];
-    ink_assert(fName != NULL);
-    ink_snprintf(fName, Len, "%s%s%s", config_dir, DIR_SEP, "net.config.xml");
-    unlink(fName);
-    Config_SaveVersion(fName);
   }
 
 
-#endif //OEM
-
-
   if (ink_hash_table_lookup(whc->post_data_ht, "FTPSaveName", (void **) &snap_name)) {
     if (snap_name != NULL) {
       int localDirLength, remoteDirLength;
@@ -2830,9 +2461,6 @@ handle_submit_snapshot_to_floppy(WebHttp
   char *UnmountFloppy;
   int old_euid;
   const char *linkFile;
-#if defined(OEM)
-  char *NWSnapshotType;
-#endif
   ExpandingArray snap_list(25, true);
 
   if (varStrFromName("proxy.config.config_dir", config_dir, 256) == false)
@@ -2956,42 +2584,6 @@ handle_submit_snapshot_to_floppy(WebHttp
             if (snap_result < 0) {
               mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_floppy] Restore snap failed");
             }
-#if defined(OEM)
-
-           /**
-            Restore the current system and network settings.
-           **/
-            if (ink_hash_table_lookup(whc->post_data_ht, "Restore Network Snapshot", (void **) &NWSnapshotType)) {
-              if (NWSnapshotType != NULL) {
-
-                if (strcmp(NWSnapshotType, "Restore NW Snapshot") == 0) {
-                  int newLen;
-                  newLen = strlen(config_dir) + strlen("net.config.xml") + 3;
-                  char *fileName = new char[newLen];
-                  ink_assert(fileName != NULL);
-                  ink_snprintf(fileName, newLen, "%s%s%s", config_dir, DIR_SEP, "net.config.xml");
-
-                  int pid = 0;
-                  if ((pid = fork()) < 0) {
-                    goto Ldone;
-                  } else if (pid == 0) {
-                    Config_RestoreNetConfig(fileName);
-                    //goto Ldone;
-                    _exit(0);
-                  }
-
-                  char *link = WebHttpGetLink_Xmalloc("/configure/c_snapshot_floppy.ink");
-                  whc->response_hdr->setRefresh(60);
-                  whc->response_hdr->setRefreshURL(link);
-                  if (submit_from_page)
-                    xfree(submit_from_page);
-                  submit_from_page = xstrdup("/restart.ink");
-                  xfree(link);
-                  goto Ldone;
-                }
-              }
-            }
-#endif //OEM
 
           }
         }
@@ -3044,35 +2636,6 @@ handle_submit_snapshot_to_floppy(WebHttp
         xfree(dirEntry);
         closedir(dir);
 
-#if defined(OEM)
-
- /**
-  Save the current system and network settings.
- **/
-        if (ink_hash_table_lookup(whc->post_data_ht, "NWSnapshot", (void **) &NWSnapshotType)) {
-          if (NWSnapshotType != NULL) {
-            if (strcmp(NWSnapshotType, "Network Settings Snapshot") == 0) {
-              int newLen;
-              newLen = strlen(config_dir) + strlen("net.config.xml") + 2;
-              char *fileName = new char[newLen];
-              ink_assert(fileName != NULL);
-              ink_snprintf(fileName, newLen, "%s%s%s", config_dir, DIR_SEP, "net.config.xml");
-              unlink(fileName);
-              Config_SaveNetConfig(fileName);
-            }
-          }
-        } else                  //NWSnapshot=NULL
-        {
-          int Len = strlen(config_dir) + strlen("net.config.xml") + 2;
-          char *fName = new char[Len];
-          ink_assert(fName != NULL);
-          ink_snprintf(fName, Len, "%s%s%s", config_dir, DIR_SEP, "net.config.xml");
-          unlink(fName);
-          Config_SaveVersion(fName);
-        }
-
-
-#endif //OEM
 
         snap_result = configFiles->takeSnap(floppy_snap_name, floppy_drive_mount_point);
         if (snap_result < 0) {
@@ -3224,19 +2787,6 @@ handle_submit_inspector_display(WebHttpC
 //-------------------------------------------------------------------------
 // handle_submit_view_logs
 //-------------------------------------------------------------------------
-#ifdef OEM
-bool
-to_root(int *uid)
-{
-
-  *uid = getuid();
-  if (restoreRootPriv() == true && setreuid(0, 0) == 0) {
-    return true;
-  } else {
-    return false;
-  }
-}
-#endif
 static int
 handle_submit_view_logs(WebHttpContext * whc, const char *file)
 {
@@ -3292,14 +2842,6 @@ handle_submit_view_logs(WebHttpContext *
   } else if (strcmp(action, "remove") == 0) {
 
     ink_snprintf(tmp, MAX_TMP_BUF_LEN, "/bin/rm -f %s", logfile);
-#if defined(OEM)
-    Debug("web2", "[handle_submit_view_logs] restore RootPriv before deleting %s\n", logfile);
-    int old_uid;
-    bool uid_changed = to_root(&old_uid);
-    if (strcmp(logfile, "/var/log/messages") == 0) {
-      ink_snprintf(tmp, MAX_TMP_BUF_LEN, "/bin/cat /dev/null > %s", logfile);
-    }
-#endif
     if (system(tmp)) {
       Debug("web2", "[handle_submit_view_logs] unable to execute \"%s\"", tmp);
       if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
@@ -3314,15 +2856,6 @@ handle_submit_view_logs(WebHttpContext *
       xfree(logfile);
       xfree(action);
     }
-#ifdef OEM
-    if (uid_changed) {
-      if (removeRootPriv() == false || setreuid(old_uid, old_uid)) {
-        mgmt_elog(stderr, "[handle_submit_view_logs] Unable to reset permissions to euid %d.  Exiting...\n", old_uid);
-        _exit(1);
-      }
-      Debug("web2", "[handle_submit_view_logs] remove RootPriv after deleting %s, now run as %d\n", logfile, getuid());
-    }
-#endif
   } else if (strcmp(action, "save") == 0) {
     WebHandle h_file;
     if ((h_file = WebFileOpenR(logfile)) == WEB_HANDLE_INVALID) {
@@ -4162,79 +3695,20 @@ handle_submit_net_config(WebHttpContext 
   return WebHttpRender(whc, submit_from_page);
 }
 
-#ifdef OEM
-bool
-DTCheck(WebHttpContext * whc, char *arg, char *input_value)
-{
-  bool warning = false;
-  long value;
-  char *end;
-
-  if (input_value == NULL) {
-    warning = true;
-    goto Ldone;
-  }
-
-  if (strcmp(arg, "timezone_select") == 0) {
-    goto Ldone;
-  } else if (strstr(arg, "ntp_server") != NULL) {
-    if (!Net_IsValid_IP(input_value)) {
-      if (!Net_IsValid_Hostname(input_value)) {
-        warning = true;
-      }
-    }
-    goto Ldone;
-  }
-
-  if (*end != '\0') {
-    warning = true;
-    goto Ldone;
-  }
-  if (strcmp(arg, "hour") == 0) {
-    if (value<0 || value> 23) {
-      warning = true;
-    }
-  } else if (strcmp(arg, "minute") == 0 || strcmp(arg, "second") == 0) {
-    if (value<0 || value> 59) {
-      warning = true;
-    }
-  } else if (strcmp(arg, "month") == 0) {
-    if (value<1 || value> 12) {
-      warning = true;
-    }
-  } else if (strcmp(arg, "day") == 0) {
-    if (value<1 || value> 31) {
-      warning = true;
-    }
-  } else if (strcmp(arg, "year") == 0) {
-//year can not be larger than 2037, 32-bit CPU limitation.
-    if (value<1970 || value> 2037) {
-      warning = true;
-    }
-  }
-
-Ldone:
-  if (warning == true) {
-    SetWarning(whc, arg);
-  }
-  return warning;
-}
-
 //-------------------------------------------------------------------------
-// handle_submit_time
+// handle_submit_otw_upgrade
 //-------------------------------------------------------------------------
 static int
-handle_submit_time(WebHttpContext * whc, const char *file)
+handle_submit_otw_upgrade(WebHttpContext * whc, const char *file)
 {
 
   int err = WEB_HTTP_ERR_OKAY;
-  char *dummy;
-  char *submit_from_page, *link;
-  char *hour, *minute, *second, *month, *day, *year, *timezone, *ntp[3], *ntp_enabled, ntp_servers[256];
-  int i, status, old_euid;
-  pid_t pid;
-  bool warning = false, apply = false, settime = false, setdate = false, settimezone = false, setntp =
-    false, ntp_change = false, restart = false;
+  char *action;
+  char *working_dir;
+  char *submit_from_page;
+  char tmp[MAX_TMP_BUF_LEN];
+  char *link;
+  const char *cgi_path;
 
   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");
@@ -4243,1753 +3717,41 @@ handle_submit_time(WebHttpContext * whc,
     submit_from_page = NULL;
   }
 
-  if (ink_hash_table_lookup(whc->post_data_ht, "cancel", (void **) &dummy)) {
-    goto Ldone;
-  } else if (ink_hash_table_lookup(whc->post_data_ht, "apply", (void **) &dummy)) {
-    apply = true;
-    restart = true;
-  } else if (ink_hash_table_lookup(whc->post_data_ht, "time_reset", (void **) &dummy)) {
-    settime = true;
-    restart = true;
-  } else if (ink_hash_table_lookup(whc->post_data_ht, "date_reset", (void **) &dummy)) {
-    setdate = true;
-    restart = true;
-  } else if (ink_hash_table_lookup(whc->post_data_ht, "timezone_reset", (void **) &dummy)) {
-    settimezone = true;
-    restart = true;
-  } else if (ink_hash_table_lookup(whc->post_data_ht, "ntp_reset", (void **) &dummy)) {
-    setntp = true;
-    restart = false;
-  }
-
-  ink_hash_table_lookup(whc->post_data_ht, "hour", (void **) &hour);
-  if ((apply || settime) && DTCheck(whc, "hour", hour))
-    warning = true;
-  ink_hash_table_lookup(whc->post_data_ht, "minute", (void **) &minute);
-  if ((apply || settime) && DTCheck(whc, "minute", minute))
-    warning = true;
-  ink_hash_table_lookup(whc->post_data_ht, "second", (void **) &second);
-  if ((apply || settime) && DTCheck(whc, "second", second))
-    warning = true;
-  ink_hash_table_lookup(whc->post_data_ht, "month", (void **) &month);
-  if ((apply || setdate) && DTCheck(whc, "month", month))
-    warning = true;
-  ink_hash_table_lookup(whc->post_data_ht, "day", (void **) &day);
-  if ((apply || setdate) && DTCheck(whc, "day", day))
-    warning = true;
-  ink_hash_table_lookup(whc->post_data_ht, "year", (void **) &year);
-  if ((apply || setdate) && DTCheck(whc, "year", year))
-    warning = true;
-  ink_hash_table_lookup(whc->post_data_ht, "timezone_select", (void **) &timezone);
-  if ((apply || settimezone) && DTCheck(whc, "timezone_select", timezone))
-    warning = true;
-
-
-  ink_hash_table_lookup(whc->post_data_ht, "ntp_enabled", (void **) &ntp_enabled);
-  ink_hash_table_lookup(whc->post_data_ht, "ntp_server1", (void **) &ntp[0]);
-  ink_hash_table_lookup(whc->post_data_ht, "ntp_server2", (void **) &ntp[1]);
-  ink_hash_table_lookup(whc->post_data_ht, "ntp_server3", (void **) &ntp[2]);
-
-  Config_User_Root(&old_euid);
-  if (setntp) {
-    char ntp_status[10];
+#ifndef _WIN32
 
-    Config_GetNTP_Status(ntp_status, sizeof(ntp_status));
-    if (strcmp(ntp_enabled, "0") == 0 && strcmp(ntp_status, "on") == 0) {
-      ntp_change = true;
-    } else if (strcmp(ntp_enabled, "1") == 0) {
-      char server[80];
-      ink_strncpy(ntp_servers, "", sizeof(ntp_servers));
-      for (i = 0; i < 3; i++) {
-        if (ntp[i] != NULL) {
-          ink_snprintf(server, sizeof(server), "ntp_server%d", i + 1);
-          if (DTCheck(whc, server, ntp[i])) {
-            warning = true;
-          }
-          strncat(ntp_servers, ntp[i], sizeof(ntp_servers) - strlen(ntp_servers) - 1);
-          strncat(ntp_servers, " ", sizeof(ntp_servers) - strlen(ntp_servers) - 1);
-        }
-      }
-      if (strlen(ntp_servers)) {
-        char *last_space = ntp_servers + strlen(ntp_servers) - 1;
-        *last_space = '\0';
-      }
-//Bug 51185: the primary ntp server can not be NULL for enabling NTP
-      if (ntp[0] == NULL) {
-        warning = true;
-        SetWarning(whc, "ntp_server1");
-      }
-
-      if (warning) {
-        goto Ldone;
-      }
-
-      if (strcmp(ntp_status, "off") == 0) {
-        ntp_change = true;
-        restart = true;
-      } else {
-        char old_ntp_servers[256];
-
-        Config_GetNTP_Servers(old_ntp_servers, sizeof(old_ntp_servers));
-        if (strlen(old_ntp_servers) == 0) {
-          ntp_change = true;
-          restart = true;
-
-        } else if (strcmp(old_ntp_servers, ntp_servers) != 0) {
-          ntp_change = true;
-          restart = true;
-        }
-      }
-    }
-  }
-
-  if (warning) {
-    goto Ldone;
-  }
-
-  pid = fork();
-  if (pid == 0) {
-//Hacking code to close the web gui socket in child
-    close(whc->si.fd);
-    for (i = 0; i < MAX_PROXY_SERVER_PORTS && lmgmt->proxy_server_fd[i] >= 0; i++) {
-      ink_close_socket(lmgmt->proxy_server_fd[i]);
-    }
-
-    if (settime)
-      Config_SetTime(true, hour, minute, second);
-    if (setdate)
-      Config_SetDate(true, month, day, year);
-    if (settimezone)
-      Config_SetTimezone(true, timezone);
-    if (setntp && ntp_change) {
-      if (strcmp(ntp_enabled, "1") == 0) {
-        Config_SetNTP_Servers(true, ntp_servers);
-      } else {
-        Config_SetNTP_Off();
-      }
-    }
-
-    if (apply) {
-      Config_SetTime(false, hour, minute, second);
-      Config_SetDate(false, month, day, year);
-      Config_SetTimezone(true, timezone);
-    }
-
-    _exit(0);
-  }
-  if (restart) {
-    link = WebHttpGetLink_Xmalloc("/configure/c_time.ink");
-    whc->response_hdr->setRefresh(60);
-    whc->response_hdr->setRefreshURL(link);
-    if (submit_from_page)
-      xfree(submit_from_page);
-    submit_from_page = xstrdup("/restart.ink");
-    xfree(link);
-  } else {
-    wait(&status);
-  }
-
-  Config_User_Inktomi(old_euid);
-Ldone:
-  err = WebHttpRender(whc, submit_from_page);
-  return err;
-}
-
-//-------------------------------------------------------------------------
-// handle_submit_box_control
-//-------------------------------------------------------------------------
-static int
-handle_submit_box_control(WebHttpContext * whc, const char *file)
-{
-
-  int err = WEB_HTTP_ERR_OKAY;
-  char *dummy;
-  char *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 (ink_hash_table_lookup(whc->post_data_ht, "reboot", (void **) &dummy)) {
-    char *link = WebHttpGetLink_Xmalloc(HTML_DEFAULT_CONFIGURE_FILE);
-//    lmgmt->ccom->sendClusterMessage(CLUSTER_MSG_SHUTDOWN_MANAGER);
-    whc->response_hdr->setRefresh(180);
-    whc->response_hdr->setRefreshURL(link);
-    if (submit_from_page)
-      xfree(submit_from_page);
-    submit_from_page = xstrdup("/reboot.ink");
-    xfree(link);
-    WebHttpRender(whc, submit_from_page);
-
-    seteuid(0);
-    setreuid(0, 0);
-    system("/sbin/reboot");
-  } else if (ink_hash_table_lookup(whc->post_data_ht, "shutdown", (void **) &dummy)) {
-    char *link = WebHttpGetLink_Xmalloc(HTML_DEFAULT_CONFIGURE_FILE);
-//    lmgmt->ccom->sendClusterMessage(CLUSTER_MSG_SHUTDOWN_MANAGER);
-    if (submit_from_page)
-      xfree(submit_from_page);
-    submit_from_page = xstrdup("/shutdown.ink");
-    xfree(link);
-    WebHttpRender(whc, submit_from_page);
-
-    seteuid(0);
-    setreuid(0, 0);
-    system("/sbin/shutdown -h now");
-  }
-
-  return err;
-}
-
-//-------------------------------------------------------------------------
-// handle_submit_driver_config
-//-------------------------------------------------------------------------
-static int
-handle_submit_driver_config(WebHttpContext * whc, const char *file)
-{
-
-  int err = WEB_HTTP_ERR_OKAY;
-  char *submit_from_page;
-  InkHashTableIteratorState htis;
-  InkHashTableEntry *hte;
-  char *key, *value, *param, *cancel;
-  char *nic[5][4], interface[80], *argv[10];
-  int i, j, no;
-  char command[80], absolute_netconfig_binary[80];
-  pid_t pid;
-
-  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;
-
-  for (i = 0; i < 5; i++) {
-    for (j = 0; j < 4; j++) {
-      nic[i][j] = NULL;
-    }
-  }
-
-  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);
-
-    if (strstr(key, "driver") == NULL)
-      continue;
-    ink_strncpy(interface, key + 7, sizeof(interface));
-    param = strchr(interface, '_');
-    *param = '\0';
-    param++;
-    no = atoi(interface + 3);
-    if (nic[no][0] == NULL) {
-      nic[no][0] = xstrdup(interface);
-      nic[no][1] = xstrdup("10");
-      nic[no][2] = xstrdup("0");
-      nic[no][3] = xstrdup("0");
-    }
-
-    if (strcmp(param, "speed") == 0) {
-      if (value == NULL || strcmp(value, "0") == 0) {
-        nic[no][1] = xstrdup("10");
-      } else {
-        nic[no][1] = xstrdup("100");
-      }
-    } else if (strcmp(param, "mode") == 0) {
-      if (value == NULL || strcmp(value, "0") == 0) {
-        nic[no][2] = xstrdup("0");
-      } else {
-        nic[no][2] = xstrdup("1");
-      }
-    } else if (strcmp(param, "auto") == 0) {
-      if (value == NULL || strcmp(value, "0") == 0) {
-        nic[no][3] = xstrdup("0");
-      } else {
-        nic[no][3] = xstrdup("1");
-      }
-    }
-  }
-  ink_snprintf(absolute_netconfig_binary, sizeof(absolute_netconfig_binary), "%s/net_config", lmgmt->bin_path);
-  for (i = 0; i < 5; i++) {
-    if (nic[i][0] != NULL) {
-      argv[0] = "net_config";
-      argv[1] = xstrdup("6");
-      argv[2] = nic[i][0];
-      argv[3] = nic[i][1];
-      argv[4] = nic[i][2];
-      argv[5] = nic[i][3];
-      argv[6] = NULL;
-
-      pid = fork();
-      if (pid == 0) {
-        int res;
-        res = execv(absolute_netconfig_binary, argv);
-        if (res != 0) {
-          mgmt_elog(stderr, "[submit_driver] fail to call net_config ");
-        }
-        _exit(res);
-      }
-
-      for (j = 0; j < 4; j++) {
-        xfree(nic[i][j]);
-      }
-    }
-  }
-
-Ldone:
-  WebHttpRender(whc, submit_from_page);
-  return err;
-}
-
-//------------------------------------------------------------------------
-// handle_submit_logging_ftpserver
-//------------------------------------------------------------------------
-static int
-handle_submit_logging_ftpserver(WebHttpContext * whc, const char *file)
-{
-  int err = 0;
-  char *submit_from_page;
-  char *ftp_server_name;
-  char *ftp_remote_dir;
-  char *ftp_login;
-  char *ftp_password;
-  char *cancel;
-  char *ftp_logging_enable, *ftp_logging_now;
-  bool recs_out_of_date, warning, real_time_ftp = false;
-  char *record_version;
-
-  // 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
-  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);
-  }
-
-  FILE *f;
-  char *config_dir, file_name[512];
-  bool found;
-
-  ink_assert(RecGetRecordString_Xmalloc("proxy.config.config_dir", &config_dir) == REC_ERR_OKAY);
-
-  ink_snprintf(file_name, sizeof(file_name), "%s%s%s%s%s", config_dir, DIR_SEP, "internal", DIR_SEP,
-               "ftp_logging.config");
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "ftp_logging_now", (void **) &ftp_logging_now)) {
-    real_time_ftp = true;
-  }
-
-  ink_hash_table_lookup(whc->post_data_ht, "ftp_logging_enabled", (void **) &ftp_logging_enable);
-
-  if (strncmp(ftp_logging_enable, "0", 1) == 0) {
-    unlink(file_name);
-    if (!real_time_ftp)
-      goto Ldone;
-  }
-
-  warning = false;
-  if (ink_hash_table_lookup(whc->post_data_ht, "FTPServerName", (void **) &ftp_server_name)) {
-    if (ftp_server_name == NULL) {
-      SetWarning(whc, "FTPServerName");
-      warning = true;
-    }
-
-  }
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "FTPUserName", (void **) &ftp_login)) {
-    if (ftp_login == NULL) {
-      SetWarning(whc, "FTPUserName");
-      warning = true;
-    }
-  }
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "FTPPassword", (void **) &ftp_password)) {
-    if (ftp_password == NULL) {
-      SetWarning(whc, "FTPPassword");
-      warning = true;
-    }
-  }
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "FTPRemoteDir", (void **) &ftp_remote_dir)) {
-    if (ftp_remote_dir == NULL) {
-      SetWarning(whc, "FTPRemoteDir");
-      warning = true;
-    }
-  }
-
-  if (warning)
-    goto Ldone;
-
-  f = fopen(file_name, "w");
-  if (f == NULL) {
-    mgmt_log(stderr, "[WebHttp::handle_submit_logging_ftpserver] Can not open file %s\n", file_name);
-    goto Ldone;
-  }
-
-  fprintf(f, "%s\n%s\n%s\n%s\n", ftp_server_name, ftp_login, ftp_password, ftp_remote_dir);
-  fclose(f);
-
-  if (real_time_ftp) {
-    lmgmt->rollLogFiles();
-  }
-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;
-
-}
-
-#endif
-//-------------------------------------------------------------------------
-// handle_submit_otw_upgrade
-//-------------------------------------------------------------------------
-static int
-handle_submit_otw_upgrade(WebHttpContext * whc, const char *file)
-{
-
-  int err = WEB_HTTP_ERR_OKAY;
-  char *action;
-  char *working_dir;
-  char *submit_from_page;
-  char tmp[MAX_TMP_BUF_LEN];
-  char *link;
-  const char *cgi_path;
-
-  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;
-  }
-
-#ifndef _WIN32
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "action", (void **) &action)) {
-    if (strcmp(action, "Cancel") == 0) {
-      // upgrade cancelled = return to HTML_OTW_UPGRADE_FILE
-      if (ink_hash_table_lookup(whc->post_data_ht, "working_dir", (void **) &working_dir)) {
-        // cleanup
-        ink_snprintf(tmp, MAX_TMP_BUF_LEN, "/bin/rm -rf %s", working_dir);
-        NOWARN_UNUSED_RETURN(system(tmp));
-      }
-      if (submit_from_page)
-        xfree(submit_from_page);
-      submit_from_page = xstrdup(HTML_OTW_UPGRADE_FILE);
-      if (whc->top_level_render_file)
-        xfree(whc->top_level_render_file);
-      whc->top_level_render_file = xstrdup(submit_from_page);
-
-    } else {
-      // start upgrade = render upgrade page + spawn traffic_shell.cgi script
-      link = WebHttpGetLink_Xmalloc(HTML_DEFAULT_MONITOR_FILE);
-      cgi_path = WebHttpAddDocRoot_Xmalloc(whc, HTML_OTW_UPGRADE_CGI_FILE);
-      int old_euid, old_egid;
-      Config_User_Root(&old_euid);
-      Config_Grp_Root(&old_egid);
-      spawn_cgi(whc, cgi_path, NULL, true, true);
-      Config_User_Inktomi(old_euid);
-      Config_Grp_Inktomi(old_egid);
-      if (submit_from_page)
-        xfree(submit_from_page);
-      submit_from_page = xstrdup("/upgrade.ink");
-      xfree(link);
-      xfree((char *) cgi_path);
-    }
-  }
-#endif
-  if (submit_from_page) {
-    err = WebHttpRender(whc, submit_from_page);
-    xfree(submit_from_page);
-  } else {
-    err = WebHttpRender(whc, HTML_DEFAULT_CONFIGURE_FILE);
-  }
-  return err;
-}
-
-#if defined(OEM)
-
-//////////////////////////////////////////////////////////////////////////
-// int SetPlugInOnOff (int OnOff) 
-// OnOff = 1: Make sure the websense line in plugin.config is uncommented
-// OnOff = 0: Make sure the websense line in plugin.config is commented
-// OnOff = -1: Do not return the Enable/Disable Form
-// Return Value = 0 : normal
-// Return value = -1: unable to submit the change.
-
-int
-SetPlugInOnOff(WebHttpContext * whc, int OnOff, Plugin_t which_plugin, bool * changed)
-{
-
-  char *p1;
-  Rollback *file_rb;
-  textBuffer *file_content = NULL;
-  textBuffer *new_file_content = NULL;
-  version_t ver;
-  int ret;
-  int rc = 0;
-  char *plugin_lib = NULL;
-
-  if (!(configFiles->getRollbackObj("plugin.config", &file_rb))) {
-    mgmt_log(stderr, "[handleWebsenseFile] ERROR getting rollback object\n");
-    goto generate_error_msg;
-  }
-  ver = file_rb->getCurrentVersion();
-  file_rb->getVersion(ver, &file_content);
-
-  switch (which_plugin) {
-  case PLUGIN_WEBSENSE:
-    plugin_lib = "WebsenseEnterprise/websense.so";
-    break;
-  case PLUGIN_VSCAN:
-    plugin_lib = "vscan.so";
-    break;
-  default:
-    rc = -2;
-    goto done;
-  }
-
-  if ((p1 = strstr(file_content->bufPtr(), plugin_lib)) == NULL) {
-    goto generate_error_msg;
-  }
-
-  do {
-    p1--;
-  } while (*p1 == ' ');
-
-  switch (OnOff) {
-  case 1:
-    if ((char) *p1 == '#') {
-      new_file_content = new textBuffer(strlen(file_content->bufPtr()));
-      ret = new_file_content->copyFrom(file_content->bufPtr(), p1 - file_content->bufPtr());
-      if (ret <= 0)
-        goto generate_error_msg;
-      p1++;
-      ret = new_file_content->copyFrom(p1, strlen(file_content->bufPtr()) - (p1 - file_content->bufPtr()));
-      if (ret <= 0)
-        goto generate_error_msg;
-      if ((file_rb->forceUpdate(new_file_content, -1)) != OK_ROLLBACK)
-        goto generate_error_msg;
-      *changed = true;
-    }
-    break;
-  case 0:
-    if ((char) *p1 != '#') {
-      p1++;
-      new_file_content = new textBuffer(strlen(file_content->bufPtr()) + 2);
-      ret = new_file_content->copyFrom(file_content->bufPtr(), p1 - file_content->bufPtr());
-      if (ret <= 0)
-        goto generate_error_msg;
-      ret = new_file_content->copyFrom("#", 1);
-      if (ret <= 0)
-        goto generate_error_msg;
-      ret = new_file_content->copyFrom(p1, strlen(file_content->bufPtr()) - (p1 - file_content->bufPtr()));
-      if (ret <= 0)
-        goto generate_error_msg;
-      if ((file_rb->forceUpdate(new_file_content, -1)) != OK_ROLLBACK)
-        goto generate_error_msg;
-      *changed = true;
-    }
-    break;
-  }
-  goto done;
-
-generate_error_msg:
-  ink_hash_table_insert(whc->submit_warn_ht, "plugin.required.restart", NULL);
-  if (!(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);
-  }
-  whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  rc = -1;
-
-done:
-  if (new_file_content) {
-    delete new_file_content;
-  }
-
-  if (file_content) {
-    delete file_content;
-  }
-  return rc;
-}
-
-//-------------------------------------------------------------------------
-// handle_submit_plugin_websense
-//-------------------------------------------------------------------------
-static int
-handle_submit_plugin_websense(WebHttpContext * whc, const char *file)
-{
-
-#ifndef _WIN32
-  textBuffer *output = whc->response_bdy;
-  int err = WEB_HTTP_ERR_OKAY;
-  char *action;
-  char *submit_from_page;
-  char *OnOffString = NULL;
-  int OnOff;
-  bool dummy;
-
-  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 (ink_hash_table_lookup(whc->post_data_ht, "apply", (void **) &action)) {
-    if (ink_hash_table_lookup(whc->post_data_ht, "proxy.config.plugin.websense.enabled", (void **) &OnOffString)) {
-      sscanf(OnOffString, "%d", &OnOff);
-      if (SetPlugInOnOff(whc, OnOff, PLUGIN_WEBSENSE, &dummy) == 0) {
-        ink_hash_table_insert(whc->submit_note_ht, "plugin.required.restart", 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_warn);
-        }
-        whc->request_state |= WEB_HTTP_STATE_SUBMIT_NOTE;
-      }
-      goto Ldone;
-      // start change the websense on/off status
-    } else {
-      goto Ldone;
-      // websense on/off change cancelled 
-    }
-  }
-#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;
-
-}
-
-/* check weather the no_str is composed of all numeric */
-int
-RmCfgInputCheck(const char *no_str, int index)
-{
-  int no;
-  int MCC;
-  char *chptr;
-
-  if (!strcmp(no_str, "disabled")) {
-    return -1;
-  }
-  chptr = no_str;
-  for (chptr; *chptr != '\0'; chptr++) {
-    if ((*chptr<'0') || (*chptr> '9')) {
-      return false;
-    }
-  }
-  no = ink_atoi(no_str);
-  switch (index) {
-  case 0:
-  case 1:                      /* check the valid port number */
-    if ((no > 0) && (no < 65535)) {
-      return 1;
-    } else {
-      return 0;
-    }
-  case 2:                      /* check the Maximum Client Connection */
-    MCC = getMaximumClientConnections();
-    if ((MCC == -1) || (MCC >= no)) {
-      return 1;
-    } else {
-      return 0;
-    }
-  case 3:
-  case 4:
-    return 1;
-  }
-}
-
-void
-DebugRMserverCtx(INKCfgContext ctx)
-{
-  int i;
-  INKRmServerEle *ele;
-
-  for (i = 0; i <= 10; i++) {
-    ele = (INKRmServerEle *) CfgContextGetEleAt((INKCfgContext) ctx, i);
-    fprintf(stderr, "name = %s \t", ele->Vname);
-    if (ele->str_val) {
-      fprintf(stderr, "str_val= %s\n", ele->str_val);
-    } else {
-      fprintf(stderr, "int_val= %d\n", ele->int_val);
-    }
-  }
-  return;
-}
-
-/* rmserver.cfg file configuration */
-static int
-handle_submit_rmserver(WebHttpContext * whc, const char *file)
-{
-  char *rules[RMSERVER_WEB_ENTRY];      // shouldn't have more than RMSERVER_WEB_ENTRYrules on a form 
-  char name[RMSERVER_WEB_ENTRY][20];
-  char *apply;
-  char *cancel;
-  char *submit_from_page;
-  char *arm_stat_str;
-  char *warning_str = NULL;
-
-  INKCfgContext ctx;
-  INKRmServerEle *ele;
-  Tokenizer tokens("\n");
-  INKActionNeedT action_need;
-  INKError response;
-  int NumRules;
-  int i, err = WEB_HTTP_ERR_OKAY;
-  int new_val;
-  bool insert_PNA_note = false;
-
-  //  ink_hash_table_dump_strings(whc->post_data_ht);
-  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 restart
-  if (ink_hash_table_lookup(whc->post_data_ht, "restart", (void **) &cancel)) {
-    char *link = WebHttpGetLink_Xmalloc(HTML_DEFAULT_RM_FILE);
-    if (rm_start_proxy() != INK_ERR_OKAY) {
-    }
-    whc->response_hdr->setRefresh(15);
-    whc->response_hdr->setRefreshURL(link);
-    if (submit_from_page)
-      xfree(submit_from_page);
-    submit_from_page = xstrdup("/rm_restart.ink");
-    xfree(link);
-    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 cancel
-  if (ink_hash_table_lookup(whc->post_data_ht, "cancel", (void **) &cancel))
-    goto Ldone;
-
-  // compose rules, the name is rmserver_rule1-6
-  // for adminPort, PNAPort/Redirect Port, MXproxyConn, MXGWBW, MXProxyBW 
-  // read all the rules into an array of char* strings; the 
-  // end of list will be delimited by a NULL value   
-  for (i = 0; i < RMSERVER_WEB_ENTRY; i++) {
-    memset(name[i], 0, 20);
-    ink_snprintf(name[sizeof(name), i], "rmserver_rule_%d", i);
-    if (ink_hash_table_lookup(whc->post_data_ht, name[i], (void **) &(rules[i]))) {
-      ink_hash_table_delete(whc->post_data_ht, name[i]);
-    } else {
-      rules[i] = xstrdup("disabled");
-    }
-  }
-  NumRules = i;
-  Debug("config", "[updateRmserverConfig] can't allocate ctx memory");
-  //compose cfgcontext
-
-  ctx = INKCfgContextCreate(INK_FNAME_RMSERVER);
-  if (!ctx) {
-    Debug("config", "[updateRmserverConfig] can't allocate ctx memory");
-    goto Lerror;
-  }
-  if (INKCfgContextGet(ctx) != INK_ERR_OKAY) {
-    Debug("config", "[updateRmserverConfig] Failed to Get CfgContext");
-    goto Lerror;
-  }
-  // create Ele's by parsing the rules in the rules array 
-  // insert the Ele's into a Cfg Context; if get invalid formatted rule, just skip it
-  for (i = 0; i < NumRules; i++) {
-    //BZ49338
-    if (rules[i] == NULL) {
-      warning_str = xstrdup("");
-      goto Lwarn;
-    }
-    tokens.Initialize(rules[i], ALLOW_EMPTY_TOKS);
-    xfree(rules[i]);
-    switch (i) {
-    case 0:{
-        ele = (INKRmServerEle *) CfgContextGetEleAt((INKCfgContext) ctx, (int) INK_RM_RULE_ADMIN_PORT);
-        break;
-      }
-    case 1:{
-        ele = (INKRmServerEle *) CfgContextGetEleAt((INKCfgContext) ctx, (int) INK_RM_RULE_PNA_PORT);
-        break;
-      }
-    case 2:{
-        ele = (INKRmServerEle *) CfgContextGetEleAt((INKCfgContext) ctx, (int) INK_RM_RULE_MAX_PROXY_CONN);
-        break;
-      }
-    case 3:{
-        ele = (INKRmServerEle *) CfgContextGetEleAt((INKCfgContext) ctx, (int) INK_RM_RULE_MAX_GWBW);
-        break;
-      }
-    case 4:{
-        ele = (INKRmServerEle *) CfgContextGetEleAt((INKCfgContext) ctx, (int) INK_RM_RULE_MAX_PXBW);
-        break;
-      }
-    default:
-      goto Lerror;
-      break;
-    }
-    // check error in format 
-    switch (RmCfgInputCheck(tokens[0], i)) {
-    case 1:
-      new_val = ink_atoi(tokens[0]);
-      if (ele->int_val != new_val) {
-        //FIX INKqa12805
-#if 0
-        if ((i == 1) && (arm_enable)) {
-          //Bug32084 need change the redirected port in ipnat.conf also.
-          if (INKSetPNA_RDT_Port(new_val) != INK_ERR_OKAY) {
-            insert_PNA_note = true;
-          } else {              //succeed on changing the ipnat.conf, the TS will be restart
-            char *link = WebHttpGetLink_Xmalloc("/configure/c_real_networks_realproxy.ink");
-            rm_start_proxy();
-            lmgmt->ccom->sendClusterMessage(CLUSTER_MSG_SHUTDOWN_MANAGER);
-            whc->response_hdr->setRefresh(60);
-            whc->response_hdr->setRefreshURL(link);
-            if (submit_from_page)
-              xfree(submit_from_page);
-            submit_from_page = xstrdup("/restart.ink");
-            xfree(link);
-          }
-        }
-#endif
-        ink_hash_table_insert(whc->submit_note_ht, name[i], NULL);
-        if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_NOTE)) {
-          HtmlRndrText(whc->submit_note, whc->lang_dict_ht, HTML_ID_RM_RESTART_REQUIRED);
-          HtmlRndrBr(whc->submit_note);
-        }
-        whc->request_state |= WEB_HTTP_STATE_SUBMIT_NOTE;
-      }
-      ele->int_val = new_val;
-      break;
-    case 0:
-      warning_str = xstrdup(tokens[0]);
-    Lwarn:
-      ink_hash_table_insert(whc->submit_warn_ht, name[i], warning_str);
-      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;
-      break;
-    case -1:                   /* a disabled entry */
-      break;
-    }
-  }
-  if (insert_PNA_note) {
-    HtmlRndrText(whc->submit_note, whc->lang_dict_ht, HTML_ID_IPNAT_CHANGE_REQUIRED);
-    HtmlRndrBr(whc->submit_note);
-  }
-  //   DebugRMserverCtx(ctx);
-  response = INKCfgContextCommit(ctx, &action_need, NULL);
-  if (response == INK_ERR_INVALID_CONFIG_RULE) {
-    err = WEB_HTTP_ERR_INVALID_CFG_RULE;
-  } else if (response != INK_ERR_OKAY) {
-    goto Lerror;
-  }
-  if (ctx)
-    INKCfgContextDestroy(ctx);
-
-  /* rerender the page */
-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;
-
-Lerror:
-  if (ctx)
-    INKCfgContextDestroy(ctx);
-  Debug("config", "[updateRmserverConfig] Error commiting changes to file");
-  mgmt_log(stderr, "[updateRmserverConfig] Error commiting changes to file");
-  return WEB_HTTP_ERR_FAIL;
-}
-
-//-------------------------------------------------------------------------
-// handle_submit_plugin_vscan
-//-------------------------------------------------------------------------
-
-//bool validVscanServerAddresses(char* vserver_ips[MAX_VAL_LENGTH], char* vserver_ports[MAX_VAL_LENGTH]);
-//int formVscanServerAddress(char* vserver_ips[MAX_VAL_LENGTH], char* vserver_ports[MAX_VAL_LENGTH], char* &server_addr);
-/* validVscanServerAddress
-   make sure if server is empty, then ports needs to be empty and vice versa 
-*/
-bool
-validVscanServerAddresses(char vserver_ips[NUM_VSERVERS][MAX_VAL_LENGTH],
-                          char vserver_ports[NUM_VSERVERS][MAX_VAL_LENGTH])
-{
-
-  // primary server ip/port fields can not be empty 
-  if ((strlen(vserver_ips[0]) <= 0) || (strlen(vserver_ports[0]) <= 0))
-    return false;
-  for (int i = 0; i < NUM_VSERVERS; i++) {
-    if (((strlen(vserver_ips[i]) > 0) && (strlen(vserver_ports[i]) <= 0)) ||
-        ((strlen(vserver_ports[i]) > 0) && (strlen(vserver_ips[i]) <= 0)))
-      return false;
-  }
-  return true;
-}
-
-/* formVscanServerAddress 
-   form format Server:x.x.x.x:y;;;Server:x.x.x.x:y
-   assume error checking has been done 
-   by validVscanServerAddresses function
- */
-int
-formVscanServerAddress(char vserver_ips[NUM_VSERVERS][MAX_VAL_LENGTH], char vserver_ports[NUM_VSERVERS][MAX_VAL_LENGTH],
-                       char *&server_addr)
-{
-  for (int i = 0; i < NUM_VSERVERS; i++) {
-    if (strlen(vserver_ips[i]) > 0 && strlen(vserver_ports[i]) > 0) {
-      if (i > 0)
-        ink_snprintf(server_addr, 1024, "%s;;;Server:%s:%s", server_addr, vserver_ips[i], vserver_ports[i]);
-      else
-        ink_snprintf(server_addr, 1024, "Server:%s:%s", vserver_ips[i], vserver_ports[i]);
-    }
-  }
-
-  return WEB_HTTP_ERR_OKAY;
-}
-
-/* SetVscanConfig
-   update the vscan.config file
- */
-INKError
-SetVscanConfig(WebHttpContext * whc, char *server_address)
-{
-
-  INKCfgContext ctx;
-  int num_eles = 0, index = 0;
-  INKError err = INK_ERR_OKAY;
-  INKVscanEle *ele;
-  INKActionNeedT action_need;
-
-  ctx = INKCfgContextCreate(INK_FNAME_VSCAN);
-  if (!ctx)
-    goto generate_error_msg;
-  if (INKCfgContextGet(ctx) != INK_ERR_OKAY)
-    goto generate_error_msg;
-  if ((num_eles = INKCfgContextGetCount(ctx)) <= 0)
-    goto generate_error_msg;
-
-  for (index = 0; index < num_eles; index++) {
-    ele = (INKVscanEle *) INKCfgContextGetEleAt(ctx, index);
-    if (ele && strcmp(ele->attr_name, "server.address") == 0) {
-      xfree(ele->attr_val);
-      ele->attr_val = xstrdup(server_address);
-      break;
-    }
-  }
-
-  // commit the CfgContext to write a new version of the file
-  if (INKCfgContextCommit(ctx, &action_need, NULL) != INK_ERR_OKAY)
-    goto generate_error_msg;
-
-  INKActionDo(action_need);
-
-  goto done;
-
-generate_error_msg:
-  ink_hash_table_insert(whc->submit_warn_ht, "plugin.required.restart", NULL);
-  if (!(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);
-  }
-  whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  err = INK_ERR_FAIL;
-
-done:
-  if (ctx)
-    INKCfgContextDestroy(ctx);
-  return err;
-}
-
-bool
-validTrustedHost(WebHttpContext * whc, char *key, char *value)
-{
-  bool success = true;
-  if (ccu_checkUrl(value)) {    // should not be in URL format
-    success = false;
-    ink_hash_table_insert(whc->submit_warn_ht, key, NULL);
-    if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-      HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_HOST_URL_ERROR);
-      HtmlRndrBr(whc->submit_warn);
-    }
-    whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  } else if (ccu_checkIpAddr(value)) {  // should not be in IP format
-    success = false;
-    ink_hash_table_insert(whc->submit_warn_ht, key, NULL);
-    if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-      HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_HOST_IP_ERROR);
-      HtmlRndrBr(whc->submit_warn);
-    }
-    whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  } else if (!Net_IsValid_Hostname(value)) {
-    success = false;
-    ink_hash_table_insert(whc->submit_warn_ht, key, NULL);
-    if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-      HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_HOST_NAME_ERROR);
-      HtmlRndrBr(whc->submit_warn);
-    }
-    whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  }
-  return success;
-}
-
-INKError
-SetTrustedHostConfig(WebHttpContext * whc, int host_count, char *new_host)
-{
-
-  // 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.
-  bool ctx_updated = false;
-  int i = 0;
-  char tmp_a[32] = { 0 };
-  char *tr_host, *tr_delete;
-  INKCfgContext ctx;
-  INKVsTrustedHostEle *ele;
-  INKActionNeedT action_need;
-  INKError err = INK_ERR_OKAY;
-
-  ctx = INKCfgContextCreate(INK_FNAME_VS_TRUSTED_HOST);
-  if (!ctx)
-    goto Lunable_to_submit;
-  if (INKCfgContextGet(ctx) != INK_ERR_OKAY)
-    goto Lunable_to_submit;
-
-  // delete hosts as requested && check for duplication of newly added hosts
-  for (i = host_count - 1; i >= 0; i--) {
-    ink_snprintf(tmp_a, sizeof(tmp_a), "host:%d", i);
-    if (ink_hash_table_lookup(whc->post_data_ht, tmp_a, (void **) &tr_host)) {
-      ink_snprintf(tmp_a, sizeof(tmp_a), "delete:%d", i);
-      if (ink_hash_table_lookup(whc->post_data_ht, tmp_a, (void **) &tr_delete)) {
-        INKCfgContextRemoveEleAt(ctx, i);
-        ctx_updated = true;
-        continue;
-      }
-      ele = (INKVsTrustedHostEle *) INKCfgContextGetEleAt(ctx, i);
-      if (!(ele && (strcmp(ele->hostname, tr_host) == 0)))
-        goto Lunable_to_submit;
-    }
-  }
-
-  // add new trusted host
-  if (new_host && strlen(new_host) > 0) {
-    ele = INKVsTrustedHostEleCreate();
-    ele->hostname = xstrdup(new_host);
-    INKCfgContextAppendEle(ctx, (INKCfgEle *) ele);
-    ctx_updated = true;
-  }
-
-  if (ctx_updated) {
-    if (INKCfgContextCommit(ctx, &action_need, NULL) != INK_ERR_OKAY)
-      goto Lunable_to_submit;
-    INKActionDo(action_need);
-  }
-  goto Ldone;
-
-Lunable_to_submit:
-  if (!(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);
-  }
-  whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  err = INK_ERR_FAIL;
-
-Ldone:
-  if (ctx)
-    INKCfgContextDestroy(ctx);
-  return err;
-
-}
-
-/* validVsExtension
-  Currently, just check for '.'
- */
-
-bool
-validVsExtension(WebHttpContext * whc, char *key, char *value)
-{
-  bool success = true;
-  if (strstr(value, ".")) {
-    success = false;
-    ink_hash_table_insert(whc->submit_warn_ht, key, NULL);
-    if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-      HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_EXT_ERROR);
-      HtmlRndrBr(whc->submit_warn);
-    }
-    whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  }
-  return success;
-}
-
-/*  uniqueVsExtension
-    check for uniqueness of the extension
- */
-bool
-uniqueVsExtension(WebHttpContext * whc, char *key, char *value)
-{
-
-  bool unique = true;
-  INKCfgContext ctx;
-  INKCfgIterState ctx_state;
-  INKVsExtensionEle *ele;
-
-  ctx = INKCfgContextCreate(INK_FNAME_VS_EXTENSION);
-  if (!ctx)
-    goto Lunable_to_submit;
-  if (INKCfgContextGet(ctx) != INK_ERR_OKAY)
-    goto Lunable_to_submit;
-
-  ele = (INKVsExtensionEle *) INKCfgContextGetFirst(ctx, &ctx_state);
-  while (ele) {
-    if (strcmp(ele->file_ext, value) == 0) {    // match, not unique
-      unique = false;
-      break;
-    }
-    ele = (INKVsExtensionEle *) INKCfgContextGetNext(ctx, &ctx_state);
-  }
-
-  if (!unique) {
-    ink_hash_table_insert(whc->submit_warn_ht, key, NULL);
-    if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-      HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_EXT_DUPLICATE_ERROR);
-      HtmlRndrBr(whc->submit_warn);
-    }
-    whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  }
-
-  goto Ldone;
-
-Lunable_to_submit:
-  if (!(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);
-  }
-  whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-
-Ldone:
-  if (ctx)
-    INKCfgContextDestroy(ctx);
-
-  return unique;
-}
-
-// return true when a < b
-bool
-extLess(char *a, char *b)
-{
-  int length = (strlen(a) < strlen(b) ? strlen(a) : strlen(b));
-  for (int i = 0; i < length; i++) {
-    if (a[i] == b[i])
-      continue;
-    if (a[i] > b[i])
-      return false;
-    else
-      return true;
-  }
-  if (strlen(a) < strlen(b))
-    return true;
-
-  return false;
-}
-
-static int
-getTSdirectory(char *ts_path, size_t ts_path_len)
-{
-  FILE *fp;
-  char *env_path;
-
-  if ((env_path = getenv("TS_ROOT"))) {
-    ink_strncpy(ts_path, env_path, ts_path_len);
-    return 0;
-  }
-
-  if ((fp = fopen(DEFAULT_TS_DIRECTORY_FILE, "r")) == NULL) {
-    ink_strncpy(ts_path, "/usr/local", ts_path_len);
-    return 0;
-  }
-  if (fgets(ts_path, ts_path_len, fp) == NULL)
-    return -1;
-  // strip newline if it exists
-  int len = strlen(ts_path);
-  if (ts_path[len - 1] == '\n') {
-    ts_path[len - 1] = '\0';
-  }
-  // strip trailing "/" if it exists
-  len = strlen(ts_path);
-  if (ts_path[len - 1] == '/') {
-    ts_path[len - 1] = '\0';
-  }
-  return 0;
-}
-
-static bool
-isLineCommented(char *line)
-{
-  char *p = line;
-  while (*p) {
-    if (*p == '#')
-      return true;
-    if (!isspace(*p) && *p != '#')
-      return false;
-    p++;
-  }
-  return true;
-}
-
-INKError
-restoreVsExtFactoryDefault(WebHttpContext * whc)
-{
-
-  INKCfgContext ctx;
-  INKVsExtensionEle *ele, *new_ele;
-  INKActionNeedT action_need;
-  INKError err = INK_ERR_OKAY;
-  char ts_path[MAX_VAL_LENGTH];
-  char command_path[MAX_VAL_LENGTH];
-  char buffer[MAX_VAL_LENGTH];
-  FILE *fd;
-  char *temp;
-
-  ctx = INKCfgContextCreate(INK_FNAME_VS_EXTENSION);
-  if (!ctx)
-    goto Lunable_to_submit;
-  if (INKCfgContextGet(ctx) != INK_ERR_OKAY)
-    goto Lunable_to_submit;
-
-  // first, try to open factory default file
-  if (getTSdirectory(ts_path, sizeof(ts_path)) != 0)
-    goto Lunable_to_submit;
-  ink_snprintf(command_path, sizeof(command_path), "%s/etc/trafficserver/plugins/extensions.config.factory.default", ts_path);
-  fd = fopen(command_path, "r");
-  if (fd == NULL)
-    goto FILE_MISSING;
-
-  // then clean up extensions.config
-  if (INKCfgContextRemoveAll(ctx) != INK_ERR_OKAY)
-    goto Lunable_to_submit;
-
-  fgets(buffer, MAX_VAL_LENGTH, fd);
-  while (!feof(fd)) {
-    if (isLineCommented(buffer)) {
-      fgets(buffer, MAX_VAL_LENGTH, fd);
-      continue;
-    }
-    if (buffer[strlen(buffer) - 1] == '\n')     // strip '\n'
-      buffer[strlen(buffer) - 1] = '\0';
-    ele = INKVsExtensionEleCreate();
-    ele->file_ext = xstrdup(buffer);
-    INKCfgContextAppendEle(ctx, (INKCfgEle *) ele);
-    fgets(buffer, MAX_VAL_LENGTH, fd);
-  }
-
-  if (INKCfgContextCommit(ctx, &action_need, NULL) != INK_ERR_OKAY)
-    goto Lunable_to_submit;
-  INKActionDo(action_need);
-
-  goto Ldone;
-
-FILE_MISSING:
-  if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-    HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_EXTFR_FILE_MISSING);
-    HtmlRndrBr(whc->submit_warn);
-  }
-  whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  err = INK_ERR_FAIL;
-  goto Ldone;
-
-Lunable_to_submit:
-  if (!(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);
-  }
-  whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  err = INK_ERR_FAIL;
-
-Ldone:
-  if (ctx)
-    INKCfgContextDestroy(ctx);
-  return err;
-
-}
-
-INKError
-SetVsNewFileExt(WebHttpContext * whc, int ext_count, char *fext)
-{
-
-  INKCfgContext ctx;
-  INKVsExtensionEle *ele, *new_ele;
-  INKActionNeedT action_need;
-  int index = -1;
-  INKError err = INK_ERR_OKAY;
-
-  // do nothing if file extension is null
-  if (fext == NULL)
-    return err;
-  if (strlen(fext) == 0)
-    return err;
-
-  ctx = INKCfgContextCreate(INK_FNAME_VS_EXTENSION);
-  if (!ctx)
-    goto Lunable_to_submit;
-  if (INKCfgContextGet(ctx) != INK_ERR_OKAY)
-    goto Lunable_to_submit;
-
-
-  for (int i = 0; i < ext_count; i++) {
-    ele = (INKVsExtensionEle *) INKCfgContextGetEleAt(ctx, i);
-    if (strcmp(ele->file_ext, "no_extension") == 0)     // skip this one
-      continue;
-    if (strcmp(fext, "no_extension") == 0) {    // always insert at 0
-      index = 0;
-      break;
-    }
-    if (isNumber(fext)) {
-      if (isNumber(ele->file_ext)) {
-        if (atoi(fext) < atoi(ele->file_ext)) {
-          index = i;
-          break;
-        }
-      } else {                  // fext is the first number
-        index = i;
-        break;
-      }
-    }
-    if (extLess(fext, ele->file_ext)) { // performing insertion sort
-      index = i;
-      break;
-    }
-  }
-
-  new_ele = INKVsExtensionEleCreate();
-  new_ele->file_ext = xstrdup(fext);
-  if (index != -1)
-    INKCfgContextInsertEleAt(ctx, (INKCfgEle *) new_ele, index);
-  else
-    INKCfgContextAppendEle(ctx, (INKCfgEle *) new_ele);
-  if (INKCfgContextCommit(ctx, &action_need, NULL) != INK_ERR_OKAY)
-    goto Lunable_to_submit;
-  INKActionDo(action_need);
-
-  goto Ldone;
-
-Lunable_to_submit:
-  if (!(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);
-  }
-  whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  err = INK_ERR_FAIL;
-
-Ldone:
-  if (ctx)
-    INKCfgContextDestroy(ctx);
-  return err;
-
-}
-
-INKError
-deleteSingleFileExt(WebHttpContext * whc, char *val)
-{
-
-  INKError err = INK_ERR_OKAY;
-  INKCfgContext ctx;
-  INKCfgIterState ctx_state;
-  INKVsExtensionEle *ele;
-  int num_eles = 0;
-  bool update = false;
-  INKActionNeedT action_need;
-
-  ctx = INKCfgContextCreate(INK_FNAME_VS_EXTENSION);
-  if (!ctx)
-    goto Lunable_to_submit;
-  if (INKCfgContextGet(ctx) != INK_ERR_OKAY)
-    goto Lunable_to_submit;
-  if ((num_eles = INKCfgContextGetCount(ctx)) <= 0)     // this is an error.. means nothing to delete
-    goto Lunable_to_submit;
-
-  for (int i = 0; i < num_eles; i++) {
-    ele = (INKVsExtensionEle *) INKCfgContextGetEleAt(ctx, i);
-    if (strcmp(ele->file_ext, val) == 0) {
-      if (INKCfgContextRemoveEleAt(ctx, i) != INK_ERR_OKAY) {
-        goto Lunable_to_submit;
-      }
-      update = true;
-      break;
-    }
-  }
-
-  if (update) {
-    if (INKCfgContextCommit(ctx, &action_need, NULL) != INK_ERR_OKAY)
-      goto Lunable_to_submit;
-    INKActionDo(action_need);
-  }
-  goto Ldone;
-
-Lunable_to_submit:
-  if (!(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);
-  }
-  whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-  err = INK_ERR_FAIL;
-
-Ldone:
-  if (ctx)
-    INKCfgContextDestroy(ctx);
-  return err;
-}
-
-INKError
-deleteFileExts(WebHttpContext * whc, char *val)
-{
-  char *del_val;
-  INKError err = INK_ERR_OKAY;
-
-  if (strstr(val, "&") != NULL) {       // multiple val to delete
-    del_val = strtok(val, "&");
-    while (err == INK_ERR_OKAY && del_val) {
-      err = deleteSingleFileExt(whc, del_val);
-      del_val = strtok(NULL, "&");
-    }
-  } else {
-    err = deleteSingleFileExt(whc, val);
-  }
-  return err;
-}
-
-bool
-isRAMDiskConfigured()
-{
-
-  bool ret_val = false;
-  INKCfgContext ctx;
-  INKCfgIterState ctx_state;
-  INKVscanEle *ele;
-
-  ctx = INKCfgContextCreate(INK_FNAME_VSCAN);
-  if (!ctx)
-    return ret_val;
-  if (INKCfgContextGet(ctx) != INK_ERR_OKAY)
-    return ret_val;
-
-  // currently, only server.address attribute is pull from the file
-  // need to fix the code below if more fields are needed
-  ele = (INKVscanEle *) INKCfgContextGetFirst(ctx, &ctx_state);
-  while (ele) {
-    if (strcmp(ele->attr_name, "plugin.temp_path") == 0) {
-      if (strstr(ele->attr_val, "ramdisk"))
-        ret_val = true;
-      else
-        ret_val = false;
-      break;
-    }
-    ele = (INKVscanEle *) INKCfgContextGetNext(ctx, &ctx_state);
-  }
-  return ret_val;
-}
-
-/*
-  modify lilo.conf
-  if OnOff = 1, un-comment out ramdisk line
-  if OnOff = 0, comment out ramdisk line
- */
-int
-SetRamLiloOnOff(WebHttpContext * whc, int OnOff)
-{
-  int old_euid;
-  FILE *fp, *tmp;
-  char buffer[1024];
-  char filename[64];
-  char *p;
-
-  Config_User_Root(&old_euid);
-  ink_strncpy(filename, "/etc/lilo.conf", sizeof(filename));
-  fp = fopen(filename, "r");
-  if (fp == NULL) {
-    ink_strncpy(filename, "/etc/lilo.conf.anaconda", sizeof(filename));
-    fp = fopen(filename, "r");
-  }
-  tmp = fopen("/tmp/lilo.conf.tmp", "w");
-  if (fp && tmp) {
-    fgets(buffer, 1024, fp);
-    while (!feof(fp)) {
-      if (p = strstr(buffer, "ramdisk")) {
-        do {
-          p--;
-        } while (*p == ' ');
-        if (OnOff) {
-          if (*p == '#') {      // get rid of #
-            p++;
-            fputs(p, tmp);
-          } else
-            fputs(buffer, tmp);
-        } else {
-          if (*p != '#') {      // add #
-            char tmpbuf[1024];
-            p++;
-            ink_snprintf(tmpbuf, sizeof(tmpbuf), "#%s", p);
-            fputs(tmpbuf, tmp);
-          } else
-            fputs(buffer, tmp);
-        }
-      } else {
-        fputs(buffer, tmp);
-      }
-      fgets(buffer, 1024, fp);
-    }
-    fclose(fp);
-    fclose(tmp);
-    ink_snprintf(buffer, sizeof(buffer), "/bin/mv -f /tmp/lilo.conf.tmp %s", filename);
-    system(buffer);
-  }
-
-  Config_User_Inktomi(old_euid);
-  return 1;
-}
-
-static int
-handle_submit_plugin_vscan(WebHttpContext * whc, const char *file)
-{
-
-  InkHashTableIteratorState htis;
-  InkHashTableEntry *hte;
-
-  textBuffer *output = whc->response_bdy;
-  bool warning = false;
-  char *submit_from_page = NULL;
-  char server_address[1024] = { 0 };
-  int OnOff = 0, index = 0, err = 0;
-  char vserver_ips[NUM_VSERVERS][MAX_VAL_LENGTH] = { 0 };
-  char vserver_ports[NUM_VSERVERS][MAX_VAL_LENGTH] = { 0 };
-  char *dummy, *record_version, *key, *value;
-  bool recs_out_of_date = true, plugin_installed = false;
-  int host_count = 0, ext_count = 0;
-  char new_trusted_host[MAX_VAL_LENGTH] = { 0 };
-  char new_file_ext[MAX_VAL_LENGTH] = { 0 };
-  bool restart_request = false;
-  bool plugin_status_changed = false;
-  bool reboot_request = false;
-
-  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 **) &dummy)) {
-    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)) {
-    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;
-
-  // check for which submit button pressed
-  if (ink_hash_table_lookup(whc->post_data_ht, "delete_file_ext", (void **) &dummy)) {
-    if (ink_hash_table_lookup(whc->post_data_ht, "file_ext_select", (void **) &value)) {
-      if (value && (deleteFileExts(whc, value) == INK_ERR_OKAY))
-        restart_request = true;
-    }
-    goto Ldone;
-  }
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "restore_file_ext", (void **) &dummy)) {
-    if (restoreVsExtFactoryDefault(whc) == INK_ERR_OKAY) {
-      restart_request = true;
-    }
-    goto Ldone;
-  }
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "new_trusted_host", (void **) &value)) {
-    if (value && strlen(value) > 0) {
-      if (!validTrustedHost(whc, "new_trusted_host", value)) {
-        warning = true;
-        goto Ldone;
-      } else {
-        ink_strncpy(new_trusted_host, value, sizeof(new_trusted_host));
-      }
-    }
-  }
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "new_file_extension", (void **) &value)) {
-    if (value && strlen(value) > 0) {
-      if (!validVsExtension(whc, "new_file_extension", value) || !uniqueVsExtension(whc, "new_file_extension", value)) {
-        warning = true;
-        goto Ldone;
-      } else {
-        ink_strncpy(new_file_ext, value, sizeof(new_file_ext));
-      }
-    }
-  }
-  // input checking and value gathering
-  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);
-
-    if (strstr(key, "delete"))
-      continue;                 // for preformance enhacement. 
-
-    if (strstr(key, "host:")) {
-      if (value && strlen(value) > 0 && strcmp(new_trusted_host, value) == 0) { //error, duplicate new host name
-        ink_hash_table_insert(whc->submit_warn_ht, "new_trusted_host", NULL);
-        whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-        HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_HOST_DUPLICATE_ERROR);
-        HtmlRndrBr(whc->submit_warn);
-        goto Ldone;
-      }
-    } else if (strstr(key, "vscan_rule_server")) {
-      if (value && strlen(value) > 0) { // can be empty string
-        if (ccu_checkIpAddr(value) && (strcmp(value, "0.0.0.0") != 0)) {        // can not be default
-          sscanf(key, "vscan_rule_server_%d", &index);
-          ink_strncpy(vserver_ips[index - 1], value, sizeof(vserver_ips[index - 1]));
-        } else {                // set warning
-          warning = true;
-          ink_hash_table_insert(whc->submit_warn_ht, key, NULL);
-          if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-            HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_IP_FORMAT_ERROR);
-            HtmlRndrBr(whc->submit_warn);
-          }
-          whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-          goto Ldone;
-        }
-      }
-    } else if (strstr(key, "vscan_rule_port")) {
-      if (value && strlen(value) > 0) { // can be empty string
-        if (isNumber(value) && ccu_checkPortNum(atoi(value))) {
-          sscanf(key, "vscan_rule_port_%d", &index);
-          ink_strncpy(vserver_ports[index - 1], value, sizeof(vserver_ports[index - 1]));
-        } else {                // set warning
-          warning = true;
-          ink_hash_table_insert(whc->submit_warn_ht, key, NULL);
-          if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-            HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_PORT_FORMAT_ERROR);
-            HtmlRndrBr(whc->submit_warn);
-          }
-          whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-          goto Ldone;
-        }
+  if (ink_hash_table_lookup(whc->post_data_ht, "action", (void **) &action)) {
+    if (strcmp(action, "Cancel") == 0) {
+      // upgrade cancelled = return to HTML_OTW_UPGRADE_FILE
+      if (ink_hash_table_lookup(whc->post_data_ht, "working_dir", (void **) &working_dir)) {
+        // cleanup
+        ink_snprintf(tmp, MAX_TMP_BUF_LEN, "/bin/rm -rf %s", working_dir);
+        NOWARN_UNUSED_RETURN(system(tmp));
       }
-    } else if (strstr(key, "proxy.config.plugin.vscan.enabled")) {
-      plugin_installed = true;
-      sscanf(value, "%d", &OnOff);
-    } else if (strcmp(key, "host_count") == 0) {
-      host_count = atoi(value);
-    } else if (strcmp(key, "ext_count") == 0) {
-      ext_count = atoi(value);
-    }
-  }
-
-  if (!plugin_installed)
-    goto Ldone;
-
-  if (!warning && !validVscanServerAddresses(vserver_ips, vserver_ports)) {
-    warning = true;
-    ink_hash_table_insert(whc->submit_warn_ht, "vscan_server", NULL);
-    if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-      if ((strlen(vserver_ips[0]) <= 0) || (strlen(vserver_ports[0]) <= 0))
-        HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_PRIMARY_SERVER_ERROR);
-      else
-        HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_CFG_VSCAN_SERVER_FORMAT_ERROR);
-      HtmlRndrBr(whc->submit_warn);
-    }
-    whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-    goto Ldone;
-  }
-  // if no error - update files
-  if (!warning) {               // no errors
-    formVscanServerAddress(vserver_ips, vserver_ports, server_address);
-    if ((SetVscanConfig(whc, server_address) == INK_ERR_OKAY) &&        // vscan.config
-        (SetTrustedHostConfig(whc, host_count, new_trusted_host)
-         == INK_ERR_OKAY) &&    // trusted-host.config
-        (SetVsNewFileExt(whc, ext_count, new_file_ext) == INK_ERR_OKAY) &&      // extensions.config
-        (SetPlugInOnOff(whc, OnOff, PLUGIN_VSCAN, &plugin_status_changed) == 0)) {      // plugin.conf
-      restart_request = true;
-    }
-  }                             // else, no changed has been done
-
-  // update lilo.conf if necessary
-  if (restart_request &&        // only do this if everything else is successful
-      plugin_status_changed && isRAMDiskConfigured()) {
-    SetRamLiloOnOff(whc, OnOff);        // fix me - add more err checking
-    reboot_request = true;
-  }
-
-  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;
+      if (submit_from_page)
+        xfree(submit_from_page);
+      submit_from_page = xstrdup(HTML_OTW_UPGRADE_FILE);
+      if (whc->top_level_render_file)
+        xfree(whc->top_level_render_file);
+      whc->top_level_render_file = xstrdup(submit_from_page);
 
-Ldone:
-  if (reboot_request) {
-    ink_hash_table_insert(whc->submit_note_ht, "plugin.required.restart", NULL);
-    if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_NOTE)) {
-      HtmlRndrText(whc->submit_note, whc->lang_dict_ht, HTML_ID_REBOOT_REQUIRED);
-      HtmlRndrBr(whc->submit_warn);
-    }
-    whc->request_state |= WEB_HTTP_STATE_SUBMIT_NOTE;
-    whc->post_data_ht = NULL;   // no error, no need to remember old values      
-  } else if (restart_request) {
-    ink_hash_table_insert(whc->submit_note_ht, "plugin.required.restart", NULL);
-    if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_NOTE)) {
-      HtmlRndrText(whc->submit_note, whc->lang_dict_ht, HTML_ID_RESTART_REQUIRED_FILE);
-      HtmlRndrBr(whc->submit_warn);
+    } else {
+      // start upgrade = render upgrade page + spawn traffic_shell.cgi script
+      link = WebHttpGetLink_Xmalloc(HTML_DEFAULT_MONITOR_FILE);
+      cgi_path = WebHttpAddDocRoot_Xmalloc(whc, HTML_OTW_UPGRADE_CGI_FILE);
+      int old_euid, old_egid;
+      Config_User_Root(&old_euid);
+      Config_Grp_Root(&old_egid);
+      spawn_cgi(whc, cgi_path, NULL, true, true);
+      Config_User_Inktomi(old_euid);
+      Config_Grp_Inktomi(old_egid);
+      if (submit_from_page)
+        xfree(submit_from_page);
+      submit_from_page = xstrdup("/upgrade.ink");
+      xfree(link);
+      xfree((char *) cgi_path);
     }
-    whc->request_state |= WEB_HTTP_STATE_SUBMIT_NOTE;
-    whc->post_data_ht = NULL;   // no error, no need to remember old values      
   }
-
+#endif
   if (submit_from_page) {
     err = WebHttpRender(whc, submit_from_page);
     xfree(submit_from_page);
@@ -5997,10 +3759,8 @@ Ldone:
     err = WebHttpRender(whc, HTML_DEFAULT_CONFIGURE_FILE);
   }
   return err;
-
 }
 
-#endif
 //-------------------------------------------------------------------------
 // handle_default
 //-------------------------------------------------------------------------
@@ -6129,169 +3889,6 @@ handle_default(WebHttpContext * whc, con
 
 }
 
-#ifdef OEM
-
-//-------------------------------------------------------------------------
-// cookieValue
-//-------------------------------------------------------------------------
-
-char *
-cookieValue(char *cookie, WebHttpContext * whc)
-{
-  char *cookieValue = NULL;
-  char *cookieString = NULL;
-  char *tokens = NULL;
-  httpMessage *request = whc->request;
-
-  if (request->getCookie() != NULL) {
-    SimpleTokenizer cookieTokens(xstrdup(request->getCookie()), ';');
-
-    int tokensCount = cookieTokens.getNumTokensRemaining();
-    for (int index = 0; index < tokensCount; index++) {
-      tokens = cookieTokens.getNext();
-      if (strstr(tokens, cookie) != NULL) {
-        cookieString = strstr(tokens, cookie);
-        break;
-      }
-    }
-    if (cookieString != NULL) {
-      cookieValue = strchr(cookieString, '=');
-      return ++cookieValue;
-    }
-  }
-  return NULL;
-}
-
-
-//-------------------------------------------------------------------------
-// checkCookie
-//-------------------------------------------------------------------------
-
-
-int
-checkCookie(WebHttpContext * whc)
-{
-
-  const int buffer_size = 2048;
-
-  httpMessage *request = whc->request;
-  httpResponse *response_hdr = whc->response_hdr;
-  bool found;
-  time_t now;
-  current_session_ele *data = NULL;
-
-  RecInt session = 0;
-  session = REC_readInteger("proxy.config.admin.session", &found);
-
-  // get our file information
-  char *file = (char *) (whc->request->getFile());
-
-  // If session management is disabled, we still maintain the session for each client
-  // but we don't complain if the session timeouts. We do this because session control
-  // might be used for more than just admin UI timeout later. We update the last access time 
-  // for each transaction. We do this so that the session does not immediately timeout
-  // if enabled later.
-  if ((found) && (session == 0) && (strcmp(file, "/submit_relogin.cgi") != 0)) {
-    if (request->getCookie() != NULL) {
-      SimpleTokenizer cookieTokens(strdup(request->getCookie()), ';');
-      char *SessionString = NULL;
-      char *SessionIDString = NULL;
-      current_session_ele *data = NULL;
-      time_t now;
-      int err;
-      int tokensCount = cookieTokens.getNumTokensRemaining();
-      for (int index = 0; index < tokensCount; index++) {
-        SessionString = cookieTokens.getNext();
-        if (strstr(SessionString, "SessionID=") != NULL) {
-          SessionIDString = strstr(SessionString, "SessionID=");
-          break;
-        }
-      }
-      if (SessionIDString != NULL) {
-        char *SessionID = strchr(SessionIDString, '=');
-        WebHttpCurrentSessionRetrieve(++SessionID, &data);
-        time(&now);
-        if (data != NULL) {
-          data->last_access = now;
-        }
-      }
-    }
-    return WEB_HTTP_ERR_OKAY;
-  }
-
-  if (request->getCookie() != NULL) {
-    // If session is invalid, i.e. The user has more than one browser window open.
-    // Since we use per-session cookie (not stored on the client harddisk), if the
-    // user clones the browser (ctrl-N), then each of those windows sessions are
-    // sharing the same cookie. If he tries to login into more than one clone simultaneously,
-    // we consider the session to be invalid until he manages to login.
-
-    // BZ50154
-    char *cookieReturnValue = cookieValue("InvalidSession", whc);
-    if ((cookieReturnValue != NULL) && strcmp(cookieReturnValue, "true") == 0) {
-      //if(strcmp(cookieValue("InvalidSession", whc), "true") == 0) {
-      return WEB_HTTP_ERR_INVALID_CFG_RULE;
-    }
-
-    SimpleTokenizer cookieTokens(xstrdup(request->getCookie()), ';');
-    char *SessionString = NULL;
-    char *SessionIDString = NULL;
-    char *LastAccessString = NULL;
-    char *SessionValidityString = NULL;
-    char *SessionValidity = NULL;
-    current_session_ele *data = NULL;
-    time_t now;
-    int err;
-    int tokensCount = cookieTokens.getNumTokensRemaining();
-    for (int index = 0; index < tokensCount; index++) {
-      SessionString = cookieTokens.getNext();
-      if (strstr(SessionString, "SessionID=") != NULL) {
-        SessionIDString = strstr(SessionString, "SessionID=");
-      } else if (strstr(SessionString, "LastAccess=") != NULL) {
-        LastAccessString = strstr(SessionString, "LastAccess=");
-      } else if (strstr(SessionString, "InvalidSession=") != NULL) {
-        SessionValidityString = strstr(SessionString, "InvalidSession=");
-      }
-    }
-    if (SessionValidityString != NULL) {
-      SessionValidity = strchr(SessionValidityString, '=');
-      if (strcmp(++SessionValidity, "true") == 0) {
-        return WEB_HTTP_ERR_INVALID_CFG_RULE;
-      }
-    }
-    if (SessionIDString != NULL) {
-      char *SessionID = strchr(SessionIDString, '=');
-      WebHttpCurrentSessionRetrieve(++SessionID, &data);
-      time(&now);
-      if (data != NULL) {
-        RecInt sessionTimeout = 0;
-        RecGetRecordInt("proxy.config.admin.session.timeout", &sessionTimeout);
-        if ((now - data->last_access) >= sessionTimeout) {
-          return WEB_HTTP_ERR_FAIL;
-        } else {
-          if ((whc->request->getReferer() != NULL) && (strncasecmp(whc->request->getReferer(), "http://", 7) == 0)) {
-            char last_access_time[25];
-            data->last_access = now;
-            ink_snprintf(last_access_time, sizeof(last_access_time), "LastAccess=%d;", now);
-            response_hdr->setCookie(last_access_time);
-            return WEB_HTTP_ERR_OKAY;
-          } else {
-            return WEB_HTTP_ERR_OKAY;
-          }
-        }
-      } else {
-        return WEB_HTTP_ERR_FAIL;
-      }
-    }
-  } else {
-    return WEB_HTTP_ERR_REQUEST_ERROR;
-  }
-
-  return WEB_HTTP_ERR_OKAY;
-
-}
-
-#endif //OEM
 
 
 //-------------------------------------------------------------------------
@@ -6602,19 +4199,6 @@ WebHttpInit()
   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);
   ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_OTW_UPGRADE_FILE, (void *) handle_submit_otw_upgrade);
-#ifdef OEM
-  ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_SNMP_CONFIG, (void *) handle_submit_snmp_config);
-  ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_SESSION, (void *) handle_submit_session);
-  ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_RELOGIN, (void *) handle_submit_relogin);
-  ink_hash_table_insert(g_submit_bindings_ht, "/submit_time.cgi", (void *) handle_submit_time);
-  ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_PLUGIN_WEBSENSE, (void *) handle_submit_plugin_websense);
-  ink_hash_table_insert(g_submit_bindings_ht, "/submit_box_control.cgi", (void *) handle_submit_box_control);
-  ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_RMSERVER, (void *) handle_submit_rmserver);
-  ink_hash_table_insert(g_submit_bindings_ht, "/submit_driver_config.cgi", (void *) handle_submit_driver_config);
-  ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_PLUGIN_VSCAN, (void *) handle_submit_plugin_vscan);
-  ink_hash_table_insert(g_submit_bindings_ht, "/submit_logging_ftpserver.cgi",
-                        (void *) handle_submit_logging_ftpserver);
-#endif
   // 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);
@@ -6654,9 +4238,6 @@ WebHttpInit()
   WebHttpLogInit();
   WebHttpRenderInit();
   WebHttpSessionInit();
-#ifdef OEM
-  WebHttpCurrentSessionInit();
-#endif //OEM
   WebHttpTreeInit();
 
   return;
@@ -6679,13 +4260,6 @@ WebHttpHandleConnection(WebHttpConInfo *
   WebHttpHandler handler;
   char *file;
   char *extn;
-#ifdef OEM
-  const char *requested_file_extension;
-  //static int session_state = false;
-  char *ctx_key;
-  WebHandle h_file;
-  int file_size;
-#endif //OEM
   int drain_bytes;
   char ch;
 
@@ -6702,12 +4276,10 @@ WebHttpHandleConnection(WebHttpConInfo *
   if ((err = read_request(whc)) != WEB_HTTP_ERR_OKAY)
     goto Lerror_switch;
 
-#ifndef OEM
   // authentication
   if (whc->server_state & WEB_HTTP_SERVER_STATE_AUTH_ENABLED)
     if (WebHttpAuthenticate(whc) != WEB_HTTP_ERR_OKAY)
       goto Ltransaction_send;
-#endif //OEM
 
   // get our file information
   file = (char *) (whc->request->getFile());
@@ -6717,222 +4289,6 @@ WebHttpHandleConnection(WebHttpConInfo *
 
   Debug("web2", "[WebHttpHandleConnection] request file: %s", file);
 
-#ifdef OEM
-  requested_file_extension = strrchr(file, '.');
-
-  // Check if the requested file qualifies for session control. We only check cookies for
-  // ink (html) files and .cgi files (either a POST or GET)
-  if ((requested_file_extension != NULL) && ((strcmp(requested_file_extension, ".cgi") == 0) ||
-                                             (strcmp(requested_file_extension, ".ink") == 0) ||
-                                             (strcmp(file, "/submit_relogin.cgi") == 0))
-      && ((strncmp(file, "/charting/", 10) != 0))) {
-
-    // User clicked on the logout link. We get a request for the file /session_logout.ink.
-    // We terminate the session and delete the cookie. This forces the user to relogin.
-    if (strcmp(file, "/session_logout.ink") == 0) {
-      if (whc->request->getCookie() != NULL) {
-        SimpleTokenizer cookieTokens(xstrdup(whc->request->getCookie()), ';');
-        char *SessionString = NULL;
-        char *SessionIDString = NULL;
-        current_session_ele *data = NULL;
-        int tokensCount = cookieTokens.getNumTokensRemaining();
-        for (int index = 0; index < tokensCount; index++) {
-          SessionString = cookieTokens.getNext();
-          if (strstr(SessionString, "SessionID=") != NULL) {
-            SessionIDString = strstr(SessionString, "SessionID=");
-            break;
-          }
-        }
-        char *SessionID = strchr(SessionIDString, '=');
-        SessionID++;
-        WebHttpCurrentSessionDelete(SessionID);
-        whc->response_hdr->setStatus(STATUS_MOVED_TEMPORARILY);
-        WebHttpSetErrorResponse(whc, STATUS_MOVED_TEMPORARILY);
-        whc->response_hdr->setLocationURL("/logout.ink");
-        char namAttrib[256];
-        ink_snprintf(namAttrib, sizeof(namAttrib), "InvalidSession=false");
-        whc->response_hdr->setCookie(namAttrib);
-        goto Ltransaction_send;
-      }
-    }
-
-    err = checkCookie(whc);
-    //if(err == WEB_HTTP_ERR_REQUEST_ERROR) {
-    //} else if(err == WEB_HTTP_ERR_FAIL) {
-    if (err == WEB_HTTP_ERR_FAIL) {
-      char *index_file = NULL;
-      if ((strcmp(file, "/submit_relogin.cgi") == 0)) {
-        bool found = false;
-        RecString product_name = REC_readString("proxy.config.product_name",
-                                                &found);
-        whc->response_hdr->setStatus(STATUS_UNAUTHORIZED);
-        if (found && product_name) {
-          whc->response_hdr->setRealm(product_name);
-          ctx_key = WebHttpMakeSessionKey_Xmalloc();
-          WebHttpCurrentSessionStore(ctx_key);
-          current_session_ele *data;
-          WebHttpCurrentSessionRetrieve(ctx_key, &data);
-          if (data != NULL) {
-            char namAttrib[256];
-            ink_snprintf(namAttrib, sizeof(namAttrib), "SessionID=%s:LastAccess=%d:InvalidSession=true", ctx_key,

[... 162 lines stripped ...]


Mime
View raw message