Bug 947213 - Rlogind broken by recent changes to /bin/login (pty loses packet mode)
Summary: Rlogind broken by recent changes to /bin/login (pty loses packet mode)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: rsh
Version: 18
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Michal Sekletar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-04-01 20:18 UTC by Philip Spencer
Modified: 2013-04-30 04:34 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-04-30 04:34:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch to make rlogind work again by keeping slave file descriptor open (1.74 KB, patch)
2013-04-01 20:18 UTC, Philip Spencer
no flags Details | Diff

Description Philip Spencer 2013-04-01 20:18:45 UTC
Created attachment 730431 [details]
Patch to make rlogind work again by keeping slave file descriptor open

Fedora 18, rsh-server-0.17-69.fc18

When rlogind is enabled, attempts to rlogin will result in one of two things happening (which one happens appears to be random):

Either the connection gets closed right away ("rlogin: connection closed"),
or the shell is invoked and receives keystrokes but nothing is echoed back (so no prompt or command output appears, making the rlogin process appear to be hung).

The cause is a change that was made to /bin/login in the util-linux package, as described in lkml.org/lkml/2012/6/5/145

Rlogind has the following code:

---------------------
pid = forkpty(&master, line, NULL, &win);
...
if (pid == 0) { 
   ...
   child(hname, termtype, lusername, authenticated, rusername);
}
ioctl(netfd, FIONBIO, &on);
ioctl(master, FIONBIO, &on);
ioctl(master, TIOCPKT, &on);
----------------------

forkpty allocates a pty pair, but the slave end is open only in the child process, which calls "child(...)" which in turn execs /bin/login.

/bin/login now closes all its file descriptors before doing a vhangup on the tty (it used to do the close only after the vhangup). Apparently, doing this on the slave end of a pty will RESET the packet mode that the parent set by ioctl(master, TIOCPKT, &on), and as a result the pty pair no longer operates in packet mode, making it unusable by rlogind.

(To test: insert a small sleep into the parent's code before ioctl(master, TIOCPKT, &on), enough to delay the call until after the child has done the vhangup (usleep(100000) is sufficient on our system) and then rlogind works just fine).

The attached patch fixes the issue by splitting the call to forkpty into separate calls to openpty, fork, and login_tty, thereby enabling the parent to keep a file descriptor to the slave pty open, so that packet mode does not get reset.

Comment 1 Fedora Admin XMLRPC Client 2013-04-02 13:25:16 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 2 Fedora Update System 2013-04-15 13:45:56 UTC
rsh-0.17-71.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/rsh-0.17-71.fc19

Comment 3 Fedora Update System 2013-04-15 16:20:29 UTC
Package rsh-0.17-71.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing rsh-0.17-71.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-5708/rsh-0.17-71.fc19
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2013-04-30 04:34:31 UTC
rsh-0.17-71.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.