From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050319 Description of problem: After updating autofs via ssh, when you log out of ssh the channel is keps open and the session will not dissconnect (requires a ~&) Version-Release number of selected component (if applicable): autofs-4.1.3-130 How reproducible: Always Steps to Reproduce: 1. ssh into machine using autofs 2. rpm -U http://some/path/autofs-4.1.3-130.i386.rpm 3. exit Actual Results: ssh session does not exit. Additional info: This is a long standing issue.
I'll try to reproduce this. Note that I do this sort of thing all of the time, and have not experienced this issue.
This is still a problem when installing U6. After the update, the automount daemon is running with a terminal instead of as a daemon. # ps ax | grep automount 2615 ? S 1:08 /usr/sbin/automount --timeout=5 /misc program /root/miscmount.sh # rpm -U autofs-4.1.3-154.i386.rpm # ps ax | grep automount 1804 pts/0 S 0:00 /usr/sbin/automount --timeout=5 /misc program /root/miscmount.sh
Still a problem in U7 ps -ef show that automount running with a controlling terminal root 23119 1 0 13:48 pts/1 00:00:00 /usr/sbin/automount --timeout=60 /home/students/accounts program /usr After logging out from ssh I have to use ~& to background the connection. Logging back in shows that automount is now running without a terminal root 23119 1 0 13:48 ? 00:00:00 /usr/sbin/automount --timeout=60 /home/students/accounts program /usr
It looks to me like the become_daemon code in autofs should call setsid() to clear the controlling tty. Ian, and particular reason this isn't done?
Ian, nevermind the above. It seems we are keeping some file descriptors open. I know that my daemon-exit-wait patch left one open, I'm pouring through the rest of the code to find other culprits.
(In reply to comment #5) > Ian, nevermind the above. It seems we are keeping some file descriptors open. > I know that my daemon-exit-wait patch left one open, I'm pouring through the > rest of the code to find other culprits. There's patch around for 4.1.4 for that. I didn't notice until it was reported by the Debian folks. Many moons ago we would do a double fork to do this but there's only a single fork in become_daemon. I'll have a look around for the patch. Ian
Created attachment 128769 [details] Change setpgrp to setsid in become_daemon function We should do this as well as hunt for the open file handles. The become_daemon function is not incorrect.
Created attachment 128770 [details] Change setpgrp to setsid in become_daemon function We should do this as well as hunt for the open file handles. The become_daemon function is incorrect.
OK, it turns out that this only happens from upgrading autofs, which points to RPM. RPM doesn't seem to set the close-on-exec bit for the file descriptors it opens, and so those get inherited by automount. I've modified the daemon to close fd's 0-255, and this appears to fix the problem. Note that this is the only change required, though I'll likely include the setsid patch as well. I'll follow up with a patch in a moment. The RPM bug I filed is bz #191196.
Created attachment 128804 [details] Close fd's 0-255 in become_daemon
Given that this particular issue is fixed in an RPM erratum, and given that RHEL 3 is only receiving critical updates, I'm closing this bug. The issue is addressed in RHEL 4.