sudo closing file descriptors

Vaclav Dvorak dvorakv at idas.cz
Tue Jul 29 17:59:51 EDT 2003


Hello folks,

It seems that sudo closes any open file descriptors before running the 
specified program. A posting at 
http://www.geocrawler.com/archives/3/515/2001/12/0/7388518/ confirms this.

I was trying to make a program that starts as normal user, creates a 
pair of pipes using pipe(2), then forks, passes the file descriptors in 
the environment and runs the second half of the program as root, using 
sudo. The two parts of the program were supposed to communicate through 
the pipes. I had my program perfectly working without sudo, but when I 
inserted sudo, the pipes got broken. :-(

I didn't find any documentation on this. Is it intentional? If yes, why? 
Is there an option to turn this off? If not, could it be made so? :-) I 
suppose I could do the patch - I haven't even seen the source code yet, 
but I suppose this shouldn't be too difficult. The question is, would 
such a patch be accepted?

Is there an obvious(ly) better way to do what I'm trying to do?

Thanks!

Vaclav Dvorak




More information about the sudo-users mailing list