Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / crypto / kerberosIV / appl / bsd / bsd_locl.h
1 /*
2  * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
3  * (Royal Institute of Technology, Stockholm, Sweden).
4  * All rights reserved.
5  * 
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 
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.
16  * 
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.
20  * 
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
31  * SUCH DAMAGE.
32  */
33
34 /* $Id: bsd_locl.h,v 1.111 1999/12/02 16:58:28 joda Exp $ */
35 /* $FreeBSD: src/crypto/kerberosIV/appl/bsd/bsd_locl.h,v 1.4.2.2 2003/02/13 21:34:35 nectar Exp $ */
36 /* $DragonFly: src/crypto/kerberosIV/appl/bsd/Attic/bsd_locl.h,v 1.2 2003/06/17 04:24:36 dillon Exp $ */
37
38 #define LOGALL
39 #ifndef KERBEROS
40 #define KERBEROS
41 #endif
42 #define KLOGIN_PARANOID
43 #define LOGIN_ACCESS
44 #define PASSWD_FALLBACK
45
46 #ifdef HAVE_CONFIG_H
47 #include "config.h"
48 #endif
49
50 /* Any better way to test NO_MOTD? */
51 #if (SunOS >= 50) || defined(__hpux)
52 #define NO_MOTD
53 #endif
54
55 #ifdef HAVE_SHADOW_H
56 #define SYSV_SHADOW
57 #endif
58
59 #include <stdio.h>
60 #include <string.h>
61 #include <stdlib.h>
62 #include <ctype.h>
63 #include <setjmp.h>
64 #include <limits.h>
65
66 #include <stdarg.h>
67
68 #include <errno.h>
69 #ifdef HAVE_IO_H
70 #include <io.h>
71 #endif
72 #ifdef HAVE_UNISTD_H
73 #include <unistd.h>
74 #endif
75 #ifdef HAVE_LIBUTIL_H
76 #include <libutil.h>
77 #endif
78 #ifdef HAVE_SYS_TYPES_H
79 #include <sys/types.h>
80 #endif
81 #ifdef TIME_WITH_SYS_TIME
82 #include <sys/time.h>
83 #include <time.h>
84 #elif defined(HAVE_SYS_TIME_H)
85 #include <sys/time.h>
86 #else
87 #include <time.h>
88 #endif
89 #ifdef HAVE_SYS_STAT_H
90 #include <sys/stat.h>
91 #endif
92
93 #ifndef S_ISTXT
94 #ifdef S_ISVTX
95 #define S_ISTXT S_ISVTX
96 #else
97 #define S_ISTXT 0
98 #endif
99 #endif
100
101 #ifdef HAVE_FCNTL_H
102 #include <fcntl.h>
103 #endif
104 #ifdef HAVE_DIRENT_H
105 #include <dirent.h>
106 #endif
107 #include <signal.h>
108 #ifdef HAVE_SYS_RESOURCE_H
109 #include <sys/resource.h>
110 #endif /* HAVE_SYS_RESOURCE_H */
111 #ifdef HAVE_SYS_WAIT_H
112 #include <sys/wait.h>
113 #endif
114 #ifdef HAVE_SYS_PARAM_H
115 #include <sys/param.h>
116 #endif
117
118 #ifndef NCARGS
119 #define NCARGS  0x100000 /* (absolute) max # characters in exec arglist */
120 #endif
121 #ifdef HAVE_PWD_H
122 #include <pwd.h>
123 #endif
124
125 #ifdef HAVE_GRP_H
126 #include <grp.h>
127 #endif
128 #ifdef HAVE_UTIME_H
129 #include <utime.h>
130 #endif
131
132 #ifdef HAVE_SYS_SOCKET_H
133 #include <sys/socket.h>
134 #endif
135 #ifdef HAVE_NETINET_IN_H
136 #include <netinet/in.h>
137 #endif
138 #ifdef HAVE_NETINET_IN_SYSTM_H
139 #include <netinet/in_systm.h>
140 #endif
141 #ifdef HAVE_NETINET_IP_H
142 #include <netinet/ip.h>
143 #endif
144 #ifdef HAVE_NETINET_TCP_H
145 #include <netinet/tcp.h>
146 #endif
147 #ifdef HAVE_ARPA_INET_H
148 #include <arpa/inet.h>
149 #endif
150 #ifdef HAVE_NETDB_H
151 #include <netdb.h>
152 #endif
153
154 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 40
155 #include <sys/ioctl.h>
156 #endif
157 #ifdef HAVE_SYS_IOCCOM_H
158 #include <sys/ioccom.h>
159 #endif
160
161 #ifdef HAVE_SYS_SOCKIO_H
162 #include <sys/sockio.h>
163 #endif
164
165 #ifdef HAVE_SYS_SELECT_H
166 #include <sys/select.h>
167 #endif
168
169 #ifdef HAVE_SYS_FILIO_H
170 #include <sys/filio.h>
171 #endif
172
173 #ifdef HAVE_SYS_STREAM_H
174 #ifdef HAVE_SYS_UIO_H
175 #include <sys/uio.h>
176 #endif /* HAVE_SYS_UIO_H */
177 #include <sys/stream.h>
178 #endif /* HAVE_SYS_STREAM_H */
179
180 #ifdef HAVE_SYS_PTYVAR_H
181 #ifdef HAVE_SYS_PROC_H
182 #include <sys/proc.h>
183 #endif
184 #ifdef HAVE_SYS_TTY_H
185 #include <sys/tty.h>
186 #endif
187 #ifdef HAVE_SYS_PTYIO_H
188 #include <sys/ptyio.h>
189 #endif
190 #include <sys/ptyvar.h>
191 #endif /* HAVE_SYS_PTYVAR_H */
192
193 /* Cray stuff */
194 #ifdef HAVE_UDB_H
195 #include <udb.h>
196 #endif
197 #ifdef HAVE_SYS_CATEGORY_H
198 #include <sys/category.h>
199 #endif
200
201 /* Strange ioctls that are not always defined */
202
203 #ifndef TIOCPKT_FLUSHWRITE
204 #define TIOCPKT_FLUSHWRITE      0x02
205 #endif
206  
207 #ifndef TIOCPKT_NOSTOP
208 #define TIOCPKT_NOSTOP  0x10
209 #endif
210  
211 #ifndef TIOCPKT_DOSTOP
212 #define TIOCPKT_DOSTOP  0x20
213 #endif
214
215 #ifndef TIOCPKT
216 #define TIOCPKT         _IOW('t', 112, int)   /* pty: set/clear packet mode */
217 #endif
218
219 #ifdef HAVE_LASTLOG_H
220 #include <lastlog.h>
221 #endif
222
223 #ifdef HAVE_LOGIN_H
224 #include <login.h>
225 #endif
226
227 #ifdef HAVE_TTYENT_H
228 #include <ttyent.h>
229 #endif
230
231 #ifdef HAVE_STROPTS_H
232 #include <stropts.h>
233 #endif
234
235 #ifdef HAVE_UTMP_H
236 #include <utmp.h>
237 #ifndef UT_NAMESIZE
238 #define UT_NAMESIZE     sizeof(((struct utmp *)0)->ut_name)
239 #endif
240 #endif
241
242 #ifdef HAVE_UTMPX_H
243 #include <utmpx.h>
244 #endif
245
246 #ifdef HAVE_USERPW_H
247 #include <userpw.h>
248 #endif /* HAVE_USERPW_H */
249
250 #ifdef HAVE_USERSEC_H
251 struct aud_rec;
252 #include <usersec.h>
253 #endif /* HAVE_USERSEC_H */
254
255 #ifdef HAVE_OSFC2
256 #include "/usr/include/prot.h"
257 #endif
258
259 #ifndef PRIO_PROCESS
260 #define PRIO_PROCESS 0
261 #endif
262
263 #include <err.h>
264
265 #include <roken.h>
266
267 #ifdef SOCKS
268 #include <socks.h>
269 /* This doesn't belong here. */
270 struct tm *localtime(const time_t *);
271 struct hostent  *gethostbyname(const char *);
272 #endif
273
274 #define OPENSSL_DES_LIBDES_COMPATIBILITY
275 #include <openssl/des.h>
276 #include <krb.h>
277 #include <kafs.h>
278
279 int kcmd(int *sock, char **ahost, u_int16_t rport, char *locuser,
280          char *remuser, char *cmd, int *fd2p, KTEXT ticket,
281          char *service, char *realm, CREDENTIALS *cred,
282          Key_schedule schedule, MSG_DAT *msg_data,
283          struct sockaddr_in *laddr, struct sockaddr_in *faddr,
284          int32_t authopts);
285
286 int krcmd(char **ahost, u_int16_t rport, char *remuser, char *cmd,
287           int *fd2p, char *realm);
288
289 int krcmd_mutual(char **ahost, u_int16_t rport, char *remuser,
290                  char *cmd,int *fd2p, char *realm,
291                  CREDENTIALS *cred, Key_schedule sched);
292
293 int klogin(struct passwd *pw, char *instance, char *localhost, char *password);
294
295 #if 0
296 typedef struct {
297         int cnt;
298         char *buf;
299 } BUF;
300 #endif
301
302 char *colon(char *cp);
303 int okname(char *cp0);
304 int susystem(char *s, int userid);
305
306 int forkpty(int *amaster, char *name,
307             struct termios *termp, struct winsize *winp);
308
309 int forkpty_truncate(int *amaster, char *name, size_t name_sz,
310                      struct termios *termp, struct winsize *winp);
311
312 #ifndef MODEMASK
313 #define MODEMASK        (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
314 #endif
315
316 #ifdef HAVE_PATHS_H
317 #include <paths.h>
318 #endif
319 #ifdef HAVE_MAILLOCK_H
320 #include <maillock.h>
321 #endif
322 #include "pathnames.h"
323
324 void stty_default (void);
325
326 int utmpx_login(char *line, char *user, char *host);
327
328 extern char **environ;
329
330 void sysv_newenv(int argc, char **argv, struct passwd *pwd,
331                  char *term, int pflag);
332
333 int login_access(struct passwd *user, char *from);
334 void fatal(int f, const char *msg, int syserr);
335
336 extern int LEFT_JUSTIFIED;
337
338 /* used in des_read and des_write */
339 #define DES_RW_MAXWRITE (1024*16)
340 #define DES_RW_BSIZE    (DES_RW_MAXWRITE+4)
341
342 void sysv_defaults(void);
343 void utmp_login(char *tty, char *username, char *hostname);
344 void sleepexit (int);
345
346 #ifndef HAVE_SETPRIORITY
347 #define setpriority(which, who, niceval) 0
348 #endif
349
350 #ifndef HAVE_GETPRIORITY
351 #define getpriority(which, who) 0
352 #endif
353
354 #ifdef HAVE_TERMIOS_H
355 #include <termios.h>
356 #endif
357
358 #ifndef _POSIX_VDISABLE
359 #define _POSIX_VDISABLE 0
360 #endif /* _POSIX_VDISABLE */
361 #if SunOS == 40
362 #include <sys/ttold.h>
363 #endif
364
365 #if defined(HAVE_SYS_TERMIO_H) && !defined(HAVE_TERMIOS_H)
366 #include <sys/termio.h>
367 #endif
368
369 #ifndef CEOF
370 #define CEOF 04
371 #endif
372
373 /* concession to Sun */
374 #ifndef SIGUSR1
375 #define SIGUSR1 30
376 #endif
377
378 #ifndef TIOCPKT_WINDOW
379 #define TIOCPKT_WINDOW 0x80
380 #endif
381
382 int get_shell_port(int kerberos, int encryption);
383 int get_login_port(int kerberos, int encryption);
384 int speed_t2int (speed_t);
385 speed_t int2speed_t (int);
386 void ip_options_and_die (int sock, struct sockaddr_in *);
387 void warning(const char *fmt, ...)
388 #ifdef __GNUC__
389 __attribute__ ((format (printf, 1, 2)))
390 #endif
391 ;
392
393 char *clean_ttyname (char *tty);
394 char *make_id (char *tty);
395 #ifdef HAVE_UTMP_H
396 void prepare_utmp (struct utmp *utmp, char *tty, char *username,
397                    char *hostname);
398 #endif
399
400 int do_osfc2_magic(uid_t);
401
402 void paranoid_setuid (uid_t uid);