You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ig...@apache.org on 2014/01/20 15:44:55 UTC

[2/3] git commit: remove the functions in which StartTrafficServer() and StopTrafficServer() was referenced

remove the functions in which StartTrafficServer() and StopTrafficServer() was referenced


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7f4ea4dd
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7f4ea4dd
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7f4ea4dd

Branch: refs/heads/TS-645-hard-restart
Commit: 7f4ea4dd2a5930a54a0e7a9505a9587825af7ba2
Parents: 3817006
Author: Igor Galić <i....@brainsware.org>
Authored: Mon Jan 20 15:29:50 2014 +0100
Committer: Igor Galić <i....@brainsware.org>
Committed: Mon Jan 20 15:29:50 2014 +0100

----------------------------------------------------------------------
 cmd/traffic_shell/CliCreateCommands.cc |   5 -
 cmd/traffic_shell/ConfigCmd.cc         | 377 ----------------------------
 cmd/traffic_shell/ConfigCmd.h          |  26 --
 3 files changed, 408 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f4ea4dd/cmd/traffic_shell/CliCreateCommands.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/CliCreateCommands.cc b/cmd/traffic_shell/CliCreateCommands.cc
index 5a22207..cd57f44 100644
--- a/cmd/traffic_shell/CliCreateCommands.cc
+++ b/cmd/traffic_shell/CliCreateCommands.cc
@@ -150,11 +150,6 @@ CliCreateCommands()
   createCommand("config:remap", Cmd_ConfigRemap, NULL, CLI_COMMAND_EXTERNAL,
                 "config:remap <url>", "Update remap configuration file <url>");
 
-  createCommand("config:clock", Cmd_ConfigClock, CmdArgs_ConfigClock, CLI_COMMAND_EXTERNAL,
-                "config:clock date <mm/dd/yyyy>\n"
-                "config:clock time <hh:mm:ss>\n"
-                "config:clock timezone <number from list | list>", "Configure date, time, timezone");
-
   createCommand("config:security", Cmd_ConfigSecurity, CmdArgs_ConfigSecurity, CLI_COMMAND_EXTERNAL,
                 "config:security <ip-allow | mgmt-allow | admin> <url-config-file>\n"
                 "config:security password", "Update security configuration");

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f4ea4dd/cmd/traffic_shell/ConfigCmd.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ConfigCmd.cc b/cmd/traffic_shell/ConfigCmd.cc
index a40da20..2bdda42 100644
--- a/cmd/traffic_shell/ConfigCmd.cc
+++ b/cmd/traffic_shell/ConfigCmd.cc
@@ -760,90 +760,6 @@ CmdArgs_ConfigPorts()
   return 0;
 }
 
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigClock
-//
-// This is the callback function for the "config:clock" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigClock(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  int setvar = 0;
-
-  if (cliCheckIfEnabled("config:clock") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigClock argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  Cli_PrintArg(0, argtable);
-  Cli_PrintArg(1, argtable);
-
-  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable[0].parsed_args) {
-    case CMD_CONFIG_DATE:
-      return (ConfigDate(argtable->arg_string));
-    case CMD_CONFIG_TIME:
-      return (ConfigTime(argtable->arg_string));
-    case CMD_CONFIG_TIMEZONE:
-      if (argc == 3) {
-        setvar = 1;
-      }
-      if (argtable[1].parsed_args == CMD_CONFIG_TIMEZONE_LIST) {
-        return (ConfigTimezoneList());
-      } else {
-        return (ConfigTimezone(argtable->arg_int, setvar));
-      }
-    }
-  }
-
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigClock
-//
-// Register "config:clock" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigClock()
-{
-  createArgument("date", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_DATE, "System Date <mm/dd/yyyy>", (char *) NULL);
-
-  createArgument("time", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_TIME, "System Time <hh:mm:ss>", (char *) NULL);
-
-  createArgument("timezone", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_TIMEZONE, "Time Zone", (char *) NULL);
-
-  createArgument("list", CMD_CONFIG_TIMEZONE, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_TIMEZONE_LIST, "Display Time Zone List", (char *) NULL);
-
-  return 0;
-}
 
 ////////////////////////////////////////////////////////////////
 // Cmd_ConfigSecurity
@@ -2518,299 +2434,6 @@ ConfigRemap(const char *url)
   return (Cli_SetConfigFileFromUrl(TS_FNAME_REMAP, url));
 }
 
-// config date sub-command
-//   used to set or display the system date
-
-int
-ConfigDate(char *datestr)
-{
-
-  if (datestr) {                // set the date
-    Cli_Debug("ConfigDate: set date %s\n", datestr);
-
-    if (getuid() != 0) {
-      Cli_Printf("\nMust be \"root\" user to change the date.\n"
-                 "Use \"config:root\" command to switch to root user.\n");
-      return CLI_ERROR;
-    }
-
-
-    struct tm *mPtr;
-    struct timeval v;
-    struct DateTime t;
-    int yy, mm, dd;
-
-    memset(&v, 0, sizeof(struct timeval));
-    memset(&t, 0, sizeof(struct DateTime));
-
-
-    // add strlen() check to avoid string overflow, so we can disable coverity check here
-    // coverity[secure_coding]
-    if (strlen(datestr) != 10 || sscanf(datestr, "%[0-9]/%[0-9]/%[0-9]", t.str_mm, t.str_dd, t.str_yy) != 3) {
-      Cli_Printf("Error: <date> = mm/dd/yyyy \n");
-      return CLI_ERROR;
-    }
-
-    Cli_Debug("%s-%s-%s\n", t.str_mm, t.str_dd, t.str_yy);
-
-    mm = atoi(t.str_mm);
-    dd = atoi(t.str_dd);
-    yy = atoi(t.str_yy);
-
-    Cli_Debug("%d-%d-%d\n", mm, dd, yy);
-
-    if (!((dd >= 1) && (dd <= 31)
-          && (mm >= 1) && (mm <= 12)
-          && (yy >= 1900) && (yy <= 2100))) {
-      Cli_Printf("Error: Invalid Date Value \n");
-      return CLI_ERROR;
-    }
-
-    if (gettimeofday(&v, NULL)) {
-      Cli_Debug("Error Getting Time \n");
-      return CLI_ERROR;
-    }
-
-    mPtr = localtime((const time_t *)&(v.tv_sec));
-
-    mPtr->tm_mday = dd;
-    mPtr->tm_mon = mm - 1;
-    mPtr->tm_year = yy - 1900;
-    if ((v.tv_sec = mktime(mPtr)) < 0) {
-      Cli_Printf("ERROR: invalid date \n");
-      return CLI_ERROR;
-    }
-
-    Cli_Printf("Stopping Proxy software while changing clock settings.\n");
-
-    StopTrafficServer();
-
-    if (settimeofday(&v, NULL) == -1) {
-      Cli_Printf("Error: could not update date \n");
-      StartTrafficServer();
-      return CLI_ERROR;
-    }
-    if (system("/sbin/hwclock --systohc --utc") != 0) {
-      Cli_Error("ERROR: Unable to set hardware clock.\n");
-      exit(1);
-    }
-    StartTrafficServer();
-  }
-
-
-  Cli_Debug("Config:clock: get date\n");
-  if (system("date '+DATE: %m/%d/%Y'") == -1)
-    return CLI_ERROR;
-
-  return CLI_OK;
-
-}
-
-
-// config time sub-command
-//   used to set or display the system time
-int
-ConfigTime(char *timestr)
-{
-
-  if (timestr) {                // set the time
-    Cli_Debug("ConfigTime: set time %s\n", timestr);
-    if (getuid() != 0) {
-      Cli_Printf("\nMust be \"root\" user to change the time.\n"
-                 "Use \"config:root\" command to switch to root user.\n");
-      return CLI_ERROR;
-    }
-
-    struct tm *mPtr;
-    struct timeval v;
-    struct DateTime t;
-    int hour, min, sec;
-
-    memset(&v, 0, sizeof(struct timeval));
-    memset(&t, 0, sizeof(struct DateTime));
-
-    // add strlen() check to avoid string overflow, so we can disable coverity check here
-    // coverity[secure_coding]
-    if (strlen(timestr) != 8 || sscanf(timestr, "%[0-9]:%[0-9]:%[0-9]", t.str_hh, t.str_min, t.str_ss) != 3) {
-      Cli_Printf("Error: <time> = hh:mm:ss \n");
-      return CLI_ERROR;
-    }
-
-    Cli_Debug("%s-%s-%s\n", t.str_hh, t.str_min, t.str_ss);
-
-    hour = atoi(t.str_hh);
-    min = atoi(t.str_min);
-    sec = atoi(t.str_ss);
-    Cli_Debug("%d-%d-%d\n", hour, min, sec);
-
-    if (!((hour >= 0) && (hour <= 23)
-          && (min >= 0) && (min <= 59)
-          && (sec >= 0) && (sec <= 59))) {
-      Cli_Printf("ERROR: Invalid Time Value \n");
-      return CLI_ERROR;
-    }
-
-    if (gettimeofday(&v, NULL)) {
-      Cli_Printf("Error Getting Time \n");
-      return CLI_ERROR;
-    }
-
-    mPtr = localtime((const time_t *)&(v.tv_sec));
-
-    mPtr->tm_sec = sec;
-    mPtr->tm_min = min;
-    mPtr->tm_hour = hour;
-    if ((v.tv_sec = mktime(mPtr)) < 0) {
-      Cli_Printf("ERROR: invalid time \n");
-      return CLI_ERROR;
-    }
-
-    Cli_Printf("Stopping Proxy software while changing clock settings.\n");
-
-    StopTrafficServer();
-
-    if (settimeofday(&v, NULL) == -1) {
-      Cli_Printf("ERROR: could not update time \n");
-
-      StartTrafficServer();
-
-      return CLI_ERROR;
-    }
-
-    if (system("/sbin/hwclock --systohc --utc") != 0) {
-      Cli_Error("ERROR: Unable to set hardware clock.\n");
-    }
-
-    StartTrafficServer();
-  }
-
-  Cli_Debug("Config:clock: get time\n");
-  if (system("date '+TIME: %H:%M:%S'") == -1)
-    Cli_Error("ERROR: Unable to set date.\n");
-
-  return CLI_OK;
-}
-
-// config timezone sub-command
-//   used to set the system timezone
-int
-ConfigTimezone(int index, int setvar)
-{
-
-  Cli_Debug("ConfigTime: %d %d\n", index, setvar);
-
-  FILE *fp, *tmp;
-  const char *zonetable = "/usr/share/zoneinfo/zone.tab";
-  char command[256];
-  char buffer[1024];
-  char old_zone[1024];
-  char new_zone[1024];
-  char *zone;
-
-  new_zone[0] = 0;
-
-  fp = fopen(zonetable, "r");
-  tmp = fopen("/tmp/zonetab.tmp", "w");
-  if (fp == NULL || tmp == NULL) {
-    printf("can not open the file\n");
-    return CLI_ERROR;
-  }
-  ATS_UNUSED_RETURN(fgets(buffer, 1024, fp));
-  while (!feof(fp)) {
-    if (buffer[0] != '#') {
-      strtok(buffer, " \t");
-      strtok(NULL, " \t");
-      zone = strtok(NULL, " \t");
-      if (zone[strlen(zone) - 1] == '\n') {
-        zone[strlen(zone) - 1] = '\0';
-      }
-      fprintf(tmp, "%s\n", zone);
-    }
-    ATS_UNUSED_RETURN(fgets(buffer, 1024, fp));
-  }
-  fclose(fp);
-  fclose(tmp);
-  remove("/tmp/zonetab");
-  ATS_UNUSED_RETURN(system("/bin/sort /tmp/zonetab.tmp > /tmp/zonetab"));
-
-  fp = fopen("/tmp/zonetab", "r");
-  ATS_UNUSED_RETURN(fgets(buffer, 1024, fp));
-  int i = 0;
-  while (!feof(fp)) {
-    zone = buffer;
-    if (zone[strlen(zone) - 1] == '\n') {
-      zone[strlen(zone) - 1] = '\0';
-    }
-    if (setvar) {
-      if (index == i) {
-        ink_strlcpy(new_zone, zone, sizeof(new_zone));
-      }
-    }
-    ATS_UNUSED_RETURN(fgets(buffer, 1024, fp));
-    i++;
-  }
-  fclose(fp);
-  remove("/tmp/zonetab.tmp");
-  remove("/tmp/zonetab");
-
-  switch (setvar) {
-  case 0:                      //get
-    find_value("/etc/sysconfig/clock", "ZONE", old_zone, sizeof(old_zone), "=", 0);
-    if (strlen(old_zone)) {
-      Cli_Printf("%s\n", old_zone);
-    } else {
-      Cli_Printf("NULL\n");
-    }
-    return CLI_OK;
-
-  case 1:                      //set
-    if (getuid() != 0) {
-      Cli_Printf("\nMust be \"root\" user to change the timezone.\n"
-                 "Use \"config:root\" command to switch to root user.\n");
-      return CLI_ERROR;
-    }
-
-    if (!strlen(new_zone)) {
-      Cli_Error("ERROR: Invalid timezone specified.\n");
-      return CLI_ERROR;
-    }
-
-    Cli_Printf("Stopping Proxy software while changing clock settings.\n");
-
-    StopTrafficServer();
-
-    Cli_Printf("New timezone is %s\n", new_zone);
-
-    fp = fopen("/etc/sysconfig/clock", "r");
-    tmp = fopen("/tmp/clock.tmp", "w");
-    ATS_UNUSED_RETURN(fgets(buffer, 256, fp));
-    while (!feof(fp)) {
-      if (strstr(buffer, "ZONE") != NULL) {
-        fprintf(tmp, "ZONE=\"%s\"\n", new_zone);
-      } else if (strstr(buffer, "UTC") != NULL) {
-        fprintf(tmp, "UTC=true\n");
-      } else {
-        fputs(buffer, tmp);
-      }
-      ATS_UNUSED_RETURN(fgets(buffer, 256, fp));
-    }
-    fclose(fp);
-    fclose(tmp);
-    if (system("/bin/mv /tmp/clock.tmp /etc/sysconfig/clock") == -1)
-      return CLI_ERROR;
-
-    snprintf(command, sizeof(command), "/bin/cp -f /usr/share/zoneinfo/%s /etc/localtime", new_zone);
-    if (system(command) == -1)
-      return CLI_ERROR;
-
-    StartTrafficServer();
-
-    return CLI_OK;
-
-  }
-  Cli_Printf("Error in File Open to Read\n");
-  return CLI_ERROR;
-}
 
 int
 ConfigTimezoneList()

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f4ea4dd/cmd/traffic_shell/ConfigCmd.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ConfigCmd.h b/cmd/traffic_shell/ConfigCmd.h
index 42ed681..84456fc 100644
--- a/cmd/traffic_shell/ConfigCmd.h
+++ b/cmd/traffic_shell/ConfigCmd.h
@@ -460,26 +460,6 @@ int Cmd_ConfigSocks(ClientData clientData, Tcl_Interp * interp, int argc, const
 int CmdArgs_ConfigSocks();
 
 ////////////////////////////////////////////////////////////////
-// Cmd_ConfigClock
-//
-// This is the callback function for the "config:clock" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigClock(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigClock
-//
-// Register "config:clock" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigClock();
-
-////////////////////////////////////////////////////////////////
 // Cmd_ConfigSecurity
 //
 // This is the callback function for the "config:security" command.
@@ -770,12 +750,6 @@ int ConfigName(const char *proxy_name);
 int ConfigPortsSet(int arg_ref, void *valuePtr);
 int ConfigPortsGet(int arg_ref);
 
-// config Date sub-command
-int ConfigDate(char *datestr);
-
-// config Time sub-command
-int ConfigTime(char *timestr);
-
 // config Timezone sub-command
 int ConfigTimezone(int, int);