Deleted Added
full compact
telnetd.c (80224) telnetd.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

--- 28 unchanged lines hidden (view full) ---

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
43#endif
44static 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

--- 28 unchanged lines hidden (view full) ---

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
43#endif
44static const char rcsid[] =
45 "$FreeBSD: head/contrib/telnet/telnetd/telnetd.c 80224 2001-07-23 21:52:26Z kris $";
45 "$FreeBSD: head/contrib/telnet/telnetd/telnetd.c 81965 2001-08-20 12:28:40Z markm $";
46#endif /* not lint */
47
48#include "telnetd.h"
49#include "pathnames.h"
50
51#if defined(_SC_CRAY_SECURE_SYS) && !defined(SCM_SECURITY)
52/*
53 * UNICOS 6.0/6.1 do not have SCM_SECURITY defined, so we can
54 * use it to tell us to turn off all the socket security code,
55 * since that is only used in UNICOS 7.0 and later.
56 */
57# undef _SC_CRAY_SECURE_SYS
58#endif
59
60#include <err.h>
61#include <arpa/inet.h>
62
46#endif /* not lint */
47
48#include "telnetd.h"
49#include "pathnames.h"
50
51#if defined(_SC_CRAY_SECURE_SYS) && !defined(SCM_SECURITY)
52/*
53 * UNICOS 6.0/6.1 do not have SCM_SECURITY defined, so we can
54 * use it to tell us to turn off all the socket security code,
55 * since that is only used in UNICOS 7.0 and later.
56 */
57# undef _SC_CRAY_SECURE_SYS
58#endif
59
60#include <err.h>
61#include <arpa/inet.h>
62
63#include <sys/mman.h>
63#include <libutil.h>
64#include <libutil.h>
65#include <paths.h>
64#include <utmp.h>
65
66#if defined(_SC_CRAY_SECURE_SYS)
67#include <sys/sysv.h>
68#include <sys/secdev.h>
69# ifdef SO_SEC_MULTI /* 8.0 code */
70#include <sys/secparm.h>
71#include <sys/usrv.h>

--- 770 unchanged lines hidden (view full) ---

842 */
843#ifndef convex
844 pty = getpty(&ptynum);
845 if (pty < 0)
846 fatal(net, "All network ports in use");
847#else
848 for (;;) {
849 char *lp;
66#include <utmp.h>
67
68#if defined(_SC_CRAY_SECURE_SYS)
69#include <sys/sysv.h>
70#include <sys/secdev.h>
71# ifdef SO_SEC_MULTI /* 8.0 code */
72#include <sys/secparm.h>
73#include <sys/usrv.h>

--- 770 unchanged lines hidden (view full) ---

844 */
845#ifndef convex
846 pty = getpty(&ptynum);
847 if (pty < 0)
848 fatal(net, "All network ports in use");
849#else
850 for (;;) {
851 char *lp;
850 extern char *line, *getpty();
851
852 if ((lp = getpty()) == NULL)
853 fatal(net, "Out of ptys");
854
855 if ((pty = open(lp, 2)) >= 0) {
856 strlcpy(line,lp,sizeof(line));
857 line[5] = 't';
858 break;
859 }
860 }
861#endif
862
863#if defined(_SC_CRAY_SECURE_SYS)
864 /*
865 * set ttyp line security label
866 */
867 if (secflag) {
868 char slave_dev[16];
869
852
853 if ((lp = getpty()) == NULL)
854 fatal(net, "Out of ptys");
855
856 if ((pty = open(lp, 2)) >= 0) {
857 strlcpy(line,lp,sizeof(line));
858 line[5] = 't';
859 break;
860 }
861 }
862#endif
863
864#if defined(_SC_CRAY_SECURE_SYS)
865 /*
866 * set ttyp line security label
867 */
868 if (secflag) {
869 char slave_dev[16];
870
870 sprintf(tty_dev, "/dev/pty/%03d", ptynum);
871 sprintf(tty_dev, "%spty/%03d", _PATH_DEV, ptynum);
871 if (setdevs(tty_dev, &dv) < 0)
872 fatal(net, "cannot set pty security");
872 if (setdevs(tty_dev, &dv) < 0)
873 fatal(net, "cannot set pty security");
873 sprintf(slave_dev, "/dev/ttyp%03d", ptynum);
874 sprintf(slave_dev, "%sp%03d", _PATH_TTY, ptynum);
874 if (setdevs(slave_dev, &dv) < 0)
875 fatal(net, "cannot set tty security");
876 }
877#endif /* _SC_CRAY_SECURE_SYS */
878
879 /* get name of connected client */
880 if (realhostname_sa(remote_hostname, sizeof(remote_hostname) - 1,
881 who, who->sa_len) == HOSTNAME_INVALIDADDR && registerd_host_only)
882 fatal(net, "Couldn't resolve your address into a host name.\r\n\
875 if (setdevs(slave_dev, &dv) < 0)
876 fatal(net, "cannot set tty security");
877 }
878#endif /* _SC_CRAY_SECURE_SYS */
879
880 /* get name of connected client */
881 if (realhostname_sa(remote_hostname, sizeof(remote_hostname) - 1,
882 who, who->sa_len) == HOSTNAME_INVALIDADDR && registerd_host_only)
883 fatal(net, "Couldn't resolve your address into a host name.\r\n\
883 Please contact your net administrator");
884 Please contact your net administrator");
884 remote_hostname[sizeof(remote_hostname) - 1] = '\0';
885
886 trimdomain(remote_hostname, UT_HOSTSIZE);
887 if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len)
888 err = getnameinfo(who, who->sa_len, remote_hostname,
889 sizeof(remote_hostname), NULL, 0,
890 NI_NUMERICHOST|NI_WITHSCOPEID);
891 /* XXX: do 'err' check */

--- 727 unchanged lines hidden ---
885 remote_hostname[sizeof(remote_hostname) - 1] = '\0';
886
887 trimdomain(remote_hostname, UT_HOSTSIZE);
888 if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len)
889 err = getnameinfo(who, who->sa_len, remote_hostname,
890 sizeof(remote_hostname), NULL, 0,
891 NI_NUMERICHOST|NI_WITHSCOPEID);
892 /* XXX: do 'err' check */

--- 727 unchanged lines hidden ---