Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1218#discussion_r87948595
  
    --- Diff: plugins/background_fetch/configs.cc ---
    @@ -44,8 +44,13 @@ BgFetchConfig::readConfig(const char *config_file)
         snprintf(file_path, sizeof(file_path), "%s/%s", TSInstallDirGet(), 
config_file);
         file = TSfopen(file_path, "r");
         if (nullptr == file) {
    -      TSError("[%s] invalid config file", PLUGIN_NAME);
    -      return false;
    +      TSDebug(PLUGIN_NAME, "Failed to open config file %s, trying config 
path", config_file);
    +      snprintf(file_path, sizeof(file_path), "%s/%s", TSConfigDirGet(), 
config_file);
    +      file = TSfopen(file_path, "r");
    +      if (NULL == file) {
    +        TSError("[%s] invalid config file", PLUGIN_NAME);
    +        return false;
    +      }
    --- End diff --
    
    This should be:
    ```C
    if (*config_file == '/') {
       file = TSfopen(config_file, "r");
    } else {
      file = path.join(TSConfigDirGet(), config_file);
    }
    ```
    
    By trying the given path without qualification you allow operators to 
accidentally depend on the current working directory. The pseudocode above is 
what all the other plugins do, and I think that it is worth being consistent 
with this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to