KPty
kpty.cpp
Go to the documentation of this file.
00001 /* 00002 00003 This file is part of the KDE libraries 00004 Copyright (C) 2002 Waldo Bastian <bastian@kde.org> 00005 Copyright (C) 2002-2003,2007-2008 Oswald Buddenhagen <ossi@kde.org> 00006 Copyright (C) 2010 KDE e.V. <kde-ev-board@kde.org> 00007 Author Adriaan de Groot <groot@kde.org> 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Library General Public 00011 License as published by the Free Software Foundation; either 00012 version 2 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Library General Public License for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with this library; see the file COPYING.LIB. If not, write to 00021 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00022 Boston, MA 02110-1301, USA. 00023 */ 00024 00025 #include "kpty_p.h" 00026 00027 #include <config.h> 00028 00029 #ifdef __sgi 00030 #define __svr4__ 00031 #endif 00032 00033 #ifdef __osf__ 00034 #define _OSF_SOURCE 00035 #include <float.h> 00036 #endif 00037 00038 #ifdef _AIX 00039 #define _ALL_SOURCE 00040 #endif 00041 00042 // __USE_XOPEN isn't defined by default in ICC 00043 // (needed for ptsname(), grantpt() and unlockpt()) 00044 #ifdef __INTEL_COMPILER 00045 # ifndef __USE_XOPEN 00046 # define __USE_XOPEN 00047 # endif 00048 #endif 00049 00050 #include <sys/types.h> 00051 #include <sys/ioctl.h> 00052 #include <sys/time.h> 00053 #include <sys/resource.h> 00054 #include <sys/stat.h> 00055 #include <sys/param.h> 00056 00057 #include <errno.h> 00058 #include <fcntl.h> 00059 #include <time.h> 00060 #include <stdlib.h> 00061 #include <stdio.h> 00062 #include <string.h> 00063 #include <unistd.h> 00064 #include <grp.h> 00065 00066 #if defined(HAVE_PTY_H) 00067 # include <pty.h> 00068 #endif 00069 00070 #ifdef HAVE_LIBUTIL_H 00071 # include <libutil.h> 00072 #elif defined(HAVE_UTIL_H) 00073 # include <util.h> 00074 #endif 00075 00076 #ifdef HAVE_UTEMPTER 00077 extern "C" { 00078 # include <utempter.h> 00079 } 00080 #else 00081 # include <utmp.h> 00082 # ifdef HAVE_UTMPX 00083 # include <utmpx.h> 00084 # endif 00085 # if !defined(_PATH_UTMPX) && defined(_UTMPX_FILE) 00086 # define _PATH_UTMPX _UTMPX_FILE 00087 # endif 00088 # if !defined(_PATH_WTMPX) && defined(_WTMPX_FILE) 00089 # define _PATH_WTMPX _WTMPX_FILE 00090 # endif 00091 #endif 00092 00093 /* for HP-UX (some versions) the extern C is needed, and for other 00094 platforms it doesn't hurt */ 00095 extern "C" { 00096 #include <termios.h> 00097 #if defined(HAVE_TERMIO_H) 00098 # include <termio.h> // struct winsize on some systems 00099 #endif 00100 } 00101 00102 #if defined (_HPUX_SOURCE) 00103 # define _TERMIOS_INCLUDED 00104 # include <bsdtty.h> 00105 #endif 00106 00107 #ifdef HAVE_SYS_STROPTS_H 00108 # include <sys/stropts.h> // Defines I_PUSH 00109 # define _NEW_TTY_CTRL 00110 #endif 00111 00112 #if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__bsdi__) || defined(__APPLE__) || defined (__DragonFly__) 00113 # define _tcgetattr(fd, ttmode) ioctl(fd, TIOCGETA, (char *)ttmode) 00114 #else 00115 # if defined(_HPUX_SOURCE) || defined(__Lynx__) || defined (__CYGWIN__) || defined(__sun) 00116 # define _tcgetattr(fd, ttmode) tcgetattr(fd, ttmode) 00117 # else 00118 # define _tcgetattr(fd, ttmode) ioctl(fd, TCGETS, (char *)ttmode) 00119 # endif 00120 #endif 00121 00122 #if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__bsdi__) || defined(__APPLE__) || defined (__DragonFly__) 00123 # define _tcsetattr(fd, ttmode) ioctl(fd, TIOCSETA, (char *)ttmode) 00124 #else 00125 # if defined(_HPUX_SOURCE) || defined(__CYGWIN__) || defined(__sun) 00126 # define _tcsetattr(fd, ttmode) tcsetattr(fd, TCSANOW, ttmode) 00127 # else 00128 # define _tcsetattr(fd, ttmode) ioctl(fd, TCSETS, (char *)ttmode) 00129 # endif 00130 #endif 00131 00132 #include <kdebug.h> 00133 #include <kstandarddirs.h> // findExe 00134 #include <kde_file.h> 00135 00136 #include <QtCore/Q_PID> 00137 00138 #define TTY_GROUP "tty" 00139 00140 #ifndef PATH_MAX 00141 # ifdef MAXPATHLEN 00142 # define PATH_MAX MAXPATHLEN 00143 # else 00144 # define PATH_MAX 1024 00145 # endif 00146 #endif 00147 00149 // private functions // 00151 00153 // private data // 00155 00156 KPtyPrivate::KPtyPrivate(KPty* parent) : 00157 masterFd(-1), slaveFd(-1), ownMaster(true), q_ptr(parent) 00158 { 00159 } 00160 00161 KPtyPrivate::~KPtyPrivate() 00162 { 00163 } 00164 00165 #ifndef HAVE_OPENPTY 00166 bool KPtyPrivate::chownpty(bool grant) 00167 { 00168 return !QProcess::execute(KStandardDirs::findExe("kgrantpty"), 00169 QStringList() << (grant?"--grant":"--revoke") << QString::number(masterFd)); 00170 } 00171 #endif 00172 00174 // public member functions // 00176 00177 KPty::KPty() : 00178 d_ptr(new KPtyPrivate(this)) 00179 { 00180 } 00181 00182 KPty::KPty(KPtyPrivate *d) : 00183 d_ptr(d) 00184 { 00185 d_ptr->q_ptr = this; 00186 } 00187 00188 KPty::~KPty() 00189 { 00190 close(); 00191 delete d_ptr; 00192 } 00193 00194 bool KPty::open() 00195 { 00196 Q_D(KPty); 00197 00198 if (d->masterFd >= 0) 00199 return true; 00200 00201 d->ownMaster = true; 00202 00203 QByteArray ptyName; 00204 00205 // Find a master pty that we can open //////////////////////////////// 00206 00207 // Because not all the pty animals are created equal, they want to 00208 // be opened by several different methods. 00209 00210 // We try, as we know them, one by one. 00211 00212 #ifdef HAVE_OPENPTY 00213 00214 char ptsn[PATH_MAX]; 00215 if (::openpty( &d->masterFd, &d->slaveFd, ptsn, 0, 0)) 00216 { 00217 d->masterFd = -1; 00218 d->slaveFd = -1; 00219 kWarning(175) << "Can't open a pseudo teletype"; 00220 return false; 00221 } 00222 d->ttyName = ptsn; 00223 00224 #else 00225 00226 #ifdef HAVE__GETPTY // irix 00227 00228 char *ptsn = _getpty(&d->masterFd, O_RDWR|O_NOCTTY, S_IRUSR|S_IWUSR, 0); 00229 if (ptsn) { 00230 d->ttyName = ptsn; 00231 goto grantedpt; 00232 } 00233 00234 #elif defined(HAVE_PTSNAME) || defined(TIOCGPTN) 00235 00236 #ifdef HAVE_POSIX_OPENPT 00237 d->masterFd = ::posix_openpt(O_RDWR|O_NOCTTY); 00238 #elif defined(HAVE_GETPT) 00239 d->masterFd = ::getpt(); 00240 #elif defined(PTM_DEVICE) 00241 d->masterFd = KDE_open(PTM_DEVICE, O_RDWR|O_NOCTTY); 00242 #else 00243 # error No method to open a PTY master detected. 00244 #endif 00245 if (d->masterFd >= 0) 00246 { 00247 #ifdef HAVE_PTSNAME 00248 char *ptsn = ptsname(d->masterFd); 00249 if (ptsn) { 00250 d->ttyName = ptsn; 00251 #else 00252 int ptyno; 00253 if (!ioctl(d->masterFd, TIOCGPTN, &ptyno)) { 00254 char buf[32]; 00255 sprintf(buf, "/dev/pts/%d", ptyno); 00256 d->ttyName = buf; 00257 #endif 00258 #ifdef HAVE_GRANTPT 00259 if (!grantpt(d->masterFd)) 00260 goto grantedpt; 00261 #else 00262 goto gotpty; 00263 #endif 00264 } 00265 ::close(d->masterFd); 00266 d->masterFd = -1; 00267 } 00268 #endif // HAVE_PTSNAME || TIOCGPTN 00269 00270 // Linux device names, FIXME: Trouble on other systems? 00271 for (const char* s3 = "pqrstuvwxyzabcde"; *s3; s3++) 00272 { 00273 for (const char* s4 = "0123456789abcdef"; *s4; s4++) 00274 { 00275 ptyName = QString().sprintf("/dev/pty%c%c", *s3, *s4).toAscii(); 00276 d->ttyName = QString().sprintf("/dev/tty%c%c", *s3, *s4).toAscii(); 00277 00278 d->masterFd = KDE_open(ptyName.data(), O_RDWR); 00279 if (d->masterFd >= 0) 00280 { 00281 #ifdef Q_OS_SOLARIS 00282 /* Need to check the process group of the pty. 00283 * If it exists, then the slave pty is in use, 00284 * and we need to get another one. 00285 */ 00286 int pgrp_rtn; 00287 if (ioctl(d->masterFd, TIOCGPGRP, &pgrp_rtn) == 0 || errno != EIO) { 00288 ::close(d->masterFd); 00289 d->masterFd = -1; 00290 continue; 00291 } 00292 #endif /* Q_OS_SOLARIS */ 00293 if (!access(d->ttyName.data(),R_OK|W_OK)) // checks availability based on permission bits 00294 { 00295 if (!geteuid()) 00296 { 00297 struct group* p = getgrnam(TTY_GROUP); 00298 if (!p) 00299 p = getgrnam("wheel"); 00300 gid_t gid = p ? p->gr_gid : getgid (); 00301 00302 chown(d->ttyName.data(), getuid(), gid); 00303 chmod(d->ttyName.data(), S_IRUSR|S_IWUSR|S_IWGRP); 00304 } 00305 goto gotpty; 00306 } 00307 ::close(d->masterFd); 00308 d->masterFd = -1; 00309 } 00310 } 00311 } 00312 00313 kWarning(175) << "Can't open a pseudo teletype"; 00314 return false; 00315 00316 gotpty: 00317 KDE_struct_stat st; 00318 if (KDE_stat(d->ttyName.data(), &st)) 00319 return false; // this just cannot happen ... *cough* Yeah right, I just 00320 // had it happen when pty #349 was allocated. I guess 00321 // there was some sort of leak? I only had a few open. 00322 if (((st.st_uid != getuid()) || 00323 (st.st_mode & (S_IRGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH))) && 00324 !d->chownpty(true)) 00325 { 00326 kWarning(175) 00327 << "chownpty failed for device " << ptyName << "::" << d->ttyName 00328 << "\nThis means the communication can be eavesdropped." << endl; 00329 } 00330 00331 grantedpt: 00332 00333 #ifdef HAVE_REVOKE 00334 revoke(d->ttyName.data()); 00335 #endif 00336 00337 #ifdef HAVE_UNLOCKPT 00338 unlockpt(d->masterFd); 00339 #elif defined(TIOCSPTLCK) 00340 int flag = 0; 00341 ioctl(d->masterFd, TIOCSPTLCK, &flag); 00342 #endif 00343 00344 d->slaveFd = KDE_open(d->ttyName.data(), O_RDWR | O_NOCTTY); 00345 if (d->slaveFd < 0) 00346 { 00347 kWarning(175) << "Can't open slave pseudo teletype"; 00348 ::close(d->masterFd); 00349 d->masterFd = -1; 00350 return false; 00351 } 00352 00353 #if (defined(__svr4__) || defined(__sgi__) || defined(Q_OS_SOLARIS)) 00354 // Solaris uses STREAMS for terminal handling. It is possible 00355 // for the pty handling modules to be left off the stream; in that 00356 // case push them on. ioctl(fd, I_FIND, ...) is documented to return 00357 // 1 if the module is on the stream already. 00358 { 00359 static const char *pt = "ptem"; 00360 static const char *ld = "ldterm"; 00361 if (ioctl(d->slaveFd, I_FIND, pt) == 0) 00362 ioctl(d->slaveFd, I_PUSH, pt); 00363 if (ioctl(d->slaveFd, I_FIND, ld) == 0) 00364 ioctl(d->slaveFd, I_PUSH, ld); 00365 } 00366 #endif 00367 00368 #endif /* HAVE_OPENPTY */ 00369 00370 fcntl(d->masterFd, F_SETFD, FD_CLOEXEC); 00371 fcntl(d->slaveFd, F_SETFD, FD_CLOEXEC); 00372 00373 return true; 00374 } 00375 00376 bool KPty::open(int fd) 00377 { 00378 #if !defined(HAVE_PTSNAME) && !defined(TIOCGPTN) 00379 kWarning(175) << "Unsupported attempt to open pty with fd" << fd; 00380 return false; 00381 #else 00382 Q_D(KPty); 00383 00384 if (d->masterFd >= 0) { 00385 kWarning(175) << "Attempting to open an already open pty"; 00386 return false; 00387 } 00388 00389 d->ownMaster = false; 00390 00391 # ifdef HAVE_PTSNAME 00392 char *ptsn = ptsname(fd); 00393 if (ptsn) { 00394 d->ttyName = ptsn; 00395 # else 00396 int ptyno; 00397 if (!ioctl(fd, TIOCGPTN, &ptyno)) { 00398 char buf[32]; 00399 sprintf(buf, "/dev/pts/%d", ptyno); 00400 d->ttyName = buf; 00401 # endif 00402 } else { 00403 kWarning(175) << "Failed to determine pty slave device for fd" << fd; 00404 return false; 00405 } 00406 00407 d->masterFd = fd; 00408 if (!openSlave()) { 00409 d->masterFd = -1; 00410 return false; 00411 } 00412 00413 return true; 00414 #endif 00415 } 00416 00417 void KPty::closeSlave() 00418 { 00419 Q_D(KPty); 00420 00421 if (d->slaveFd < 0) 00422 return; 00423 ::close(d->slaveFd); 00424 d->slaveFd = -1; 00425 } 00426 00427 bool KPty::openSlave() 00428 { 00429 Q_D(KPty); 00430 00431 if (d->slaveFd >= 0) 00432 return true; 00433 if (d->masterFd < 0) { 00434 kWarning(175) << "Attempting to open pty slave while master is closed"; 00435 return false; 00436 } 00437 d->slaveFd = KDE_open(d->ttyName.data(), O_RDWR | O_NOCTTY); 00438 if (d->slaveFd < 0) { 00439 kWarning(175) << "Can't open slave pseudo teletype"; 00440 return false; 00441 } 00442 fcntl(d->slaveFd, F_SETFD, FD_CLOEXEC); 00443 return true; 00444 } 00445 00446 void KPty::close() 00447 { 00448 Q_D(KPty); 00449 00450 if (d->masterFd < 0) 00451 return; 00452 closeSlave(); 00453 if (d->ownMaster) { 00454 #ifndef HAVE_OPENPTY 00455 // don't bother resetting unix98 pty, it will go away after closing master anyway. 00456 if (memcmp(d->ttyName.data(), "/dev/pts/", 9)) { 00457 if (!geteuid()) { 00458 struct stat st; 00459 if (!stat(d->ttyName.data(), &st)) { 00460 chown(d->ttyName.data(), 0, st.st_gid == getgid() ? 0 : -1); 00461 chmod(d->ttyName.data(), S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); 00462 } 00463 } else { 00464 fcntl(d->masterFd, F_SETFD, 0); 00465 d->chownpty(false); 00466 } 00467 } 00468 #endif 00469 ::close(d->masterFd); 00470 } 00471 d->masterFd = -1; 00472 } 00473 00474 void KPty::setCTty() 00475 { 00476 Q_D(KPty); 00477 00478 // Setup job control ////////////////////////////////// 00479 00480 // Become session leader, process group leader, 00481 // and get rid of the old controlling terminal. 00482 setsid(); 00483 00484 // make our slave pty the new controlling terminal. 00485 #ifdef TIOCSCTTY 00486 ioctl(d->slaveFd, TIOCSCTTY, 0); 00487 #else 00488 // __svr4__ hack: the first tty opened after setsid() becomes controlling tty 00489 ::close(KDE_open(d->ttyName, O_WRONLY, 0)); 00490 #endif 00491 00492 // make our new process group the foreground group on the pty 00493 int pgrp = getpid(); 00494 #if defined(_POSIX_VERSION) || defined(__svr4__) 00495 tcsetpgrp(d->slaveFd, pgrp); 00496 #elif defined(TIOCSPGRP) 00497 ioctl(d->slaveFd, TIOCSPGRP, (char *)&pgrp); 00498 #endif 00499 } 00500 00501 void KPty::login(const char *user, const char *remotehost) 00502 { 00503 #ifdef HAVE_UTEMPTER 00504 Q_D(KPty); 00505 00506 addToUtmp(d->ttyName, remotehost, d->masterFd); 00507 Q_UNUSED(user); 00508 #else 00509 # ifdef HAVE_UTMPX 00510 struct utmpx l_struct; 00511 # else 00512 struct utmp l_struct; 00513 # endif 00514 memset(&l_struct, 0, sizeof(l_struct)); 00515 // note: strncpy without terminators _is_ correct here. man 4 utmp 00516 00517 if (user) 00518 strncpy(l_struct.ut_name, user, sizeof(l_struct.ut_name)); 00519 00520 if (remotehost) { 00521 strncpy(l_struct.ut_host, remotehost, sizeof(l_struct.ut_host)); 00522 # ifdef HAVE_STRUCT_UTMP_UT_SYSLEN 00523 l_struct.ut_syslen = qMin(strlen(remotehost), sizeof(l_struct.ut_host)); 00524 # endif 00525 } 00526 00527 # ifndef __GLIBC__ 00528 Q_D(KPty); 00529 const char *str_ptr = d->ttyName.data(); 00530 if (!memcmp(str_ptr, "/dev/", 5)) 00531 str_ptr += 5; 00532 strncpy(l_struct.ut_line, str_ptr, sizeof(l_struct.ut_line)); 00533 # ifdef HAVE_STRUCT_UTMP_UT_ID 00534 strncpy(l_struct.ut_id, 00535 str_ptr + strlen(str_ptr) - sizeof(l_struct.ut_id), 00536 sizeof(l_struct.ut_id)); 00537 # endif 00538 # endif 00539 00540 # ifdef HAVE_UTMPX 00541 gettimeofday(&l_struct.ut_tv, 0); 00542 # else 00543 l_struct.ut_time = time(0); 00544 # endif 00545 00546 # ifdef HAVE_LOGIN 00547 # ifdef HAVE_LOGINX 00548 ::loginx(&l_struct); 00549 # else 00550 ::login(&l_struct); 00551 # endif 00552 # else 00553 # ifdef HAVE_STRUCT_UTMP_UT_TYPE 00554 l_struct.ut_type = USER_PROCESS; 00555 # endif 00556 # ifdef HAVE_STRUCT_UTMP_UT_PID 00557 l_struct.ut_pid = getpid(); 00558 # ifdef HAVE_STRUCT_UTMP_UT_SESSION 00559 l_struct.ut_session = getsid(0); 00560 # endif 00561 # endif 00562 # ifdef HAVE_UTMPX 00563 utmpxname(_PATH_UTMPX); 00564 setutxent(); 00565 pututxline(&l_struct); 00566 endutxent(); 00567 updwtmpx(_PATH_WTMPX, &l_struct); 00568 # else 00569 utmpname(_PATH_UTMP); 00570 setutent(); 00571 pututline(&l_struct); 00572 endutent(); 00573 updwtmp(_PATH_WTMP, &l_struct); 00574 # endif 00575 # endif 00576 #endif 00577 } 00578 00579 void KPty::logout() 00580 { 00581 #ifdef HAVE_UTEMPTER 00582 Q_D(KPty); 00583 00584 removeLineFromUtmp(d->ttyName, d->masterFd); 00585 #else 00586 Q_D(KPty); 00587 00588 const char *str_ptr = d->ttyName.data(); 00589 if (!memcmp(str_ptr, "/dev/", 5)) 00590 str_ptr += 5; 00591 # ifdef __GLIBC__ 00592 else { 00593 const char *sl_ptr = strrchr(str_ptr, '/'); 00594 if (sl_ptr) 00595 str_ptr = sl_ptr + 1; 00596 } 00597 # endif 00598 # ifdef HAVE_LOGIN 00599 # ifdef HAVE_LOGINX 00600 ::logoutx(str_ptr, 0, DEAD_PROCESS); 00601 # else 00602 ::logout(str_ptr); 00603 # endif 00604 # else 00605 # ifdef HAVE_UTMPX 00606 struct utmpx l_struct, *ut; 00607 # else 00608 struct utmp l_struct, *ut; 00609 # endif 00610 memset(&l_struct, 0, sizeof(l_struct)); 00611 00612 strncpy(l_struct.ut_line, str_ptr, sizeof(l_struct.ut_line)); 00613 00614 # ifdef HAVE_UTMPX 00615 utmpxname(_PATH_UTMPX); 00616 setutxent(); 00617 if ((ut = getutxline(&l_struct))) { 00618 # else 00619 utmpname(_PATH_UTMP); 00620 setutent(); 00621 if ((ut = getutline(&l_struct))) { 00622 # endif 00623 memset(ut->ut_name, 0, sizeof(*ut->ut_name)); 00624 memset(ut->ut_host, 0, sizeof(*ut->ut_host)); 00625 # ifdef HAVE_STRUCT_UTMP_UT_SYSLEN 00626 ut->ut_syslen = 0; 00627 # endif 00628 # ifdef HAVE_STRUCT_UTMP_UT_TYPE 00629 ut->ut_type = DEAD_PROCESS; 00630 # endif 00631 # ifdef HAVE_UTMPX 00632 gettimeofday(&(ut->ut_tv), 0); 00633 pututxline(ut); 00634 } 00635 endutxent(); 00636 # else 00637 ut->ut_time = time(0); 00638 pututline(ut); 00639 } 00640 endutent(); 00641 # endif 00642 # endif 00643 #endif 00644 } 00645 00646 bool KPty::tcGetAttr(struct ::termios *ttmode) const 00647 { 00648 Q_D(const KPty); 00649 00650 #ifdef Q_OS_SOLARIS 00651 if (_tcgetattr(d->slaveFd, ttmode) == 0) return true; 00652 #endif 00653 return _tcgetattr(d->masterFd, ttmode) == 0; 00654 } 00655 00656 bool KPty::tcSetAttr(struct ::termios *ttmode) 00657 { 00658 Q_D(KPty); 00659 00660 #ifdef Q_OS_SOLARIS 00661 if (_tcsetattr(d->slaveFd, ttmode) == 0) return true; 00662 #endif 00663 return _tcsetattr(d->masterFd, ttmode) == 0; 00664 } 00665 00666 bool KPty::setWinSize(int lines, int columns) 00667 { 00668 Q_D(KPty); 00669 00670 struct winsize winSize; 00671 memset(&winSize, 0, sizeof(winSize)); 00672 winSize.ws_row = (unsigned short)lines; 00673 winSize.ws_col = (unsigned short)columns; 00674 return ioctl(d->masterFd, TIOCSWINSZ, (char *)&winSize) == 0; 00675 } 00676 00677 bool KPty::setEcho(bool echo) 00678 { 00679 struct ::termios ttmode; 00680 if (!tcGetAttr(&ttmode)) 00681 return false; 00682 if (!echo) 00683 ttmode.c_lflag &= ~ECHO; 00684 else 00685 ttmode.c_lflag |= ECHO; 00686 return tcSetAttr(&ttmode); 00687 } 00688 00689 const char *KPty::ttyName() const 00690 { 00691 Q_D(const KPty); 00692 00693 return d->ttyName.data(); 00694 } 00695 00696 int KPty::masterFd() const 00697 { 00698 Q_D(const KPty); 00699 00700 return d->masterFd; 00701 } 00702 00703 int KPty::slaveFd() const 00704 { 00705 Q_D(const KPty); 00706 00707 return d->slaveFd; 00708 }
KDE 4.6 API Reference