Re: [PATCH] be paranoid about closed stdin/stdout/stderr
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Aug 27, 2008, 06:35 UTC
- Message-ID
- <48B4F5C4.9020404@viscovery.net>
- In-Reply-To
- <48B44C61.2020206@gnu.org>
Paolo Bonzini schrieb:
Show 14 quoted lines
> Junio C Hamano wrote: >> Johannes Sixt <j.sixt@viscovery.net> writes: >> >>> Paolo Bonzini schrieb: >>>> + /* >>>> + * Always open file descriptors 0/1/2 to avoid clobbering files >>>> + * in die(). It also avoids not messing up when the pipes are >>>> + * dup'ed onto stdin/stdout/stderr in the child processes we spawn. >>>> + */ >>> I see your point, but I don't have an opinion whether this stretch is >>> necessary. >> This is going too far. Have you seen any other sane program that do this? > > Busybox. But it runs setuid, as Steven pointed out.
I straced tee (it was the only tool I found that opens files for writing without also opening some for reading). If one of 0,1,2 is closed, it *does* dup() the fd that it is going to write.
Don't you now feel like Reg in "Life of Brian":
"All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?"
;)
-- Hannes