1

I am trying to run a Ruby daemon using the daemons gem.

It will be started as user 'joe' but needs to change to 'www-data' once it's demonized so that it can access the files it will be working on.

I can see that daemons has change_privilege method for the Application class, but I can't figure out how to use it around this code:

require 'daemons'
Daemons.run(
  File.join(File.dirname(__FILE__), 'worker.rb'),
  {
    :backtrace  => true,
    :log_output => true,
    :dir_mode   => :script,
    :log_dir    => '/tmp',
    :monitor    => true
  }
)
Val
  • 124
  • 1
  • 9
  • just FYI. A process started by user "joe" will not be able to change is userid to "www-data". It will need to be started by the root user. – Doon Apr 26 '11 at 02:58
  • You are correct, joe was just an example :) – Val Apr 26 '11 at 11:58
  • the way I normally handle the above is to either user the OS facility to setuid it in the startup script. or set the effective ID in something like god. – Doon Apr 26 '11 at 12:03

1 Answers1

0

You should not be running as www-data as this is a specific user to apache. You should however add "joe" to your www user group that can access such files.

Mike Lewis
  • 63,433
  • 20
  • 141
  • 111