Merge branch 'jennifer/march2016-patches'
authorJennifer Richards <jennifer@painless-security.com>
Mon, 20 Jun 2016 17:39:31 +0000 (13:39 -0400)
committerJennifer Richards <jennifer@painless-security.com>
Mon, 20 Jun 2016 17:39:31 +0000 (13:39 -0400)
Conflicts (both trivial):
common/tr_config.c
common/tr_name.c

1  2 
common/tr_config.c
common/tr_name.c
include/tr_config.h
tr/tr_main.c

@@@ -866,19 -908,12 +908,20 @@@ TR_CFG_RC tr_cfg_validate (TR_CFG *trc
    return rc;
  }
  
 -TR_CFG_RC tr_parse_config (TR_INSTANCE *tr, int n, struct dirent **cfg_files) {
 +/* Join two paths and return a pointer to the result. This should be freed
 + * via talloc_free. Returns NULL on failure. */
 +static char *join_paths(const char *p1, const char *p2) {
 +  return talloc_asprintf(NULL, "%s/%s", p1, p2); /* returns NULL on a failure */
 +}
 +
 +/* Reads configuration files in config_dir ("" or "./" will use the current directory) */
 +TR_CFG_RC tr_parse_config (TR_INSTANCE *tr, const char *config_dir, int n, struct dirent **cfg_files) {
    json_t *jcfg;
+   json_t *jser;
    json_error_t rc;
 +  char *file_with_path;
  
 -  if ((!tr) || (!cfg_files))
 +  if ((!tr) || (!cfg_files) || (n<=0))
      return TR_CFG_BAD_PARAMS;
  
    /* If there is a partial/abandoned config lying around, free it */
  
    /* Parse configuration information from each config file */
    while (n--) {
 -    tr_debug("tr_read_config: Parsing %s.", cfg_files[n]->d_name);
 -    if (NULL == (jcfg = json_load_file(cfg_files[n]->d_name, 
 -                                     JSON_DISABLE_EOF_CHECK, &rc))) {
 -      tr_debug("tr_read_config: Error parsing config file %s.", 
 -             cfg_files[n]->d_name);
 +    file_with_path=join_paths(config_dir, cfg_files[n]->d_name); /* must free result with talloc_free */
 +    if(file_with_path == NULL) {
 +      tr_crit("tr_parse_config: error joining path.");
 +      return TR_CFG_NOMEM;
 +    }
 +    tr_debug("tr_parse_config: Parsing %s.", cfg_files[n]->d_name); /* print the filename without the path */
 +    if (NULL == (jcfg = json_load_file(file_with_path, 
 +                                       JSON_DISABLE_EOF_CHECK, &rc))) {
 +      tr_debug("tr_parse_config: Error parsing config file %s.", 
 +               cfg_files[n]->d_name);
 +      talloc_free(file_with_path);
        return TR_CFG_NOPARSE;
      }
 +    talloc_free(file_with_path); /* done with filename */
  
+     // Look for serial number and log it if it exists
+     if (NULL != (jser = json_object_get(jcfg, "serial_number"))) {
+       if (json_is_number(jser)) {
+         tr_notice("tr_read_config: Attempting to load revision %i of %s.",
+                   (int *) json_integer_value(jser),
+                   cfg_files[n]->d_name);
+       }
+     }
      if ((TR_CFG_SUCCESS != tr_cfg_parse_internal(tr->new_cfg, jcfg)) ||
 -      (TR_CFG_SUCCESS != tr_cfg_parse_rp_clients(tr->new_cfg, jcfg)) ||
 -      (TR_CFG_SUCCESS != tr_cfg_parse_idp_realms(tr->new_cfg, jcfg)) ||
 -      (TR_CFG_SUCCESS != tr_cfg_parse_default_servers(tr->new_cfg, jcfg)) ||
 -      (TR_CFG_SUCCESS != tr_cfg_parse_comms(tr->new_cfg, jcfg))) {
 +        (TR_CFG_SUCCESS != tr_cfg_parse_rp_clients(tr->new_cfg, jcfg)) ||
 +        (TR_CFG_SUCCESS != tr_cfg_parse_idp_realms(tr->new_cfg, jcfg)) ||
 +        (TR_CFG_SUCCESS != tr_cfg_parse_default_servers(tr->new_cfg, jcfg)) ||
 +        (TR_CFG_SUCCESS != tr_cfg_parse_comms(tr->new_cfg, jcfg))) {
        tr_cfg_free(tr->new_cfg);
        return TR_CFG_ERROR;
      }
Simple merge
Simple merge
diff --cc tr/tr_main.c
Simple merge