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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)telnetd.h 8.1 (Berkeley) 6/4/93 34 */ 35 36 37 #include <config.h> 38 39 #include <stdio.h> 40 #include <stdarg.h> 41 #include <stdlib.h> 42 #include <string.h> 43 44 #ifdef HAVE_SYS_TYPES_H 45 #include <sys/types.h> 46 #endif 47 #ifdef HAVE_SYS_PARAM_H 48 #include <sys/param.h> 49 #endif 50 51 #ifdef HAVE_SYS_SOCKET_H 52 #include <sys/socket.h> 53 #endif 54 #ifdef TIME_WITH_SYS_TIME 55 #include <sys/time.h> 56 #include <time.h> 57 #elif defined(HAVE_SYS_TIME_H) 58 #include <sys/time.h> 59 #else 60 #include <time.h> 61 #endif 62 63 #ifdef HAVE_SYS_RESOURCE_H 64 #include <sys/resource.h> 65 #endif /* HAVE_SYS_RESOURCE_H */ 66 67 #ifdef HAVE_SYS_WAIT_H 68 #include <sys/wait.h> 69 #endif 70 71 #ifdef HAVE_FCNTL_H 72 #include <fcntl.h> 73 #endif 74 #ifdef HAVE_SYS_FILE_H 75 #include <sys/file.h> 76 #endif 77 #ifdef HAVE_SYS_STAT_H 78 #include <sys/stat.h> 79 #endif 80 81 /* including both <sys/ioctl.h> and <termios.h> in SunOS 4 generates a 82 lot of warnings */ 83 84 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 40 85 #include <sys/ioctl.h> 86 #endif 87 #ifdef HAVE_SYS_FILIO_H 88 #include <sys/filio.h> 89 #endif 90 91 #ifdef HAVE_NETINET_IN_H 92 #include <netinet/in.h> 93 #endif 94 #ifdef HAVE_NETINET_IN6_H 95 #include <netinet/in6.h> 96 #endif 97 #ifdef HAVE_NETINET6_IN6_H 98 #include <netinet6/in6.h> 99 #endif 100 101 #ifdef HAVE_ARPA_INET_H 102 #include <arpa/inet.h> 103 #endif 104 105 #include <signal.h> 106 #include <errno.h> 107 #ifdef HAVE_NETDB_H 108 #include <netdb.h> 109 #endif 110 #ifdef HAVE_SYSLOG_H 111 #include <syslog.h> 112 #endif 113 #include <ctype.h> 114 115 #ifdef HAVE_UNISTD_H 116 #include <unistd.h> 117 #endif 118 119 #include <termios.h> 120 121 #ifdef HAVE_PTY_H 122 #include <pty.h> 123 #endif 124 125 #ifdef STREAMSPTY 126 #ifdef HAVE_SAC_H 127 #include <sac.h> 128 #endif 129 #ifdef HAVE_SYS_STROPTS_H 130 #include <sys/stropts.h> 131 #endif 132 133 # include <stropts.h> 134 135 #ifdef HAVE_SYS_UIO_H 136 #include <sys/uio.h> 137 #ifdef __hpux 138 #undef SE 139 #endif 140 #endif 141 #ifdef HAVE_SYS_STREAM_H 142 #include <sys/stream.h> 143 #endif 144 145 #endif /* STREAMSPTY */ 146 147 #undef NOERROR 148 149 #include "defs.h" 150 151 #ifndef _POSIX_VDISABLE 152 # ifdef VDISABLE 153 # define _POSIX_VDISABLE VDISABLE 154 # else 155 # define _POSIX_VDISABLE ((unsigned char)'\377') 156 # endif 157 #endif 158 159 160 #ifdef HAVE_SYS_PTY_H 161 #include <sys/pty.h> 162 #endif 163 #ifdef HAVE_SYS_SELECT_H 164 #include <sys/select.h> 165 #endif 166 167 #ifdef HAVE_SYS_PTYIO_H 168 #include <sys/ptyio.h> 169 #endif 170 171 #ifdef HAVE_SYS_UTSNAME_H 172 #include <sys/utsname.h> 173 #endif 174 175 #ifdef HAVE_PATHS_H 176 #include <paths.h> 177 #endif 178 179 #ifdef HAVE_ARPA_TELNET_H 180 #include <arpa/telnet.h> 181 #endif 182 183 #include "ext.h" 184 185 #ifdef SOCKS 186 #include <socks.h> 187 /* This doesn't belong here. */ 188 struct tm *localtime(const time_t *); 189 struct hostent *gethostbyname(const char *); 190 #endif 191 192 #ifdef KRB4 193 #include <krb.h> 194 #endif 195 196 #ifdef AUTHENTICATION 197 #include <libtelnet/auth.h> 198 #include <libtelnet/misc.h> 199 #ifdef ENCRYPTION 200 #include <libtelnet/encrypt.h> 201 #endif 202 #endif 203 204 #ifdef HAVE_LIBUTIL_H 205 #include <libutil.h> 206 #endif 207 208 #include <roken.h> 209 210 /* Don't use the system login, use our version instead */ 211 212 /* BINDIR should be defined somewhere else... */ 213 214 #ifndef BINDIR 215 #define BINDIR "/usr/athena/bin" 216 #endif 217 218 #undef _PATH_LOGIN 219 #define _PATH_LOGIN BINDIR "/login" 220 221 /* fallbacks */ 222 223 #ifndef _PATH_DEV 224 #define _PATH_DEV "/dev/" 225 #endif 226 227 #ifndef _PATH_TTY 228 #define _PATH_TTY "/dev/tty" 229 #endif /* _PATH_TTY */ 230 231 #ifdef DIAGNOSTICS 232 #define DIAG(a,b) if (diagnostic & (a)) b 233 #else 234 #define DIAG(a,b) 235 #endif 236 237 /* other external variables */ 238 extern char **environ; 239 240 /* prototypes */ 241 242 /* appends data to nfrontp and advances */ 243 int output_data (const char *format, ...) 244 #ifdef __GNUC__ 245 __attribute__ ((format (printf, 1, 2))) 246 #endif 247 ; 248 249 #ifdef ENCRYPTION 250 extern int require_encryption; 251 #endif 252