remote_syslog icon indicating copy to clipboard operation
remote_syslog copied to clipboard

Can't seem to use relative path to ssl_server_cert

Open swrobel opened this issue 11 years ago • 5 comments

remote_syslog: #<Errno::ENOENT: No such file or directory @ rb_sysopen - ssl/papertrail.crt

I have the papertrail certificate in my application's code and I'm attempting to access it by giving the relative path to the file. I can't give an absolute path, since my deploy directory depends on the environment, application, etc. Anyway, hardcoding paths sucks. I think it has something to do with this comment regarding Daemonize setting the path to / https://github.com/papertrail/remote_syslog/blob/master/lib/remote_syslog/cli.rb#L171

swrobel avatar Apr 09 '14 22:04 swrobel

I'm actually not 100% sure that a relative path for the key won't work. Is it possible that the working directory remote_syslog was started in - that is, what ssl/ would be relative to - is not the app root (or wherever ssl/ is). Couple ideas for how to identify the working directory:

  • make remote_syslog spit out the directory before it runs this line. A simple way would be to edit tls_endpoint.rb on that system and have it puts Dir.getwd (Dir.getwd), which is that process's working directory.
  • find the script that's starting remote_syslog and have it output the working directory. If this is an init script, it may be /, ~root, or a similar system-related path.
  • as a last resort, try invoking remote_syslog as a user while in the directory containing ssl/ (with the same arguments is used by the init script).

If one or more of those confirm that the wd is the directory containing ssl/, we're into other options:

  • are you able to create a symlink somewhere else in the filesystem, as many deployments scripts do? For example, capistrano creates a current symlink to the current release version.
  • if the provisioning system doesn't support creating a symlink, consider putting the file outside the deploy directory or writing the config file or invocation arguments (which specify the path to the cert) as part of the deployment

troy avatar Apr 09 '14 23:04 troy

I tried your 3rd suggestion, "as a last resort, try invoking remote_syslog as a user while in the directory containing ssl/ (with the same arguments is used by the init script)."

Still get not found even when running it from within the ssl/ dir within my app simply using the following command: bundle exec remote_syslog -c ../config/remote_syslog.yml --dest-port <port> --tls

I also tried adding puts Dir.getwd in the source but it doesn't seem to get output to the command line. It also seemed to me that this was a better place to put it so I tried it there as well - no luck. I've tried adding an additional puts in cli.rb and that comes out, so it isn't that I'm modifying in the wrong gem dir or something.

swrobel avatar Apr 09 '14 23:04 swrobel

I'm out of easy ideas too. I had one question. You mentioned:

Still get not found even when running it from within the ssl/ dir within my app

Were you in the directory containing ssl/ or in the ssl/ directory itself? I'm guessing that it was just wording, but wanted to confirm.

troy avatar Apr 11 '14 18:04 troy

I've tried it from both

swrobel avatar Apr 11 '14 18:04 swrobel

Okay. If you can get it to spit out the wd, it may well be / but there's a chance it'll be something else.

troy avatar Apr 11 '14 18:04 troy