Skip to contentSkip to conversation

pppd passes plugin fd's onto child processes

PATCH Alan Hourihane 1 participant 1 message May 24, 2004 PPP protocol drivers and compressors

lore
Share & tools
lore
#0 lore raw

Trying to find out why my connection would never re-establish itself and reported 'Address already in use' got me plugging into the pppd code.

I've found a problem with plugins that don't implement the close() function.

When run_program() is called it tries to close the file descriptor down with the code...

	if (the_channel->close)
		(*the_channel->close)();

The problem is, that certainly the pppoatm plugin and from what I can tell the rp-pppoe plugin do not implement this and therefore the child processes inherit these file descriptors.

The patch below does the simplest thing of closing the fd returned by the connect() call, being devfd in pppd's main process.

This fixes the problem, so I thought I'd submit it here.

Hope this helps others,

Alan.

pppd/main.c +3 -0
diff -ur ppp-2.4.2.old/pppd/main.c ppp-2.4.2/pppd/main.c
@@ -1662,8 +1648,11 @@
 
     /* Ensure that nothing of our device environment is inherited. */
     closelog();
+    /* Some plugins dont have a close function, so just close the devfd */
     if (the_channel->close)
 	(*the_channel->close)();
+    else
+	close(devfd);
 
     /* Don't pass handles to the PPP device, even by accident. */
     dup2(fd_devnull, 0);