Pseudo-tty as piped to NSTask -- help?
Pseudo-tty as piped to NSTask -- help?
- Subject: Pseudo-tty as piped to NSTask -- help?
- From: Fritz Anderson <email@hidden>
- Date: Thu, 11 Sep 2003 16:46:50 -0500
A job assignment has me writing an application that, at least for the
moment, has me putting a front end on the ssh tool, using the
typed-password authentication method. The ssh tool won't accept a
password unless its stdin stream is a tty.
Assembling the pieces with a Cocoa eye, I have:
(1) ssh as an NSTask, with my application hooked to it through
setStandardInput: and setStandardOutput: .
(2) Because ssh needs a terminal, I use openpty to get a pair of file
descriptors for a master/slave pseudo-TTY pair. I wrap these in
NSFileHandles via initWithFileDescriptor:. I did this a couple of days
ago, and a trip to the Darwin list confirmed that this was the right
tack to take.
(Side note: I discover that a subclass of NSFileHandle can't issue
[super initWithFileDescriptor:closeOnDealloc:] -- the selector isn't
recognized. This was frustrating; I'd hoped to embed the bookkeeping on
the slave terminal in a subclass mostly concerned with the master
terminal's I/O.)
openpty() succeeds. I create an NSFileHandle from the slave descriptor.
I pass the slave NSFileHandle in both the setStandardInput: and
setStandardOutput: messages while setting up the ssh NSTask. My app
does I/O on the NSFileHandle built on the master descriptor, and in
fact characters sent in the master end get echoed back.
MY PROBLEM: What I don't see is the ssh tool recognizing what I've
provided, as a tty device. The password prompt is not sent, the tool
does not pause for a password to be entered, and the password I send
blindly to the tool is not used.
I am terribly naive on UNIX issues, and so I am probably missing
something obvious. Could someone set me straight?
(Would it matter -- I think it should not -- that I did not specify
terminal type or geometry in the openpty() call?)
-- F
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.