----- Original Message -----
> Updated Branches:
>   refs/heads/master 0f171d335 -> bb275c046
> 
> 
> TS-1184 Additional whitespace in proxy.config.admin.user_id value
> results in error
[snip]
> ----------------------------------------------------------------------
>  CHANGES                 |    3 +++
>  cop/TrafficCop.cc       |   30 +++++++++++++++++++-----------
>  lib/records/RecUtils.cc |   10 +++++++++-
>  proxy/Main.cc           |   12 +++++-------
>  4 files changed, 36 insertions(+), 19 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb275c04/CHANGES
> ----------------------------------------------------------------------
> diff --git a/CHANGES b/CHANGES
> index 8466cb9..c7d8de1 100644
> --- a/CHANGES
> +++ b/CHANGES
> @@ -2,6 +2,9 @@
>    Changes with Apache Traffic Server 3.3.3
>  
>  
> +  *) TS-1184 Additional whitespace in proxy.config.admin.user_id
> value results
> +   in error.
> +
>    *) [TS-1662] Remove remaining use of register storage class.
>  
>    *) [TS-846] Eliminate proxy.config.remap.use_remap_processor.
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb275c04/cop/TrafficCop.cc
> ----------------------------------------------------------------------
> diff --git a/cop/TrafficCop.cc b/cop/TrafficCop.cc
> index f2f047b..dff3f17 100644
> --- a/cop/TrafficCop.cc
> +++ b/cop/TrafficCop.cc
> @@ -46,6 +46,8 @@ union semun
>  // For debugging, turn this on.
>  // #define TRACE_LOG_COP 1
>  
> +static const long MAX_LOGIN =  sysconf(_SC_LOGIN_NAME_MAX) <= 0 ? 
> _POSIX_LOGIN_NAME_MAX :  sysconf(_SC_LOGIN_NAME_MAX);
> +
>  #define OPTIONS_MAX     32
>  #define OPTIONS_LEN_MAX 1024
>  
> @@ -75,7 +77,7 @@ static char syslog_fac_str[PATH_NAME_MAX] =
> "LOG_DAEMON";
>  static int killsig = SIGKILL;
>  static int coresig = 0;
>  
> -static char admin_user[256];
> +static char* admin_user;
>  static uid_t admin_uid;
>  static gid_t admin_gid;
>  static bool admin_user_p = false;
> @@ -202,12 +204,8 @@ void
>  chown_file_to_admin_user(const char *file) {
>    if (admin_user_p) {
>      if (chown(file, admin_uid, admin_gid) < 0) {
> -      cop_log(
> -        COP_FATAL,
> -        "cop couldn't chown the file: '%s' for '%s' (%d/%d) : [%d] %s\n",
> -        file, admin_user, admin_uid, admin_gid,
> -        errno, strerror(errno)
> -      );
> +      cop_log(COP_FATAL, "cop couldn't chown the file: '%s' for '%s' (%d/%d) 
> : [%d] %s\n",
> +              file, admin_user, admin_uid, admin_gid, errno, 
> strerror(errno));
>      }
>    }
>  }
> @@ -600,13 +598,24 @@ ConfigIntFatalError:
>  }
>  
>  
> -bool
> -get_admin_user() {
> +void
> +get_admin_user()
> +{
>    struct passwd *pwd = NULL;
>  
> -  read_config_string("proxy.config.admin.user_id", admin_user,
> sizeof(admin_user));
> +  if (!admin_user)
> +    admin_user = (char *)ats_malloc(MAX_LOGIN);
> +
> +  read_config_string("proxy.config.admin.user_id", admin_user, MAX_LOGIN);
>  
>    if (*admin_user) {
> +    char *end = admin_user + strlen(admin_user) - 1;
> +
> +    // Trim trailing spaces.
> +    while (end >= admin_user && isspace(*end))
> +      end--;
> +    *(end + 1) = '\0';
> +
>      if (*admin_user == '#') {
>        int uid = atoi(admin_user + 1);
>        if (uid == -1) {
> @@ -627,7 +636,6 @@ get_admin_user() {
>        exit(1);
>      }
>    }
> -  return admin_user_p;
>  }
>  
>  static void
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb275c04/lib/records/RecUtils.cc
> ----------------------------------------------------------------------
> diff --git a/lib/records/RecUtils.cc b/lib/records/RecUtils.cc
> index a3d47cd..d04fce7 100644
> --- a/lib/records/RecUtils.cc
> +++ b/lib/records/RecUtils.cc
> @@ -129,9 +129,17 @@ RecDataSet(RecDataT data_type, RecData *
> data_dst, RecData * data_src)
>        }
>      } else if (((data_dst->rec_string) &&
>      (strcmp(data_dst->rec_string, data_src->rec_string) != 0)) ||
>                 ((data_dst->rec_string == NULL) &&
>                 (data_src->rec_string != NULL))) {
> -      if (data_dst->rec_string) ats_free(data_dst->rec_string);
> +      if (data_dst->rec_string)
> +        ats_free(data_dst->rec_string);
> +
>        data_dst->rec_string = ats_strdup(data_src->rec_string);
>        rec_set = true;
> +      // Chop trailing spaces
> +      char *end = data_dst->rec_string + strlen(data_dst->rec_string) - 1;
> +
> +      while (end >= data_dst->rec_string && isspace(*end))
> +        end--;
> +      *(end + 1) = '\0';
>      }
>      break;
>    case RECD_INT:
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb275c04/proxy/Main.cc
> ----------------------------------------------------------------------
> diff --git a/proxy/Main.cc b/proxy/Main.cc
> index 78e1fe6..c9da002 100644
> --- a/proxy/Main.cc
> +++ b/proxy/Main.cc
> @@ -113,6 +113,8 @@ extern "C" int plock(int);
>  
>  #define DEFAULT_REMOTE_MANAGEMENT_FLAG    0
>  
> +static const long MAX_LOGIN =  sysconf(_SC_LOGIN_NAME_MAX) <= 0 ? 
> _POSIX_LOGIN_NAME_MAX :  sysconf(_SC_LOGIN_NAME_MAX);
> +
>  static void * mgmt_restart_shutdown_callback(void *, char *, int
>  data_len);
>  
>  static int version_flag = DEFAULT_VERSION_FLAG;
> @@ -1422,15 +1424,11 @@ main(int argc, char **argv)
>    if (!num_task_threads)
>      TS_ReadConfigInteger(num_task_threads,
>      "proxy.config.task_threads");
>  
> -  const long max_login =  sysconf(_SC_LOGIN_NAME_MAX) <= 0 ? 
> _POSIX_LOGIN_NAME_MAX :  sysconf(_SC_LOGIN_NAME_MAX);
> -  char *user = (char *)ats_malloc(max_login);
> +  char *user = (char *)ats_malloc(MAX_LOGIN);
>  
>    *user = '\0';
> -  admin_user_p =
> -    (REC_ERR_OKAY ==
> -      TS_ReadConfigString(user, "proxy.config.admin.user_id",
> max_login)
> -    ) && user[0] != '\0' && 0 != strcmp(user, "#-1")
> -    ;
> +  admin_user_p = ((REC_ERR_OKAY == TS_ReadConfigString(user, 
> "proxy.config.admin.user_id", MAX_LOGIN)) &&
> +                  (*user != '\0') && (0 != strcmp(user, "#-1")));
>  
>  # if TS_USE_POSIX_CAP
>    // Change the user of the process.
> 

Is it necessary that we duplicate the code between traffic_cop and 
traffic_server?

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.ga...@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE

Reply via email to