2 * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute 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.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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
34 /* $Id: kx.h,v 1.38 2000/02/06 05:52:03 assar Exp $ */
38 #endif /* HAVE_CONFIG_H */
58 #ifdef HAVE_SYS_TYPES_H
59 #include <sys/types.h>
61 #ifdef TIME_WITH_SYS_TIME
64 #elif defined(HAVE_SYS_TIME_H)
69 #ifdef HAVE_SYS_RESOURCE_H
70 #include <sys/resource.h>
72 #ifdef HAVE_SYS_SELECT_H
73 #include <sys/select.h>
75 #ifdef HAVE_SYS_WAIT_H
78 #ifdef HAVE_SYS_STAT_H
81 #ifdef HAVE_SYS_SOCKET_H
82 #include <sys/socket.h>
84 #ifdef HAVE_NETINET_IN_H
85 #include <netinet/in.h>
87 #ifdef HAVE_NETINET_TCP_H
88 #include <netinet/tcp.h>
90 #ifdef HAVE_ARPA_INET_H
91 #include <arpa/inet.h>
100 #include <X11/Xlib.h>
101 #include <X11/Xauth.h>
103 #ifdef HAVE_SYS_STREAM_H
104 #include <sys/stream.h>
106 #ifdef HAVE_SYS_STROPTS_H
107 #include <sys/stropts.h>
110 /* as far as we know, this is only used with later versions of Slowlaris */
111 #if SunOS >= 50 && defined(HAVE_SYS_STROPTS_H) && defined(HAVE_FATTACH) && defined(I_PUSH)
112 #define MAY_HAVE_X11_PIPES
117 /* This doesn't belong here. */
118 struct tm *localtime(const time_t *);
119 struct hostent *gethostbyname(const char *);
140 UNIX_SOCKET = LISTENP | 2,
145 extern char x_socket[];
146 extern u_int32_t display_num;
147 extern char display[];
148 extern int display_size;
149 extern char xauthfile[];
150 extern int xauthfile_size;
151 extern u_char cookie[];
152 extern size_t cookie_len;
154 int get_xsockets (int *number, struct x_socket **sockets, int tcpp);
155 int chown_xsockets (int n, struct x_socket *sockets, uid_t uid, gid_t gid);
157 int connect_local_xsocket (unsigned dnr);
158 int create_and_write_cookie (char *xauthfile,
162 int verify_and_remove_cookies (int fd, int sock, int cookiesp);
163 int replace_cookie(int xserver, int fd, char *filename, int cookiesp);
165 int suspicious_address (int sock, struct sockaddr_in addr);
169 #define KX_OLD_VERSION "KXSERV.1"
170 #define KX_VERSION "KXSERV.2"
172 #define COOKIE_TYPE "MIT-MAGIC-COOKIE-1"
174 enum { INIT = 0, ACK = 1, NEW_CONN = 2, ERROR = 3 };
176 enum kx_flags { PASSIVE = 1, KEEP_ALIVE = 2 };
178 typedef enum kx_flags kx_flags;
181 int (*authenticate)(struct kx_context *kc, int s);
182 int (*userok)(struct kx_context *kc, char *user);
183 ssize_t (*read)(struct kx_context *kc,
184 int fd, void *buf, size_t len);
185 ssize_t (*write)(struct kx_context *kc,
186 int fd, const void *buf, size_t len);
187 int (*copy_encrypted)(struct kx_context *kc,
189 void (*destroy)(struct kx_context *kc);
196 struct sockaddr_in thisaddr, thataddr;
200 typedef struct kx_context kx_context;
203 context_set (kx_context *kc, const char *host, const char *user, int port,
204 int debug_flag, int keepalive_flag, int tcp_flag);
207 context_destroy (kx_context *kc);
210 context_authenticate (kx_context *kc, int s);
213 context_userok (kx_context *kc, char *user);
216 kx_read (kx_context *kc, int fd, void *buf, size_t len);
219 kx_write (kx_context *kc, int fd, const void *buf, size_t len);
222 copy_encrypted (kx_context *kc, int fd1, int fd2);
227 krb4_make_context (kx_context *c);
230 recv_v4_auth (kx_context *kc, int sock, u_char *buf);
237 krb5_make_context (kx_context *c);
240 recv_v5_auth (kx_context *kc, int sock, u_char *buf);
245 fatal (kx_context *kc, int fd, char *format, ...)
247 __attribute__ ((format (printf, 3, 4)))
254 krb_get_int(void *f, u_int32_t *to, int size, int lsb);
257 krb_put_int(u_int32_t from, void *to, size_t rem, int size);