powerdns pipe backend doesn't close sockets before execing() #194

Closed
Habbie opened this Issue Apr 26, 2013 · 4 comments

Projects

None yet

1 participant

@Habbie
Member
Habbie commented Apr 26, 2013

The pipe backend fails to close() off the sockets that the server had open after forking() to exec the pipe command. The pipe program definitely should not have these file descriptors available to it.

One really nasty side effect is that if the pipe program doesn't (immediately) cleanly exit when you're restarting pdns then it will hold on to the listener socket for port 53 and the server will fail to restart.

@Habbie Habbie was assigned Apr 26, 2013
@Habbie Habbie closed this Apr 26, 2013
@Habbie
Member
Habbie commented Apr 26, 2013

Author: anon
Another nasty side effect is that child programs of the pipe backend inherit eachother's pipes from PowerDNS, and can get in a circular deadlock, failing to exit on PowerDNS shutdown.

The easiest way to fix this is probably to simply close all file descriptors except stdin/stdout between fork() and exec().
-- Mark Bergsma mark@nedworks.org

@Habbie
Member
Habbie commented Apr 26, 2013

Author: anon
or set the FD_CLOEXEC flag on each additional file descriptor that pdns opens

@Habbie
Member
Habbie commented Apr 26, 2013

Author: anon
I was witnessing the same behaviour of the pipe backend with a 3.0-pre DNSSEC test installation where a python coprocess hogged my pdns servers listen IP port 53 after it got respawned by "pdns[25938]: 5045 questions waiting for database attention. Limit is 5000, respawning".

Sten Spans also thinks that O_CLOEXEC should do the trick.

best regards,

Stefan Schmidt

@Habbie
Member
Habbie commented Apr 26, 2013

Author: peter
Fixed in r2273!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment