[tor-bugs] #2029 [Tor Relay]: Set FD_CLOEXEC on all open file descriptors so that they are closed on exec()

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Wed Dec 1 16:02:29 UTC 2010


#2029: Set FD_CLOEXEC on all open file descriptors so that they are closed on
exec()
-----------------------+----------------------------------------------------
 Reporter:  sjmurdoch  |       Owner:  sjmurdoch         
     Type:  defect     |      Status:  needs_review      
 Priority:  normal     |   Milestone:  Tor: 0.2.3.x-final
Component:  Tor Relay  |     Version:                    
 Keywords:             |      Parent:  #1775             
-----------------------+----------------------------------------------------

Comment(by sjmurdoch):

 I made some changes to my branch
 (`cloexec` of git://git.torproject.org/sjm217/tor.git) after experimenting
 on MacOS X by seeing which file descriptors tor-fw-helper has open using
 lsof.

 `786abbd`
 `tor-fw-helper` had an open filehandle to the Tor log file; this patch
 fixes this

 `367794c`
 `tor-fw-helper` had open filehandles to the DNS resolvers; this patch
 fixes this. Note that by using `tor_open_socket()` rather than
 plain `socket()`, the socket accounting code now knows about these
 sockets. Is this a problem?

 `a961521`
 While debugging the issue below, I noted
 that `tor_socketpair()` uses `FD_CLOEXEC` before it is checked. This
 probably isn't an issue, but we check elsewhere so I cleaned this up.

 I hoped that tor-fw-helper now would only have file descriptors 0, 1, and
 2 open, but there is one left: a unix domain socket to
 /var/run/mDNSResponder. I guess this is something created by the MacOS X
 DNS code, and I am not sure how to set CLOEXEC on this file descriptor.

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/2029#comment:9>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list