sys_term.c (69825) | sys_term.c (81965) |
---|---|
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[] = | 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 69825 2000-12-10 20:50:20Z assar $"; | 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 */ | 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#ifndef __GNUC__ 485char *line = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; 486#else 487static char Xline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; 488char *line = Xline; 489#endif | |
490#ifdef CRAY | 484#ifdef CRAY |
491char *myline = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; | 485char myline[16]; 486#else 487char line[16]; |
492#endif /* CRAY */ 493 494 int 495getpty(ptynum) 496int *ptynum; 497{ 498 register int p; 499#ifdef STREAMSPTY --- 12 unchanged lines hidden (view full) --- 512#ifndef CRAY 513 register char *cp, *p1, *p2; 514 register int i; 515#if defined(sun) && defined(TIOCGPGRP) && BSD < 199207 516 int dummy; 517#endif 518 519#ifndef __hpux | 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 |
520 (void) strcpy(line, "/dev/ptyXX"); | 516 (void) strcpy(line, _PATH_DEV); 517 (void) strcat(line, "ptyXX"); |
521 p1 = &line[8]; 522 p2 = &line[9]; 523#else 524 (void) strcpy(line, "/dev/ptym/ptyXX"); 525 p1 = &line[13]; 526 p2 = &line[14]; 527#endif 528 --- 34 unchanged lines hidden (view full) --- 563 } 564 } 565 } 566#else /* CRAY */ 567 extern lowpty, highpty; 568 struct stat sb; 569 570 for (*ptynum = lowpty; *ptynum <= highpty; (*ptynum)++) { | 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)++) { |
571 (void) sprintf(myline, "/dev/pty/%03d", *ptynum); | 568 (void) sprintf(myline, "%spty/%03d", _PATH_DEV, *ptynum); |
572 p = open(myline, 2); 573 if (p < 0) 574 continue; | 569 p = open(myline, 2); 570 if (p < 0) 571 continue; |
575 (void) sprintf(line, "/dev/ttyp%03d", *ptynum); | 572 (void) sprintf(line, "%sp%03d", _PATH_TTY, *ptynum); |
576 /* 577 * Here are some shenanigans to make sure that there 578 * are no listeners lurking on the line. 579 */ 580 if(stat(line, &sb) < 0) { 581 (void) close(p); 582 continue; 583 } --- 711 unchanged lines hidden (view full) --- 1295 return(-1); 1296# endif 1297# if defined(CRAY) && defined(TCVHUP) 1298 { 1299 register int i; 1300 (void) signal(SIGHUP, SIG_IGN); 1301 (void) ioctl(t, TCVHUP, (char *)0); 1302 (void) signal(SIGHUP, SIG_DFL); | 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(); |
|
1303 1304#ifdef UNICOS7x 1305 if (secflag) { 1306 if (secstat(line, &secbuf) < 0) 1307 return(-1); 1308 if (setulvl(secbuf.st_slevel) < 0) 1309 return(-1); 1310 if (setucmp(secbuf.st_compart) < 0) --- 43 unchanged lines hidden (view full) --- 1354 if (ioctl(t, TIOCSCTTY, (char *)0) < 0) 1355 fatalperror(net, "ioctl(sctty)"); 1356# if defined(CRAY) 1357 /* 1358 * Close the hard fd to /dev/ttypXXX, and re-open through 1359 * the indirect /dev/tty interface. 1360 */ 1361 close(t); | 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); |
1362 if ((t = open("/dev/tty", O_RDWR)) < 0) | 1360 if ((t = open(_PATH_TTY, O_RDWR)) < 0) |
1363 fatalperror(net, "open(/dev/tty)"); 1364# endif 1365# else 1366 /* 1367 * We get our controlling tty assigned as a side-effect 1368 * of opening up a tty device. But on BSD based systems, 1369 * this only happens if our process group is zero. The 1370 * setsid() call above may have set our pgrp, so clear --- 76 unchanged lines hidden (view full) --- 1447 /* 1448 * Create utmp entry for child 1449 */ 1450 (void) time(&wtmp.ut_time); 1451 wtmp.ut_type = LOGIN_PROCESS; 1452 wtmp.ut_pid = pid; 1453 SCPYN(wtmp.ut_user, "LOGIN"); 1454 SCPYN(wtmp.ut_host, host); | 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); |
1455 SCPYN(wtmp.ut_line, line + sizeof("/dev/") - 1); | 1453 SCPYN(wtmp.ut_line, line + sizeof(_PATH_DEV) - 1); |
1456#ifndef __hpux 1457 SCPYN(wtmp.ut_id, wtmp.ut_line+3); 1458#else 1459 SCPYN(wtmp.ut_id, wtmp.ut_line+7); 1460#endif 1461 pututline(&wtmp); 1462 endutent(); 1463 if ((i = open(wtmpf, O_WRONLY|O_APPEND)) >= 0) { --- 115 unchanged lines hidden (view full) --- 1579 1580#ifdef UTMPX 1581 /* 1582 * Create utmp entry for child 1583 */ 1584 1585 memset(&utmpx, 0, sizeof(utmpx)); 1586 SCPYN(utmpx.ut_user, ".telnet"); | 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"); |
1587 SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1); | 1585 SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1); |
1588 utmpx.ut_pid = pid; 1589 utmpx.ut_id[0] = 't'; 1590 utmpx.ut_id[1] = 'n'; 1591 utmpx.ut_id[2] = SC_WILDC; 1592 utmpx.ut_id[3] = SC_WILDC; 1593 utmpx.ut_type = LOGIN_PROCESS; 1594 (void) time(&utmpx.ut_tv.tv_sec); 1595 if (makeutx(&utmpx) == NULL) --- 297 unchanged lines hidden (view full) --- 1893 void 1894cleanup(sig) 1895 int sig; 1896{ 1897#ifndef PARENT_DOES_UTMP 1898# if (BSD > 43) || defined(convex) 1899 char *p; 1900 | 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 |
1901 p = line + sizeof("/dev/") - 1; | 1899 p = line + sizeof(_PATH_DEV) - 1; |
1902 if (logout(p)) 1903 logwtmp(p, "", ""); 1904 (void)chmod(line, 0666); 1905 (void)chown(line, 0, 0); 1906 *p = 'p'; 1907 (void)chmod(line, 0666); 1908 (void)chown(line, 0, 0); 1909 (void) shutdown(net, 2); --- 294 unchanged lines hidden (view full) --- 2204 register char *user; 2205{ 2206 switch(fork()) { 2207 case -1: 2208 syslog(LOG_ERR, "TMPDIR cleanup(%s): fork() failed: %m", 2209 tpath); 2210 break; 2211 case 0: | 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: |
2212 execl(CLEANTMPCMD, CLEANTMPCMD, user, tpath, 0); | 2210 execl(CLEANTMPCMD, CLEANTMPCMD, user, tpath, (char *)0); |
2213 syslog(LOG_ERR, "TMPDIR cleanup(%s): execl(%s) failed: %m", 2214 tpath, CLEANTMPCMD); 2215 exit(1); 2216 default: 2217 /* 2218 * Forget about child. We will exit, and 2219 * /etc/init will pick it up. 2220 */ --- 21 unchanged lines hidden (view full) --- 2242 struct stat statbf; 2243 2244 struct utmpx *utxp, utmpx; 2245 2246 /* 2247 * This updates the utmpx and utmp entries and make a wtmp/x entry 2248 */ 2249 | 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 |
2250 SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1); | 2248 SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1); |
2251 utxp = getutxline(&utmpx); 2252 if (utxp) { 2253 utxp->ut_type = DEAD_PROCESS; 2254 utxp->ut_exit.e_termination = 0; 2255 utxp->ut_exit.e_exit = 0; 2256 (void) time(&utmpx.ut_tv.tv_sec); 2257 utmpx.ut_tv.tv_usec = 0; 2258 modutx(utxp); --- 44 unchanged lines hidden (view full) --- 2303 SCPYN(wtmp.ut_host, ""); 2304 (void) time(&wtmp.ut_time); 2305 (void) write(f, (char *)&wtmp, sizeof(wtmp)); 2306 (void) close(f); 2307 } 2308 } 2309 (void) chmod(line, 0666); 2310 (void) chown(line, 0, 0); | 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); |
2311 line[strlen("/dev/")] = 'p'; | 2309 line[strlen(_PATH_DEV)] = 'p'; |
2312 (void) chmod(line, 0666); 2313 (void) chown(line, 0, 0); 2314} /* end of rmut */ 2315#endif /* CRAY */ 2316 2317#ifdef __hpux 2318rmut (line) 2319char *line; --- 35 unchanged lines hidden --- | 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 --- |