[PATCH] chowning /dev/null should be guarded against

Joel Meador joel at expectedbehavior.com
Tue Oct 2 01:48:05 UTC 2012


Eric Wong wrote:
> Interesting nobody found this bug earlier (I think pointing logs
> to /dev/null is bad :)
Generally agree. Sometimes it happens. :|
> How about this, instead?  This will work in case some weirdo setups
> use a non-standard path for /dev/null, and also allows logging to
> FIFOs (e.g. cronolog users).
>
> diff --git a/lib/unicorn/util.rb b/lib/unicorn/util.rb
> index cde2563..f84241c 100644
> --- a/lib/unicorn/util.rb
> +++ b/lib/unicorn/util.rb
> @@ -7,6 +7,7 @@ def self.is_log?(fp)
>       append_flags = File::WRONLY | File::APPEND
>
>       ! fp.closed?&&
> +      fp.stat.file?&&
>         fp.sync&&
>         (fp.fcntl(Fcntl::F_GETFL)&  append_flags) == append_flags
>       rescue IOError, Errno::EBADF
This looks much better as a general solution to the problem. +1 Thanks, 
Eric!


More information about the mongrel-unicorn mailing list