|
|
@ -217,20 +217,25 @@ bool KPty::setPty(int pty_master)
|
|
|
|
|
|
|
|
|
|
|
|
bool KPty::_attachPty(int pty_master)
|
|
|
|
bool KPty::_attachPty(int pty_master)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQCString ptyName;
|
|
|
|
if (d->slaveFd < 0 ) {
|
|
|
|
|
|
|
|
|
|
|
|
kdDebug(175) << "KPty::_attachPty(): " << pty_master << endl;
|
|
|
|
kdDebug(175) << "KPty::_attachPty(): " << pty_master << endl;
|
|
|
|
#if defined(HAVE_PTSNAME) && defined(HAVE_GRANTPT)
|
|
|
|
#if defined(HAVE_PTSNAME)
|
|
|
|
char *ptsn = ptsname(d->masterFd);
|
|
|
|
char *ptsn = ptsname(d->masterFd);
|
|
|
|
if (ptsn) {
|
|
|
|
if (ptsn) {
|
|
|
|
grantpt(d->masterFd);
|
|
|
|
|
|
|
|
d->ttyName = ptsn;
|
|
|
|
d->ttyName = ptsn;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
::close(d->masterFd);
|
|
|
|
::close(d->masterFd);
|
|
|
|
d->masterFd = -1;
|
|
|
|
d->masterFd = -1;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_GRANTPT)
|
|
|
|
|
|
|
|
if (grantpt(d->masterFd)) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
struct stat st;
|
|
|
|
struct stat st;
|
|
|
|
if (stat(d->ttyName.data(), &st))
|
|
|
|
if (stat(d->ttyName.data(), &st))
|
|
|
|
return false; // this just cannot happen ... *cough* Yeah right, I just
|
|
|
|
return false; // this just cannot happen ... *cough* Yeah right, I just
|
|
|
@ -241,9 +246,10 @@ bool KPty::_attachPty(int pty_master)
|
|
|
|
!chownpty(true))
|
|
|
|
!chownpty(true))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdWarning(175)
|
|
|
|
kdWarning(175)
|
|
|
|
<< "KPty::_attachPty(): " << "chownpty failed for device " << ptyName << "::" << d->ttyName << endl
|
|
|
|
<< "KPty::_attachPty(): " << "chownpty failed for device " << d->ttyName << endl
|
|
|
|
<< "KPty::_attachPty(): " << "This means the communication can be eavesdropped." << endl;
|
|
|
|
<< "KPty::_attachPty(): " << "This means the communication can be eavesdropped." << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef BSD
|
|
|
|
#ifdef BSD
|
|
|
|
revoke(d->ttyName.data());
|
|
|
|
revoke(d->ttyName.data());
|
|
|
@ -261,6 +267,11 @@ bool KPty::_attachPty(int pty_master)
|
|
|
|
d->masterFd = -1;
|
|
|
|
d->masterFd = -1;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENPTY
|
|
|
|
|
|
|
|
// set screen size
|
|
|
|
|
|
|
|
ioctl(d->slaveFd, TIOCSWINSZ, (char *)&d->winSize);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if (defined(__svr4__) || defined(__sgi__))
|
|
|
|
#if (defined(__svr4__) || defined(__sgi__))
|
|
|
|
// Solaris
|
|
|
|
// Solaris
|
|
|
@ -294,8 +305,10 @@ bool KPty::_attachPty(int pty_master)
|
|
|
|
|
|
|
|
|
|
|
|
_tcsetattr(d->slaveFd, &ttmode);
|
|
|
|
_tcsetattr(d->slaveFd, &ttmode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef HAVE_OPENPTY
|
|
|
|
// set screen size
|
|
|
|
// set screen size
|
|
|
|
ioctl(d->slaveFd, TIOCSWINSZ, (char *)&d->winSize);
|
|
|
|
ioctl(d->slaveFd, TIOCSWINSZ, (char *)&d->winSize);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
fcntl(d->masterFd, F_SETFD, FD_CLOEXEC);
|
|
|
|
fcntl(d->masterFd, F_SETFD, FD_CLOEXEC);
|
|
|
|
fcntl(d->slaveFd, F_SETFD, FD_CLOEXEC);
|
|
|
|
fcntl(d->slaveFd, F_SETFD, FD_CLOEXEC);
|
|
|
|