Created attachment 333884 [details] Proposed patch Description of problem: telnetd does not create an appropriate entry in utmp file before spawning login. As a result, it leaves empty entries in the utmp file that get never reused. Version-Release number of selected component (if applicable): telnet-server-0.17-39.el5.i386.rpm How reproducible: 100% reprducible Steps to Reproduce: 1. open several login with telnet 2. close 3. reopen new connections Actual results: => An new entry is added instead of reusing the previous emptied one. 1. On a testsystem, empty the utmp log entirely (not required, but easier to read) # > /var/run/utmp # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp 2. Login from telnet # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [7] [28326] [5 ] [ofourdan] [pts/5 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:36 2009 BST] 3. Again # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [7] [28326] [5 ] [ofourdan] [pts/5 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:36 2009 BST] [7] [28363] [6 ] [ofourdan] [pts/6 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:48 2009 BST] 4. And again # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [7] [28326] [5 ] [ofourdan] [pts/5 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:36 2009 BST] [7] [28363] [6 ] [ofourdan] [pts/6 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:48 2009 BST] [7] [28400] [8 ] [ofourdan] [pts/8 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:56 2009 BST] 5. Close first connection # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [7] [28326] [5 ] [ofourdan] [pts/5 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:36 2009 BST] [8] [28363] [6 ] [ ] [pts/6 ] [ ] [127.0.0.1 ] [Tue Mar 03 19:47:04 2009 BST] [7] [28400] [8 ] [ofourdan] [pts/8 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:56 2009 BST] 6. Relogin # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [7] [28326] [5 ] [ofourdan] [pts/5 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:36 2009 BST] [8] [28363] [6 ] [ ] [pts/6 ] [ ] [127.0.0.1 ] [Tue Mar 03 19:47:04 2009 BST] [7] [28400] [8 ] [ofourdan] [pts/8 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:46:56 2009 BST] [7] [28440] [6 ] [ofourdan] [pts/6 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:47:12 2009 BST] Expected results: The empty entries get reused. 1. On a testsystem, empty the utmp log entirely (not required, but easier to read) # > /var/run/utmp # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp 2. Login from telnet # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [7] [28550] [8 ] [ofourdan] [pts/8 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:48:54 2009 BST] 3. Again # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [7] [28550] [8 ] [ofourdan] [pts/8 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:48:54 2009 BST] [7] [28587] [9 ] [ofourdan] [pts/9 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:49:13 2009 BST] 4. And again # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [7] [28550] [8 ] [ofourdan] [pts/8 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:48:54 2009 BST] [7] [28587] [9 ] [ofourdan] [pts/9 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:49:13 2009 BST] [7] [28624] [10 ] [ofourdan] [pts/10 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:49:23 2009 BST] 5. Close first connection # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [8] [28550] [8 ] [ ] [pts/8 ] [ ] [127.0.0.1 ] [Tue Mar 03 19:49:33 2009 BST] [7] [28587] [9 ] [ofourdan] [pts/9 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:49:13 2009 BST] [7] [28624] [10 ] [ofourdan] [pts/10 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:49:23 2009 BST] 6. Relogin # utmpdump /var/run/utmp | tail -10 Utmp dump of /var/run/utmp [7] [28664] [8 ] [ofourdan] [pts/8 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:49:43 2009 BST] [7] [28587] [9 ] [ofourdan] [pts/9 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:49:13 2009 BST] [7] [28624] [10 ] [ofourdan] [pts/10 ] [localhost.localdomain] [127.0.0.1 ] [Tue Mar 03 19:49:23 2009 BST] Additional info: Other daemons (agetty, sshd) prepare an appropriate entry in utmp for login to pick up, but telnetd doesn't. As a result, login itself will add a new entry inutmp each time a telnet connection is initiated. The proposed patch adds this missing bit to telnetd so that no "hole" is created in utmp when using telnet. Please note that the problem is present in upstream code also.
I haven't tested patch yet but it looks fine. Thanks.