1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static const char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95"; 37#endif 38static const char rcsid[] = |
39 "$FreeBSD: head/contrib/telnet/telnetd/sys_term.c 81965 2001-08-20 12:28:40Z markm $"; |
40#endif /* not lint */ 41 42#include "telnetd.h" 43#include "pathnames.h" 44 45#if defined(AUTHENTICATION) 46#include <libtelnet/auth.h> 47#endif --- 428 unchanged lines hidden (view full) --- 476/* 477 * getpty() 478 * 479 * Allocate a pty. As a side effect, the external character 480 * array "line" contains the name of the slave side. 481 * 482 * Returns the file descriptor of the opened pty. 483 */ |
484#ifdef CRAY |
485char myline[16]; 486#else 487char line[16]; |
488#endif /* CRAY */ 489 490 int 491getpty(ptynum) 492int *ptynum; 493{ 494 register int p; 495#ifdef STREAMSPTY --- 12 unchanged lines hidden (view full) --- 508#ifndef CRAY 509 register char *cp, *p1, *p2; 510 register int i; 511#if defined(sun) && defined(TIOCGPGRP) && BSD < 199207 512 int dummy; 513#endif 514 515#ifndef __hpux |
516 (void) strcpy(line, _PATH_DEV); 517 (void) strcat(line, "ptyXX"); |
518 p1 = &line[8]; 519 p2 = &line[9]; 520#else 521 (void) strcpy(line, "/dev/ptym/ptyXX"); 522 p1 = &line[13]; 523 p2 = &line[14]; 524#endif 525 --- 34 unchanged lines hidden (view full) --- 560 } 561 } 562 } 563#else /* CRAY */ 564 extern lowpty, highpty; 565 struct stat sb; 566 567 for (*ptynum = lowpty; *ptynum <= highpty; (*ptynum)++) { |
568 (void) sprintf(myline, "%spty/%03d", _PATH_DEV, *ptynum); |
569 p = open(myline, 2); 570 if (p < 0) 571 continue; |
572 (void) sprintf(line, "%sp%03d", _PATH_TTY, *ptynum); |
573 /* 574 * Here are some shenanigans to make sure that there 575 * are no listeners lurking on the line. 576 */ 577 if(stat(line, &sb) < 0) { 578 (void) close(p); 579 continue; 580 } --- 711 unchanged lines hidden (view full) --- 1292 return(-1); 1293# endif 1294# if defined(CRAY) && defined(TCVHUP) 1295 { 1296 register int i; 1297 (void) signal(SIGHUP, SIG_IGN); 1298 (void) ioctl(t, TCVHUP, (char *)0); 1299 (void) signal(SIGHUP, SIG_DFL); |
1300 setpgrp(); |
1301 1302#ifdef UNICOS7x 1303 if (secflag) { 1304 if (secstat(line, &secbuf) < 0) 1305 return(-1); 1306 if (setulvl(secbuf.st_slevel) < 0) 1307 return(-1); 1308 if (setucmp(secbuf.st_compart) < 0) --- 43 unchanged lines hidden (view full) --- 1352 if (ioctl(t, TIOCSCTTY, (char *)0) < 0) 1353 fatalperror(net, "ioctl(sctty)"); 1354# if defined(CRAY) 1355 /* 1356 * Close the hard fd to /dev/ttypXXX, and re-open through 1357 * the indirect /dev/tty interface. 1358 */ 1359 close(t); |
1360 if ((t = open(_PATH_TTY, O_RDWR)) < 0) |
1361 fatalperror(net, "open(/dev/tty)"); 1362# endif 1363# else 1364 /* 1365 * We get our controlling tty assigned as a side-effect 1366 * of opening up a tty device. But on BSD based systems, 1367 * this only happens if our process group is zero. The 1368 * setsid() call above may have set our pgrp, so clear --- 76 unchanged lines hidden (view full) --- 1445 /* 1446 * Create utmp entry for child 1447 */ 1448 (void) time(&wtmp.ut_time); 1449 wtmp.ut_type = LOGIN_PROCESS; 1450 wtmp.ut_pid = pid; 1451 SCPYN(wtmp.ut_user, "LOGIN"); 1452 SCPYN(wtmp.ut_host, host); |
1453 SCPYN(wtmp.ut_line, line + sizeof(_PATH_DEV) - 1); |
1454#ifndef __hpux 1455 SCPYN(wtmp.ut_id, wtmp.ut_line+3); 1456#else 1457 SCPYN(wtmp.ut_id, wtmp.ut_line+7); 1458#endif 1459 pututline(&wtmp); 1460 endutent(); 1461 if ((i = open(wtmpf, O_WRONLY|O_APPEND)) >= 0) { --- 115 unchanged lines hidden (view full) --- 1577 1578#ifdef UTMPX 1579 /* 1580 * Create utmp entry for child 1581 */ 1582 1583 memset(&utmpx, 0, sizeof(utmpx)); 1584 SCPYN(utmpx.ut_user, ".telnet"); |
1585 SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1); |
1586 utmpx.ut_pid = pid; 1587 utmpx.ut_id[0] = 't'; 1588 utmpx.ut_id[1] = 'n'; 1589 utmpx.ut_id[2] = SC_WILDC; 1590 utmpx.ut_id[3] = SC_WILDC; 1591 utmpx.ut_type = LOGIN_PROCESS; 1592 (void) time(&utmpx.ut_tv.tv_sec); 1593 if (makeutx(&utmpx) == NULL) --- 297 unchanged lines hidden (view full) --- 1891 void 1892cleanup(sig) 1893 int sig; 1894{ 1895#ifndef PARENT_DOES_UTMP 1896# if (BSD > 43) || defined(convex) 1897 char *p; 1898 |
1899 p = line + sizeof(_PATH_DEV) - 1; |
1900 if (logout(p)) 1901 logwtmp(p, "", ""); 1902 (void)chmod(line, 0666); 1903 (void)chown(line, 0, 0); 1904 *p = 'p'; 1905 (void)chmod(line, 0666); 1906 (void)chown(line, 0, 0); 1907 (void) shutdown(net, 2); --- 294 unchanged lines hidden (view full) --- 2202 register char *user; 2203{ 2204 switch(fork()) { 2205 case -1: 2206 syslog(LOG_ERR, "TMPDIR cleanup(%s): fork() failed: %m", 2207 tpath); 2208 break; 2209 case 0: |
2210 execl(CLEANTMPCMD, CLEANTMPCMD, user, tpath, (char *)0); |
2211 syslog(LOG_ERR, "TMPDIR cleanup(%s): execl(%s) failed: %m", 2212 tpath, CLEANTMPCMD); 2213 exit(1); 2214 default: 2215 /* 2216 * Forget about child. We will exit, and 2217 * /etc/init will pick it up. 2218 */ --- 21 unchanged lines hidden (view full) --- 2240 struct stat statbf; 2241 2242 struct utmpx *utxp, utmpx; 2243 2244 /* 2245 * This updates the utmpx and utmp entries and make a wtmp/x entry 2246 */ 2247 |
2248 SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1); |
2249 utxp = getutxline(&utmpx); 2250 if (utxp) { 2251 utxp->ut_type = DEAD_PROCESS; 2252 utxp->ut_exit.e_termination = 0; 2253 utxp->ut_exit.e_exit = 0; 2254 (void) time(&utmpx.ut_tv.tv_sec); 2255 utmpx.ut_tv.tv_usec = 0; 2256 modutx(utxp); --- 44 unchanged lines hidden (view full) --- 2301 SCPYN(wtmp.ut_host, ""); 2302 (void) time(&wtmp.ut_time); 2303 (void) write(f, (char *)&wtmp, sizeof(wtmp)); 2304 (void) close(f); 2305 } 2306 } 2307 (void) chmod(line, 0666); 2308 (void) chown(line, 0, 0); |
2309 line[strlen(_PATH_DEV)] = 'p'; |
2310 (void) chmod(line, 0666); 2311 (void) chown(line, 0, 0); 2312} /* end of rmut */ 2313#endif /* CRAY */ 2314 2315#ifdef __hpux 2316rmut (line) 2317char *line; --- 35 unchanged lines hidden --- |