trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject svn commit: r1057958 - in /trafficserver/traffic/trunk: CHANGES proxy/mgmt2/api2/INKMgmtAPI.cc proxy/mgmt2/api2/include/INKMgmtAPI.h proxy/mgmt2/html2/configure/helper/INKMgmtAPIFtp.tcl proxy/mgmt2/web2/WebHttp.cc proxy/mgmt2/web2/WebHttpRender.cc
Date Wed, 12 Jan 2011 00:39:11 GMT
Author: igalic
Date: Wed Jan 12 00:39:11 2011
New Revision: 1057958

URL: http://svn.apache.org/viewvc?rev=1057958&view=rev
Log:
More work on TS-324, by phasing out TCL bindings.

Removed:
    trafficserver/traffic/trunk/proxy/mgmt2/html2/configure/helper/INKMgmtAPIFtp.tcl
Modified:
    trafficserver/traffic/trunk/CHANGES
    trafficserver/traffic/trunk/proxy/mgmt2/api2/INKMgmtAPI.cc
    trafficserver/traffic/trunk/proxy/mgmt2/api2/include/INKMgmtAPI.h
    trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc
    trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttpRender.cc

Modified: trafficserver/traffic/trunk/CHANGES
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/CHANGES?rev=1057958&r1=1057957&r2=1057958&view=diff
==============================================================================
--- trafficserver/traffic/trunk/CHANGES (original)
+++ trafficserver/traffic/trunk/CHANGES Wed Jan 12 00:39:11 2011
@@ -2,6 +2,9 @@
 
 Changes with Apache Traffic Server 2.1.6
 
+  *) Remove traces of FTP references [TS-324] by purging the now useless TCL
+  bindings to it.
+
   *) Fix configure issues for sqlite3. This fix eliminates all of SimpleDBM,
   sqlite3 and bdb dependencies. It also fixes the "make distclean" problem,
   and clean things up a bit [TS-513].

Modified: trafficserver/traffic/trunk/proxy/mgmt2/api2/INKMgmtAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/api2/INKMgmtAPI.cc?rev=1057958&r1=1057957&r2=1057958&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/api2/INKMgmtAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/api2/INKMgmtAPI.cc Wed Jan 12 00:39:11 2011
@@ -2644,164 +2644,6 @@ INKIsValid(INKCfgEle * ele)
   return (ele_obj->isValid());
 }
 
-
-/*--- External FTP tcl script operations --------------------------------*/
-
-/* Process forking function for ftp.tcl helper */
-
-static int
-ftpProcessSpawn(const char *args[], char *output)
-{
-  int status = 0;
-
-#ifndef _WIN32
-  char buffer[1024];
-  size_t nbytes;
-  int stdoutPipe[2];
-  pid_t pid;
-  size_t output_size = 4096;
-  size_t count = 0;
-
-  if (pipe(stdoutPipe) == -1)
-    fprintf(stderr, "[ftpProcessSpawn] unable to create stdout pipe\n");
-
-  pid = fork();
-  if (pid == 0) {               // child process
-    dup2(stdoutPipe[1], STDOUT_FILENO);
-    close(stdoutPipe[0]);
-
-    pid = execv(args[0], (char* const*)&args[0]);
-    if (pid == -1) {
-      fprintf(stderr, "[ftpProcessSpawn] unable to execv [%s,%s...]\n", args[0], args[1]);
-    }
-    _exit(1);
-  } else if (pid == -1) {       // failed to create child process
-    fprintf(stderr, "[ftpProcessSpawn] unable to fork [%d '%s']\n", errno, strerror(errno));
-    status = 1;
-  } else {                      // parent process
-    close(stdoutPipe[1]);
-    /* read the output from child script process */
-    while ((nbytes = read(stdoutPipe[0], buffer, 1024))) {
-      if ((count + nbytes) < output_size) {
-        strncpy(&output[count], buffer, nbytes);
-        count += nbytes;
-      } else {
-        break;
-      }
-    }
-    close(stdoutPipe[0]);
-
-    waitpid(pid, &status, 0);
-    if (status) {
-      fprintf(stderr, "[ftpProcessSpawn] script %s returns non-zero status '%d'", args[0], status);
-      status = -1;
-    }
-  }
-
-#endif
-  return status;
-}
-
-/* Process forking function for tcl_checker.sh helper */
-
-static int
-tclCheckProcessSpawn(char *args[], char *output)
-{
-  int status = 0;
-
-#ifndef _WIN32
-  char buffer[1024];
-  size_t nbytes;
-  int stdoutPipe[2];
-  pid_t pid;
-  size_t output_size = 256;
-  size_t count = 0;
-
-  if (pipe(stdoutPipe) == -1)
-    fprintf(stderr, "[tclCheckProcessSpawn] unable to create stdout pipe\n");
-
-  pid = fork();
-  if (pid == 0) {               // child process
-    dup2(stdoutPipe[1], STDOUT_FILENO);
-    close(stdoutPipe[0]);
-
-    pid = execv(args[0], &args[0]);
-    if (pid == -1) {
-      fprintf(stderr, "[tclCheckProcessSpawn] unable to execv [%s,%s...]\n", args[0], args[1]);
-    }
-    _exit(1);
-  } else if (pid == -1) {       // failed to create child process
-    fprintf(stderr, "[tclCheckProcessSpawn] unable to fork [%d '%s']\n", errno, strerror(errno));
-    status = 1;
-  } else {                      // parent process
-    close(stdoutPipe[1]);
-    /* read the output from child script process */
-    while ((nbytes = read(stdoutPipe[0], buffer, 1024))) {
-      if ((count + nbytes) < output_size) {
-        strncpy(&output[count], buffer, nbytes);
-        count += nbytes;
-      } else {
-        break;
-      }
-    }
-    close(stdoutPipe[0]);
-
-    waitpid(pid, &status, 0);
-    if (status) {
-      fprintf(stderr, "[tclCheckProcessSpawn] script %s returns non-zero status '%d'", args[0], status);
-      status = -1;
-    }
-  }
-
-#endif
-  return status;
-}
-
-/* Snapshot Interface-centric function */
-
-inkapi INKError
-INKMgmtFtp(const char *ftpCmd, const char *ftp_server_name, const char *ftp_login, const char *ftp_password, const char *local, const char *remote,
-           char *output)
-{
-  char script_path[1024];
-  char chk_script_path[1024];
-  int chk_status = 0;
-  int status = 0;
-  char *ui_path = NULL;
-  INKRecordGetString("proxy.config.admin.html_doc_root", &ui_path);
-  if (ui_path != NULL) {
-
-    /* First we check to make sure we can use tcl on this plat */
-    snprintf(chk_script_path, sizeof(chk_script_path), "%s/configure/helper/INKMgmtAPICheckTcl.sh", ui_path);
-    char *chk_args[] = {
-      chk_script_path,
-      NULL
-    };
-    /* tclCheckProcessSpawn.sh sends nothing back on stdout if check OK... */
-    chk_status = tclCheckProcessSpawn(chk_args, output);
-    if (chk_status == 0) {
-      /* Go ahead and try the using the FTP .tcl script */
-      snprintf(script_path, sizeof(script_path), "%s/configure/helper/INKMgmtAPIFtp.tcl", ui_path);
-      const char *args[] = {
-        script_path,
-        ftpCmd,
-        ftp_server_name,
-        ftp_login,
-        ftp_password,
-        local,
-        remote,
-        NULL
-      };
-      status = ftpProcessSpawn(args, output);
-    } else {
-      status = -1;
-    }
-  }
-  if (status < 0)
-    return INK_ERR_FAIL;
-  return INK_ERR_OKAY;
-}
-
 /* Network conifguration functions */
 
 // close all file descriptors belong to process specified by pid

Modified: trafficserver/traffic/trunk/proxy/mgmt2/api2/include/INKMgmtAPI.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/api2/include/INKMgmtAPI.h?rev=1057958&r1=1057957&r2=1057958&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/api2/include/INKMgmtAPI.h (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/api2/include/INKMgmtAPI.h Wed Jan 12 00:39:11 2011
@@ -1178,14 +1178,6 @@ typedef enum
   inkapi INKError INKSnapshotGetMlt(INKStringList snapshots);
 
 
-/*--- ftp operations ------------------------------------------------------*/
-
-/* INKMgmtFtpGet: retrieves a file from the specified ftp server
- * Input:
- * Output: INKError
- */
-  inkapi INKError INKMgmtFtp(const char *ftpCmd, const char *ftp_server_name, const char *ftp_login, const char *ftp_password, const char *local,
-                             const char *remote, char *output);
 /*--- statistics operations -----------------------------------------------*/
 /* INKStatsReset: sets all the statistics variables to their default values
  * Input: <none>

Modified: trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc?rev=1057958&r1=1057957&r2=1057958&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc Wed Jan 12 00:39:11 2011
@@ -1058,353 +1058,6 @@ Ldone:
 
 
 
-//-------------------------------------------------------------------------
-// handle_submit_snapshot
-//-------------------------------------------------------------------------
-
-// Doesn't seem to be used.
-static int INK_UNUSED
-handle_submit_snapshot(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_location;
-  char *snap_directory;
-  char *ftp_server_name;
-  char *ftp_remote_dir;
-  char *ftp_login;
-  char *ftp_password;
-  char *snapDirFromRecordsConf;
-  bool found = false;
-  struct stat snapDirStat;
-  char config_dir[PATH_NAME_MAX];
-  struct stat s;
-
-  if (varStrFromName("proxy.config.config_dir", config_dir, PATH_NAME_MAX) == false)
-    mgmt_fatal(stderr,
-               "[WebHttp::handle_submit_snapshot] Unable to find configuration directory from proxy.config.config_dir\n");
-
-  if ((err = stat(config_dir, &s)) < 0) {
-    ink_strncpy(config_dir, system_config_directory,sizeof(config_dir));
-    if ((err = stat(config_dir, &s)) < 0) {
-        mgmt_elog("[WebHttp::handle_submit_snapshot] unable to stat() directory '%s': %d %d, %s\n",
-                config_dir, err, errno, strerror(errno));
-        mgmt_fatal("[WebHttp::handle_submit_snapshot] please set config path via command line '-path <path>' or '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;
-  }
-
-#ifndef _WIN32
-
-  // FIXME: button names here are going to be hard to
-  // internationalize.  we should put the button names into the
-  // dictionary.
-
-  // handle snapshot
-  if (ink_hash_table_lookup(whc->post_data_ht, "snap_action", (void **) &snap_action)) {
-    // take the snapshot action
-    if (strcmp(snap_action, "  Change  ") == 0) {
-      if (ink_hash_table_lookup(whc->post_data_ht, "Change Directory", (void **) &snap_directory)) {
-        if (snap_directory == NULL) {
-          mgmt_log(stderr, "Change Directory not specified.");
-        } else {
-          ink_assert(RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf)
-                     == REC_ERR_OKAY);
-          if (snapDirFromRecordsConf == NULL) {
-            // coverity[size_is_strlen]
-            snapDirFromRecordsConf = new char[strlen("snapshots")];
-            snprintf(snapDirFromRecordsConf, strlen("snapshots"), "%s", "snapshots");
-            ink_assert(RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf)
-                       == REC_ERR_OKAY);
-            ink_assert(RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf)
-                       == REC_ERR_OKAY);
-            RecSetRecordString("proxy.config.snapshot_dir", (RecString) snapDirFromRecordsConf);
-          }
-          if (strcasecmp(snapDirFromRecordsConf, snap_directory)) {
-            RecSetRecordString("proxy.config.snapshot_dir", snap_directory);
-            // Create a directory for the snap shot
-            if (snap_directory[0] != '/') {
-              // coverity[alloc_fn][var_assign]
-              char *snap_dir_cpy = strdup(snap_directory);
-              int newLen;
-
-              // coverity[noescape]
-              newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
-              snap_directory = new char[newLen];
-              ink_assert(snap_directory != NULL);
-              // coverity[noescape]
-              snprintf(snap_directory, newLen, "%s%s%s", config_dir, DIR_SEP, snap_dir_cpy);
-              //snap_directory = newPathString(config_dir, snap_dir_cpy);
-              RecSetRecordString("proxy.config.snapshot_dir", snap_dir_cpy);
-              if (snap_dir_cpy)
-                free(snap_dir_cpy);
-            }
-
-            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);
-
-                  if (mkdir(absoluteDir, DIR_MODE) < 0) {
-                    perror("Absolute snapPath Directory creation:");
-                  }
-                  delete[]absoluteDir;
-                } else {
-                  const char *tok = snapDirPathTok.getNext(i);
-                  // These weren't used, so moved. /leif
-                  //int newLen;
-                  //char* absoluteDir;
-                  //const char *config_dir = lmgmt->record_data ->readString("proxy.config.config_dir", &found);
-
-                  //newLen = strlen(tok) + strlen(config_dir) + 2;
-                  //absoluteDir = new char[newLen];
-                  //ink_assert(absoluteDir != NULL);
-                  //sprintf(absoluteDir, "%s%s%s",config_dir, DIR_SEP, tok);
-
-                  //if ((ret_val = mkdir(absoluteDir, DIR_MODE)) < 0) {
-                  //perror("Absolute snapPath Directory creation:");
-                  //}
-                  //delete [] absoluteDir;
-                  if (mkdir(tok, DIR_MODE) < 0) {
-                    perror("Relative snapPath Directory creation:");
-                  }
-                }
-                snapDirPathTok.setString(snap_directory);
-              }
-            }                   //else {
-            //if(snap_directory[0] == '/') {
-            //lmgmt->record_data ->setString("proxy.config.snapshot_dir", snap_directory);
-            //} else {
-            //int newLen;
-            //char* relativeDir;
-            //const char *config_dir = lmgmt->record_data ->readString("proxy.config.config_dir", &found);
-
-            //newLen = strlen(snap_directory) + strlen(config_dir) + 2;
-            //relativeDir = new char[newLen];
-            //ink_assert(relativeDir != NULL);
-            //sprintf(relativeDir, "%s%s%s",config_dir, DIR_SEP, snap_directory);
-            //lmgmt->record_data ->setString("proxy.config.snapshot_dir", relativeDir);
-            //}
-            //}
-          }
-        }
-      }
-    } else if (strcmp(snap_action, "   Take   ") == 0) {
-      if (ink_hash_table_lookup(whc->post_data_ht, "new_snap", (void **) &snap_name)) {
-        if (snap_name == NULL) {
-          mgmt_log(stderr, "Snapshots name on disk not specified.");
-        }
-      }
-      if (ink_hash_table_lookup(whc->post_data_ht, "Snapshots Location", (void **) &snap_location)) {
-        // coverity[var_compare_op]
-        if (snap_location == NULL) {
-          mgmt_log(stderr, "Snapshots Location not specified.");
-        }
-      }
-      if (snap_location && strcmp(snap_location, "OnDisk") == 0) {
-        RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snap_directory);
-
-        if (snap_directory[0] != '/') {
-          // coverity[alloc_fn][var_assign]
-          char *snap_dir_cpy = strdup(snap_directory);
-          int newLen;
-
-          // coverity[noescape]
-          newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
-          snap_directory = new char[newLen];
-          ink_assert(snap_directory != NULL);
-          // coverity[noescape]
-          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);
-      } else if (!(strcmp(snap_location, "FTPServerUpload")) || !(strcmp(snap_location, "FTPServerDownload"))) {
-        if (ink_hash_table_lookup(whc->post_data_ht, "FTPServerName", (void **) &ftp_server_name)) {
-          if (ftp_server_name == NULL) {
-            mgmt_log(stderr, "FTPServerName not specified.");
-          }
-        }
-        if (ink_hash_table_lookup(whc->post_data_ht, "FTPRemoteDir", (void **) &ftp_remote_dir)) {
-          if (ftp_server_name == NULL) {
-            mgmt_log(stderr, "FTPRemoteDir not specified.");
-          }
-        }
-        if (ink_hash_table_lookup(whc->post_data_ht, "FTPLogin", (void **) &ftp_login)) {
-          if (ftp_login == NULL) {
-            mgmt_log(stderr, "FTPLogin not specified.");
-          }
-        }
-        if (ink_hash_table_lookup(whc->post_data_ht, "FTPPassword", (void **) &ftp_password)) {
-          if (ftp_password == NULL) {
-            mgmt_log(stderr, "FTPPassword not specified.");
-          }
-        }
-        if (!(strcmp(snap_location, "FTPServerUpload")) && snap_name) {
-          int localDirLength, remoteDirLength;
-          char *newStr;
-          char *ftp_remote_dir_name;
-
-          localDirLength = strlen(snap_name) + strlen("/tmp") + 2;
-          remoteDirLength = strlen(snap_name) + strlen(ftp_remote_dir) + 2;
-
-          newStr = new char[localDirLength];
-          ink_assert(newStr != NULL);
-          ftp_remote_dir_name = new char[remoteDirLength];
-          ink_assert(ftp_remote_dir_name != NULL);
-          snprintf(newStr, localDirLength, "/tmp%s%s", DIR_SEP, snap_name);
-          snprintf(ftp_remote_dir_name, remoteDirLength, "%s%s%s", ftp_remote_dir, DIR_SEP, snap_name);
-          snap_result = configFiles->takeSnap(snap_name, "/tmp");
-          INKMgmtFtp("put", ftp_server_name, ftp_login, ftp_password, newStr, ftp_remote_dir_name, NULL);
-        } else {
-          RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf);
-          ink_release_assert(found);
-
-          if (snapDirFromRecordsConf[0] != '/') {
-            char *snap_dir_cpy = strdup(snapDirFromRecordsConf);
-            int newLen;
-
-            newLen = strlen(snap_dir_cpy) + strlen(config_dir) + strlen(snap_name) + 3;
-            snapDirFromRecordsConf = new char[newLen];
-            ink_assert(snapDirFromRecordsConf != NULL);
-            snprintf(snapDirFromRecordsConf, newLen, "%s%s%s%s%s", config_dir, DIR_SEP, snap_dir_cpy, DIR_SEP,
-                         snap_name);
-            if (snap_dir_cpy)
-              free(snap_dir_cpy);
-          } else {
-
-            char *snap_dir_cpy = strdup(snapDirFromRecordsConf);
-            int newLen;
-
-            newLen = strlen(snap_dir_cpy) + strlen(config_dir) + strlen(snap_name) + 3;
-            snapDirFromRecordsConf = new char[newLen];
-            ink_assert(snapDirFromRecordsConf != NULL);
-            snprintf(snapDirFromRecordsConf, newLen, "%s%s%s", snap_dir_cpy, DIR_SEP, snap_name);
-            if (snap_dir_cpy)
-              free(snap_dir_cpy);
-          }
-          int newLen;
-          char *newStr;
-          //const char *config_dir = lmgmt->record_data ->readString("proxy.config.config_dir", &found);
-
-          newLen = strlen(snap_name) + strlen(ftp_remote_dir) + 2;
-          newStr = new char[newLen];
-          ink_assert(newStr != NULL);
-          snprintf(newStr, newLen, "%s%s%s", ftp_remote_dir, DIR_SEP, snap_name);
-
-          if (mkdir(snapDirFromRecordsConf, DIR_MODE) < 0) {
-            mgmt_log(stderr, "Cannot create %s\n", snapDirFromRecordsConf);
-          }
-          INKMgmtFtp("get", ftp_server_name, ftp_login, ftp_password, snapDirFromRecordsConf, newStr, NULL);
-
-        }
-      } else if (!(strcmp(snap_location, "FloppySave")) || !(strcmp(snap_location, "FloppyCopy"))) {
-        char *floppyMountPoint;
-        if (ink_hash_table_lookup(whc->post_data_ht, "FloppyDrive", (void **) &floppyMountPoint)) {
-          //coverity [var_compare_op]
-          if (floppyMountPoint == NULL)
-            mgmt_log(stderr, "FloppyMountPoint not found.");
-        }
-        if (snap_location && strcmp(snap_location, "FloppySave") == 0) {
-          snap_result = configFiles->takeSnap(snap_name, floppyMountPoint);
-        } else {
-          char args[256];
-          RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf);
-          snprintf(args, sizeof(args), "cp -fr %s/%s %s", floppyMountPoint, snap_name, snapDirFromRecordsConf);
-          const char *argv[] = { args,
-            NULL
-          };
-          processSpawn(argv, NULL, NULL, NULL, false, false);
-        }
-      } else {
-        mgmt_log(stderr, "Illegal value for snapshot location.");
-      }
-      // take a snapshot for the current configuration files
-    } else if (strcmp(snap_action, " Restore ") == 0) {
-      // restore the selected snapshot
-      if (ink_hash_table_lookup(whc->post_data_ht, "snap_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 = strdup(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);
-        }
-      }
-    } else if (strcmp(snap_action, "  Delete  ") == 0) {
-      // delete the selected snapshot
-      if (ink_hash_table_lookup(whc->post_data_ht, "snap_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 = strdup(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);
-        }
-      }
-    } else {
-      // show alarm error
-      mgmt_log(stderr, "Unknown action is specified.");
-    }
-  } else {
-    snap_action = NULL;
-  }
-
-#endif
-
-  if (snap_result != SNAP_OK) {
-    // FIXME: show alarm error for snapshot!
-  }
-
-  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_snapshot_to_filesystem
@@ -1740,461 +1393,6 @@ Ldone:
 }
 
 
-
-
-
-
-
-//-------------------------------------------------------------------------
-// handle_submit_snapshot_to_ftpserver
-//-------------------------------------------------------------------------
-
-static int
-handle_submit_snapshot_to_ftpserver(WebHttpContext * whc, const char *file)
-{
-  NOWARN_UNUSED(file);
-  int err = 0;
-  char *submit_from_page;
-  char *snap_name;
-  char *ftp_server_name;
-  char *ftp_remote_dir;
-  char *ftp_login;
-  char *ftp_password;
-  char *snapDirFromRecordsConf;
-  char *tempDirFromRecordsConf;
-  char *cancel;
-  bool found;
-  // Doesn't seem to be used.
-  //struct stat snapDirStat;
-  char config_dir[256];
-  char *record_version;
-  ExpandingArray snap_list(25, true);
-
-  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);
-  }
-#ifndef _WIN32
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "FTPServerName", (void **) &ftp_server_name)) {
-    if (ftp_server_name == NULL) {
-      mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_ftpsystem] FTPServerName not specified.");
-      ink_hash_table_insert(whc->submit_warn_ht, "FTPServerNameError", NULL);
-      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;
-    }
-  }
-
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "FTPUserName", (void **) &ftp_login)) {
-    if (ftp_login == NULL) {
-      mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_ftpsystem] FTPlogin not specified.");
-      ink_hash_table_insert(whc->submit_warn_ht, "FTPUserNameError", NULL);
-      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;
-    }
-  }
-
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "FTPPassword", (void **) &ftp_password)) {
-    if (ftp_password == NULL) {
-      mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_ftpsystem] FTPpassword not specified.");
-      ink_hash_table_insert(whc->submit_warn_ht, "FTPPasswordError", NULL);
-      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;
-    }
-  }
-
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "FTPRemoteDir", (void **) &ftp_remote_dir)) {
-    if (ftp_remote_dir == NULL) {
-      mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_ftpsystem] FTPremote_dir not specified.");
-      ink_hash_table_insert(whc->submit_warn_ht, "FTPRemoteDirError", NULL);
-      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;
-    }
-  }
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "ftp_select", (void **) &snap_name)) {
-    if (strcmp(snap_name, "- select a snapshot -")) {
-      RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf);
-      /*
-         char *snap_dir;
-         snapDirFromRecordsConf = lmgmt->record_data ->readString("proxy.config.snapshot_dir", &found);
-         ink_assert(found);
-
-         if(snapDirFromRecordsConf[0] != '/') {
-         const char *snap_dir_cpy = strdup(snapDirFromRecordsConf);
-         int newLen;
-
-         newLen = strlen(snap_dir_cpy) + strlen(config_dir) + strlen(snap_name) + 3;
-         snapDirFromRecordsConf = new char[newLen];
-         ink_assert(snapDirFromRecordsConf != NULL);
-         sprintf(snapDirFromRecordsConf, "%s%s%s%s%s", config_dir, DIR_SEP, snap_dir_cpy, DIR_SEP, snap_name);
-
-         newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
-         snap_dir = new char[newLen];
-         ink_assert(snap_dir != NULL);
-         sprintf(snap_dir, "%s%s%s", config_dir, DIR_SEP, snap_dir_cpy);
-         } else {
-
-         char *snap_dir_cpy = strdup(snapDirFromRecordsConf);
-         int newLen;
-
-         newLen = strlen(snap_dir_cpy) + strlen(snap_name) + 2;
-         snapDirFromRecordsConf = new char[newLen];
-         ink_assert(snapDirFromRecordsConf != NULL);
-         sprintf(snapDirFromRecordsConf, "%s%s%s", snap_dir_cpy, DIR_SEP, snap_name);
-
-         snap_dir = snap_dir_cpy;
-         } */
-
-      found = (RecGetRecordString_Xmalloc("proxy.config.temp_dir", &tempDirFromRecordsConf)
-               == REC_ERR_OKAY);
-
-      ink_release_assert(found);
-
-      int newLen;
-      char *newStr;
-
-      newLen = strlen(tempDirFromRecordsConf) + strlen(snap_name) + 2;
-      char *tmp_ftp_snap = new char[newLen];
-      ink_assert(tmp_ftp_snap != NULL);
-      snprintf(tmp_ftp_snap, newLen, "%s%s%s", tempDirFromRecordsConf, DIR_SEP, snap_name);
-
-      newLen = strlen(snap_name) + strlen(ftp_remote_dir) + 2;
-      newStr = new char[newLen];
-      ink_assert(newStr != NULL);
-      snprintf(newStr, newLen, "%s%s%s", ftp_remote_dir, DIR_SEP, snap_name);
-
-      if (mkdir(tmp_ftp_snap, DIR_MODE) < 0) {
-        mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_ftpsystem] Cannot create %s\n", tmp_ftp_snap);
-      }
-      char ftpOutput[4096];
-      INKMgmtFtp("get", ftp_server_name, ftp_login, ftp_password, tmp_ftp_snap, newStr, ftpOutput);
-      if (!strncmp(ftpOutput, "ERROR:", 6)) {
-        mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_ftpsystem] FTP get failed : %s", ftpOutput);
-        goto Ldone;
-      }
-      // TODO: Check return values?
-      configFiles->restoreSnap(snap_name, tempDirFromRecordsConf);
-      configFiles->removeSnap(snap_name, tempDirFromRecordsConf);
-    }
-  }
-
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "FTPSaveName", (void **) &snap_name)) {
-    if (snap_name != NULL) {
-      int localDirLength, remoteDirLength;
-      char *newStr;
-      char *ftp_remote_dir_name;
-
-      localDirLength = strlen(snap_name) + strlen("/tmp") + 2;
-      remoteDirLength = strlen(snap_name) + strlen(ftp_remote_dir) + 2;
-
-      newStr = new char[localDirLength];
-      ink_assert(newStr != NULL);
-      ftp_remote_dir_name = new char[remoteDirLength];
-      ink_assert(ftp_remote_dir_name != NULL);
-      snprintf(newStr, localDirLength, "/tmp%s%s", DIR_SEP, snap_name);
-      snprintf(ftp_remote_dir_name, remoteDirLength, "%s%s%s", ftp_remote_dir, DIR_SEP, snap_name);
-      configFiles->takeSnap(snap_name, "/tmp");
-      char ftpOutput[4096];
-      INKMgmtFtp("put", ftp_server_name, ftp_login, ftp_password, newStr, ftp_remote_dir_name, ftpOutput);
-      if (!strncmp(ftpOutput, "ERROR:", 6)) {
-        //mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_ftpsystem] FTP put failed : %s", ftpOutput);
-        fprintf(stderr, "[WebHttp::handle_submit_snapshot_to_ftpsystem] FTP put failed : %s", ftpOutput);
-        if (!strncmp(ftpOutput, "ERROR: FTP Put:: permission", 27)) {
-          ink_hash_table_insert(whc->submit_warn_ht, "FTPRemoteDirError", NULL);
-          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;
-        }
-        goto Ldone;
-      }
-    }
-  }
-#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_snapshot_to_floppy
-//-------------------------------------------------------------------------
-
-static int
-handle_submit_snapshot_to_floppy(WebHttpContext * whc, const char *file)
-{
-  NOWARN_UNUSED(file);
-  int err = 0;
-  SnapResult snap_result = SNAP_OK;
-  char *submit_from_page;
-  char *snapDirFromRecordsConf;
-  char *cancel;
-  char *floppy_drive_mount_point;
-  char *floppy_selected_snap_name;
-  char *floppy_snap_name;
-  // Not used here.
-  //struct stat snapDirStat;
-  char config_dir[256];
-  char *record_version;
-  char *UnmountFloppy;
-  int old_euid;
-  const char *linkFile;
-  ExpandingArray snap_list(25, true);
-
-  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);
-  }
-#ifndef _WIN32
-
-   /**
-     Unmount Floppy
-    **/
-  if (ink_hash_table_lookup(whc->post_data_ht, "Unmount Floppy", (void **) &UnmountFloppy)) {
-    if (UnmountFloppy != NULL) {
-      int ret = 0;
-
-      if (strcmp(UnmountFloppy, "Unmount Floppy") == 0) {
-        char unmountPath[1024];
-
-        if (ink_hash_table_lookup(whc->post_data_ht, "FloppyPath", (void **) &floppy_drive_mount_point)) {
-          if (floppy_drive_mount_point != NULL)
-            snprintf(unmountPath, sizeof(unmountPath), "/bin/umount %s", floppy_drive_mount_point);
-          else {
-            NOWARN_UNUSED_RETURN(system("sync;sync;sync"));
-            linkFile = "/configure/c_snapshot_floppy.ink";
-            ink_hash_table_insert(whc->submit_warn_ht, "CouldnotUnmount", NULL);
-            if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-              HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_FLOPPY_UNMOUNT_ERR);
-              HtmlRndrBr(whc->submit_warn);
-            }
-            whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-            if (submit_from_page)
-              xfree(submit_from_page);
-            submit_from_page = xstrdup(linkFile);
-            goto Ldone;
-          }
-        }
-        pid_t pid;
-        if ((pid = fork()) < 0) {
-          goto Ldone;
-        } else if (pid == 0) {
-          old_euid = getuid();
-          seteuid(0);
-          setreuid(0, 0);
-          ret = system(unmountPath);
-          setreuid(old_euid, old_euid);
-          exit(ret / 256);
-        } else {
-          wait(&ret);
-        }
-      }
-      if ((ret / 256)) {
-        linkFile = "/configure/c_snapshot_floppy.ink";
-        ink_hash_table_insert(whc->submit_warn_ht, "CouldnotUnmount", NULL);
-        if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-          HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_FLOPPY_UNMOUNT_ERR);
-          HtmlRndrBr(whc->submit_warn);
-        }
-        whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-        if (submit_from_page)
-          xfree(submit_from_page);
-        submit_from_page = xstrdup(linkFile);
-        goto Ldone;
-      } else {
-        linkFile = "/configure/c_basic.ink";
-      }
-
-#if TS_HAS_WEBUI
-      char *link = WebHttpGetLink_Xmalloc(linkFile);
-      whc->response_hdr->setRefreshURL(link);
-      xfree(link);
-#endif
-      whc->response_hdr->setRefresh(0);
-      if (submit_from_page)
-        xfree(submit_from_page);
-      submit_from_page = xstrdup(linkFile);
-      goto Ldone;
-    }
-  }
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "floppy_select", (void **) &floppy_selected_snap_name)) {
-    if (floppy_selected_snap_name != NULL) {
-      if (strcmp(floppy_selected_snap_name, "- select a snapshot -")) {
-        if (ink_hash_table_lookup(whc->post_data_ht, "FloppyPath", (void **) &floppy_drive_mount_point)) {
-
-          RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf);
-
-          if (snapDirFromRecordsConf[0] != '/') {
-            // coverity[alloc_fn][var_assign]
-            char *snap_dir_cpy = strdup(snapDirFromRecordsConf);
-            int newLen;
-
-            // coverity[noescape]
-            newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
-            snapDirFromRecordsConf = new char[newLen];
-            ink_assert(snapDirFromRecordsConf != NULL);
-            // coverity[noescape]
-            snprintf(snapDirFromRecordsConf, newLen, "%s%s%s", config_dir, DIR_SEP, snap_dir_cpy);
-            if (snap_dir_cpy)
-              free(snap_dir_cpy);
-          }
-          if (ink_hash_table_lookup(whc->post_data_ht, "FloppyPath", (void **) &floppy_drive_mount_point)) {
-            snap_result = configFiles->restoreSnap(floppy_selected_snap_name, floppy_drive_mount_point);
-            if (snap_result < 0) {
-              mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_floppy] Restore snap failed");
-            }
-
-          }
-        }
-      }
-    }
-  }
-
-
-  if (ink_hash_table_lookup(whc->post_data_ht, "FloppySnapName", (void **) &floppy_snap_name)) {
-    if (floppy_snap_name != NULL) {
-      if (ink_hash_table_lookup(whc->post_data_ht, "FloppyPath", (void **) &floppy_drive_mount_point)) {
-
-        struct dirent *dirEntry;
-        DIR *dir;
-        char *fileName;
-        // Doesn't seem to be used.
-        //struct stat fileInfo;
-        //struct stat records_config_fileInfo;
-        //fileEntry* fileListEntry;
-
-        dir = opendir(floppy_drive_mount_point);
-
-        if (dir == NULL) {
-          mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_floppy] Unable to open %s directory: %s\n",
-                   floppy_drive_mount_point, strerror(errno));
-          return -1;
-        }
-        // The fun of Solaris - readdir_r requires a buffer passed into it
-        //   The man page says this obscene expression gives us the proper
-        //     size
-        dirEntry = (struct dirent *) xmalloc(sizeof(struct dirent) + pathconf(".", _PC_NAME_MAX) + 1);
-        struct dirent *result;
-        while (readdir_r(dir, dirEntry, &result) == 0) {
-          if (!result)
-            break;
-          fileName = dirEntry->d_name;
-          if (!strcmp(fileName, floppy_snap_name)) {
-            ink_hash_table_insert(whc->submit_warn_ht, "FloppyError", 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;
-            xfree(dirEntry);
-            closedir(dir);
-            goto Ldone;
-          }
-        }
-
-        xfree(dirEntry);
-        closedir(dir);
-
-
-        snap_result = configFiles->takeSnap(floppy_snap_name, floppy_drive_mount_point);
-        if (snap_result < 0) {
-          mgmt_log(stderr, "[WebHttp::handle_submit_snapshot_to_floppy] Take snap failed");
-        } else if (snap_result == 6) {
-          // BZ50256
-          ink_hash_table_insert(whc->submit_warn_ht, "FloppySaveFailed", NULL);
-          if (!(whc->request_state & WEB_HTTP_STATE_SUBMIT_WARN)) {
-            HtmlRndrText(whc->submit_warn, whc->lang_dict_ht, HTML_ID_FLOPPY_NO_SPACE);
-            HtmlRndrBr(whc->submit_warn);
-          }
-          whc->request_state |= WEB_HTTP_STATE_SUBMIT_WARN;
-          goto Ldone;
-        }
-        ink_hash_table_delete(whc->post_data_ht, "FloppySnapName");
-      }
-    }
-  }
-#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_inspector
 //-------------------------------------------------------------------------
@@ -3681,9 +2879,6 @@ WebHttpInit()
   //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_SNAPSHOT_FTPSERVER,
-                        (void *) handle_submit_snapshot_to_ftpserver);
-  ink_hash_table_insert(g_submit_bindings_ht, HTML_SUBMIT_SNAPSHOT_FLOPPY, (void *) handle_submit_snapshot_to_floppy);
   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);

Modified: trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttpRender.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttpRender.cc?rev=1057958&r1=1057957&r2=1057958&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttpRender.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttpRender.cc Wed Jan 12 00:39:11 2011
@@ -1121,300 +1121,6 @@ handle_action_checked(WebHttpContext * w
   return WEB_HTTP_ERR_OKAY;
 }
 
-static int
-handle_ftp_select(WebHttpContext * whc)
-{
-
-  char *ftp_server_name;
-  char *ftp_remote_dir;
-  char *ftp_login;
-  char *ftp_password;
-  // Not used here.
-  //struct stat snapDirStat;
-  ExpandingArray snap_list(25, true);
-  textBuffer *output = whc->response_bdy;
-
-  if (whc->post_data_ht != NULL) {
-    if (ink_hash_table_lookup(whc->post_data_ht, "FTPServerName", (void **) &ftp_server_name)) {
-      if (ftp_server_name == NULL) {
-        return -1;
-      }
-    }
-
-    if (ink_hash_table_lookup(whc->post_data_ht, "FTPUserName", (void **) &ftp_login)) {
-      if (ftp_login == NULL) {
-        return -1;
-      }
-    }
-    if (ink_hash_table_lookup(whc->post_data_ht, "FTPPassword", (void **) &ftp_password)) {
-      if (ftp_server_name == NULL) {
-        return -1;
-      }
-    }
-    if (ink_hash_table_lookup(whc->post_data_ht, "FTPRemoteDir", (void **) &ftp_remote_dir)) {
-      if (ftp_server_name == NULL) {
-        return -1;
-      }
-    }
-
-    if ((ftp_server_name != NULL) && (ftp_login != NULL) && (ftp_password != NULL) && (ftp_remote_dir != NULL)) {
-      char ftpOutput[4096];
-      ink_strncpy(ftpOutput, "", sizeof(ftpOutput));
-      INKMgmtFtp("list", ftp_server_name, ftp_login, ftp_password, "", ftp_remote_dir, ftpOutput);
-      if (!strncmp(ftpOutput, "ERROR:", 6)) {
-        HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-        HtmlRndrTdOpen(output, HTML_CSS_RED_LABEL, HTML_ALIGN_CENTER, HTML_VALIGN_NONE, NULL, "2", 2);
-        output->copyFrom(ftpOutput, strlen(ftpOutput));
-        HtmlRndrTdClose(output);
-        HtmlRndrTrClose(output);
-        return -1;
-      }
-
-      SimpleTokenizer snapDirPathTok(ftpOutput, ' ');
-      int numOptions = snapDirPathTok.getNumTokensRemaining();
-      const char *default_text = "- select a snapshot -";
-
-      HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-      HtmlRndrTdOpen(output, HTML_CSS_CONFIGURE_LABEL, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, "2", 2);
-      output->copyFrom("Restore Snapshot", strlen("Restore Snapshot"));
-      HtmlRndrTdClose(output);
-      HtmlRndrTrClose(output);
-
-      HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-      HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, "2", 0);
-
-      HtmlRndrSelectOpen(output, HTML_CSS_NONE, "ftp_select", 1);
-      HtmlRndrOptionOpen(output, 0, true);
-      output->copyFrom(default_text, strlen(default_text));
-      HtmlRndrOptionClose(output);
-      for (int i = 1; i <= numOptions; i++) {
-        HtmlRndrOptionOpen(output, 0, false);
-        const char *nextOption = snapDirPathTok.getNext();
-        output->copyFrom(nextOption, strlen(nextOption));
-        HtmlRndrOptionClose(output);
-      }
-      HtmlRndrSelectClose(output);
-      HtmlRndrTdClose(output);
-
-      HtmlRndrTdOpen(output, HTML_CSS_CONFIGURE_HELP, HTML_ALIGN_LEFT, HTML_VALIGN_TOP, NULL, NULL, 0);
-      output->copyFrom("<ul> <li>Select the snapshot to restore from FTP server.</ul>",
-                       strlen("<ul> <li>Select the snapshot to restore from FTP server.</ul>"));
-
-      HtmlRndrTdClose(output);
-      HtmlRndrTrClose(output);
-
-
-      HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-      HtmlRndrTdOpen(output, HTML_CSS_CONFIGURE_LABEL, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, "2", 2);
-      InkHashTableEntry *warn_snapname = ink_hash_table_lookup_entry(whc->submit_warn_ht, "FTPSaveName");
-      if (warn_snapname) {
-        output->copyFrom("<span class=\"redLabel\">!&nbsp;</span>Save Snapshot to FTP Server",
-                         strlen("<span class=\"redLabel\">!&nbsp;</span>Save Snapshot to FTP Server"));
-      } else {
-        output->copyFrom("Save snapshot to FTP server", strlen("Save Snapshot to FTP Server"));
-      }
-      HtmlRndrTdClose(output);
-      HtmlRndrTrClose(output);
-
-      HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-      HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, "2", 0);
-      if (warn_snapname) {
-        char *warn_name;
-        char str[1024];
-        if (ink_hash_table_lookup(whc->post_data_ht, "FTPSaveName", (void **) &warn_name)) {
-          if (warn_name != NULL) {
-            snprintf(str, sizeof(str), "<input type=\"text\" size=\"22\" name=\"FTPSaveName\" value=\"%s\">",
-                         warn_name);
-          } else {
-            snprintf(str, sizeof(str), "<input type=\"text\" size=\"22\" name=\"FTPSaveName\" value=\"\">");
-          }
-        }
-        output->copyFrom(str, strlen(str));
-      } else {
-        output->copyFrom("<input type=\"text\" size=\"22\" name=\"FTPSaveName\" value=\"\">",
-                         strlen("<input type=\"text\" size=\"22\" name=\"FTPSaveName\" value=\"\">"));
-      }
-      //output->copyFrom("<input type=\"text\" size=\"22\" name=\"FTPSaveName\" value=\"\">", strlen("<input type=\"text\" size=\"22\" name=\"FTPSaveName\" value=\"\">"));
-
-      HtmlRndrTdClose(output);
-
-      HtmlRndrTdOpen(output, HTML_CSS_CONFIGURE_HELP, HTML_ALIGN_LEFT, HTML_VALIGN_TOP, NULL, NULL, 0);
-      output->copyFrom("<ul> <li>Name of the snapshot to save on the FTP server.</ul>",
-                       strlen("<ul> <li>Name of the snapshot to save on the FTP server.</ul>"));
-
-      HtmlRndrTdClose(output);
-      HtmlRndrTrClose(output);
-
-
-    }
-  }
-  return WEB_HTTP_ERR_OKAY;
-}
-
-
-
-
-char *
-floppyPathString(const char *s1, const char *s2)
-{
-  int newLen;
-  char *newStr;
-
-  newLen = strlen(s1) + strlen(s2) + 2;
-  newStr = new char[newLen];
-  ink_assert(newStr != NULL);
-  snprintf(newStr, newLen, "%s%s%s", s1, DIR_SEP, s2);
-  return newStr;
-}
-
-
-static int
-handle_floppy_select(WebHttpContext * whc)
-{
-
-  char *snap_name;
-  // Not used here.
-  //struct stat snapDirStat;
-  char *floppy_drive_mount_point;
-  ExpandingArray snap_list(25, true);
-
-#ifndef _WIN32
-
-  if (whc->post_data_ht != NULL) {
-    if (ink_hash_table_lookup(whc->post_data_ht, "FloppyDrive", (void **) &floppy_drive_mount_point)) {
-      if (floppy_drive_mount_point == NULL) {
-        printf("floppy_drive_mount_point = NULL\n");
-        return -1;
-      } else {
-        struct dirent *dirEntry;
-        DIR *dir;
-        char *fileName;
-        char *filePath;
-        char *records_config_filePath;
-        struct stat fileInfo;
-        struct stat records_config_fileInfo;
-        // Not used here.
-        //fileEntry* fileListEntry;
-        textBuffer *output = whc->response_bdy;
-        const char *default_text = "- select a snapshot -";
-
-        dir = opendir(floppy_drive_mount_point);
-
-        if (dir == NULL) {
-          mgmt_log(stderr, "[WebHttpRender:: handle_floppy_select] Unable to open %s directory: %s\n",
-                   floppy_drive_mount_point, strerror(errno));
-          return -1;
-        }
-
-        HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-        HtmlRndrTdOpen(output, HTML_CSS_CONFIGURE_HELP, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, "2", 0);
-        output->
-          copyFrom
-          ("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" name=\"Unmount Floppy\" value=\"Unmount Floppy\">",
-           strlen
-           ("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" name=\"Unmount Floppy\" value=\"Unmount Floppy\">"));
-        output->copyFrom("&nbsp;Unmount Floppy", strlen("&nbsp;Unmount Floppy"));
-
-        HtmlRndrTdClose(output);
-        HtmlRndrTrClose(output);
-
-        dirEntry = (struct dirent *) xmalloc(sizeof(struct dirent) + pathconf(".", _PC_NAME_MAX) + 1);
-
-        HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-        HtmlRndrTdOpen(output, HTML_CSS_CONFIGURE_LABEL, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, "2", 2);
-        output->copyFrom("Restore Snapshot", strlen("Restore Snapshot"));
-        HtmlRndrTdClose(output);
-        HtmlRndrTrClose(output);
-
-        HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-        HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, "2", 0);
-
-        HtmlRndrSelectOpen(output, HTML_CSS_NONE, "floppy_select", 1);
-        HtmlRndrOptionOpen(output, 0, true);
-        output->copyFrom(default_text, strlen(default_text));
-        HtmlRndrOptionClose(output);
-
-        struct dirent *result;
-        while (readdir_r(dir, dirEntry, &result) == 0) {
-          if (!result)
-            break;
-          fileName = dirEntry->d_name;
-          filePath = floppyPathString(floppy_drive_mount_point, fileName);
-          records_config_filePath = floppyPathString(filePath, "records.config");
-          if (stat(filePath, &fileInfo) < 0) {
-            mgmt_log(stderr, "[WebHttpRender::handle_floppy_select] Stat of %s failed %s\n", fileName, strerror(errno));
-          } else {
-            if (stat(records_config_filePath, &records_config_fileInfo) < 0) {
-              continue;
-            }
-            // Ignore ., .., and any dot files
-            if (*fileName != '.' && (strcmp(fileName, ".."))) {
-              HtmlRndrOptionOpen(output, 0, false);
-              output->copyFrom(fileName, strlen(fileName));
-              HtmlRndrOptionClose(output);
-            }
-          }
-          delete[]filePath;
-        }
-
-        xfree(dirEntry);
-        closedir(dir);
-
-        HtmlRndrSelectClose(output);
-        HtmlRndrTdClose(output);
-
-        HtmlRndrTdOpen(output, HTML_CSS_CONFIGURE_HELP, HTML_ALIGN_LEFT, HTML_VALIGN_TOP, NULL, NULL, 0);
-        output->copyFrom("<ul> <li>Select the snapshot to restore from the floppy drive.</ul>",
-                         strlen("<ul> <li>Select the snapshot to restore from the floppy drive.</ul>"));
-
-        HtmlRndrTdClose(output);
-        HtmlRndrTrClose(output);
-
-
-        HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-        HtmlRndrTdOpen(output, HTML_CSS_CONFIGURE_LABEL, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, "2", 2);
-        output->copyFrom("Save Snapshot to Floppy", strlen("Save Snapshot to Floppy"));
-        HtmlRndrTdClose(output);
-        HtmlRndrTrClose(output);
-
-        HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
-        HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, "2", 0);
-        HtmlRndrInput(output, HTML_CSS_NONE, HTML_TYPE_HIDDEN, "FloppyPath", floppy_drive_mount_point, NULL, NULL);
-
-        if (ink_hash_table_lookup(whc->post_data_ht, "FloppySnapName", (void **) &snap_name)) {
-          if (snap_name == NULL) {
-            output->copyFrom("<input type=\"text\" size=\"22\" name=\"FloppySnapName\" value=\"\">",
-                             strlen("<input type=\"text\" size=\"22\" name=\"FloppySnapName\" value=\"\">"));
-          } else {
-            char input_string[256];
-            snprintf(input_string, sizeof(input_string),
-                         "<input type=\"text\" size=\"22\" name=\"FloppySnapName\" value=\"%s\">", snap_name);
-            output->copyFrom(input_string, strlen(input_string));
-          }
-        } else {
-          output->copyFrom("<input type=\"text\" size=\"22\" name=\"FloppySnapName\" value=\"\">",
-                           strlen("<input type=\"text\" size=\"22\" name=\"FloppySnapName\" value=\"\">"));
-        }
-
-        HtmlRndrTdClose(output);
-
-        HtmlRndrTdOpen(output, HTML_CSS_CONFIGURE_HELP, HTML_ALIGN_LEFT, HTML_VALIGN_TOP, NULL, NULL, 0);
-        output->copyFrom("<ul> <li>Select the snapshot to save on the floppy disk.</ul>",
-                         strlen("<ul> <li>Select the snapshot to save on the floppy disk.</ul>"));
-
-        HtmlRndrTdClose(output);
-        HtmlRndrTrClose(output);
-
-
-      }
-    }
-
-  }
-#endif
-
-  return WEB_HTTP_ERR_OKAY;
-}
-
 
 
 
@@ -1427,10 +1133,6 @@ handle_select(WebHttpContext * whc, char
   NOWARN_UNUSED(tag);
   if (strcmp(arg, "snapshot") == 0) {
     configFiles->displaySnapOption(whc->response_bdy);
-  } else if (strcmp(arg, "ftp_snapshot") == 0) {
-    handle_ftp_select(whc);
-  } else if (strcmp(arg, "floppy_drive") == 0) {
-    handle_floppy_select(whc);
   }
   return WEB_HTTP_ERR_OKAY;
 }



Mime
View raw message