Deleted Added
sdiff udiff text old ( 69825 ) new ( 81965 )
full compact
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 $";
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
491char *myline = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
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
520 (void) strcpy(line, "/dev/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)++) {
571 (void) sprintf(myline, "/dev/pty/%03d", *ptynum);
572 p = open(myline, 2);
573 if (p < 0)
574 continue;
575 (void) sprintf(line, "/dev/ttyp%03d", *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);
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);
1362 if ((t = open("/dev/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);
1455 SCPYN(wtmp.ut_line, line + sizeof("/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");
1587 SCPYN(utmpx.ut_line, line + sizeof("/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
1901 p = line + sizeof("/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:
2212 execl(CLEANTMPCMD, CLEANTMPCMD, user, tpath, 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
2250 SCPYN(utmpx.ut_line, line + sizeof("/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);
2311 line[strlen("/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 ---