EAGAIN on file when using RNG after daemon fork
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
paramiko |
Confirmed
|
Medium
|
Robey Pointer |
Bug Description
Basically, I ran into this in the construction of a daemon that uses paramiko. I did not have an issue until I made the import of the paramiko module earlier than the fork point. The solution was to move the import into a function after the fork.
Here is the backtrace:
2009-09-16 11:19:25,713 DEBUG [paramiko.
2009-09-16 11:19:25,767 INFO [paramiko.
2009-09-16 11:19:25,768 ERROR [paramiko.
2009-09-16 11:19:25,768 ERROR [paramiko.
2009-09-16 11:19:25,768 ERROR [paramiko.
2009-09-16 11:19:25,768 ERROR [paramiko.
2009-09-16 11:19:25,768 ERROR [paramiko.
2009-09-16 11:19:25,768 ERROR [paramiko.
2009-09-16 11:19:25,769 ERROR [paramiko.
2009-09-16 11:19:25,769 ERROR [paramiko.
2009-09-16 11:19:25,769 ERROR [paramiko.
2009-09-16 11:19:25,769 ERROR [paramiko.
2009-09-16 11:19:25,769 ERROR [paramiko.
2009-09-16 11:19:25,769 ERROR [paramiko.
Looking at the code, we can see that all StrongLockingRa
if ((platform is not None and platform.
# MS Windows
from paramiko import rng_win32
rng_device = rng_win32.
else:
# Assume POSIX (any system where /dev/urandom exists)
from paramiko import rng_posix
rng_device = rng_posix.
It seems this file descriptor would get closed when doing a daemon fork if this module is imported prior to daemonizing (I am using python-daemon). I would argue that each transport should have their own file descriptor to the random number generator. This way, when the Transport is created, which is likely in the context of the daemon, we also control the creation of the file descriptor. The other option is to catch this error and reopen the fd.
Changed in paramiko: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
assignee: | nobody → Robey Pointer (robey) |
Changed in paramiko: | |
status: | Confirmed → Incomplete |
status: | Incomplete → Confirmed |
that might use up file descriptors fast. odd that the error is EAGAIN instead of some error that would indicate the file is closed. i wonder if the kernel is catching that 2 processes have the same pool reference and that's it's passive-aggressive way of saying quit it.
might make sense to catch EAGAIN there and re-open /dev/urandom?