Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Kevin Smith
RE: $SAFE and tainting? [ reply ]  
2008-12-03 13:43
I found a "solution" and wanted to post it to help anyone else facing a similar problem. I moved my $SAFE=1 inside the daemon start block. So Daemons.run_proc runs in dangerous mode, but all of my own code is safe.

In a perfect world, Daemons would be compatible with safe mode 1, but this is good enough for now.

By: Kevin Smith
$SAFE and tainting? [ reply ]  
2008-12-03 03:24
I'm trying to get my app to work as a daemon, but my app runs $SAFE=1. I finally figured out that I had to specify :dir_mode=>:system to avoid a taint error on startup.

Now I'm getting a taint error on exit which looks harder. The code in pidfile.find_files gets a list of potential pid files, and calls File? for each. But the filenames are tainted, as shown here:

irb(main):006:0> a = Dir['*']
=> ["ReferenceImplementations", "test", "COPYING", "README", "maildiode.conf.sample", "Rakefile", "lib", "pkg", "bin", "maildiode.log", "doc"]
irb(main):008:0> a[0].tainted?
=> true

Given that daemons are especially important to run in SAFE mode, it seems like the daemons gem should support/encourage doing so. Any chances of a quick but safe fix to allow me (and others) to remain SAFE?