1 /*-
2 * Copyright (c) 1991, 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. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 #ifndef lint
31 /* from: static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/4/93"; */
32 /* from: static char rcsid[] = "$NetBSD: misc.c,v 1.5 1996/02/24 01:15:25 jtk Exp $"; */
33 static char rcsid[] = "$OpenBSD: misc.c,v 1.2 2003/06/02 19:38:25 millert Exp $";
34 #endif /* not lint */
35
36 /* $KTH: misc.c,v 1.15 2000/01/25 23:24:58 assar Exp $ */
37
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include <err.h>
42 #include "misc.h"
43 #include "auth.h"
44 #include "encrypt.h"
45
46
47 const char *RemoteHostName;
48 const char *LocalHostName;
49 char *UserNameRequested = 0;
50 int ConnectedCount = 0;
51
52 void
auth_encrypt_init(const char * local,const char * remote,const char * name,int server)53 auth_encrypt_init(const char *local, const char *remote, const char *name,
54 int server)
55 {
56 RemoteHostName = remote;
57 LocalHostName = local;
58 #ifdef AUTHENTICATION
59 auth_init(name, server);
60 #endif
61 #ifdef ENCRYPTION
62 encrypt_init(name, server);
63 #endif
64 if (UserNameRequested) {
65 free(UserNameRequested);
66 UserNameRequested = 0;
67 }
68 }
69
70 void
auth_encrypt_user(const char * name)71 auth_encrypt_user(const char *name)
72 {
73 if (UserNameRequested)
74 free(UserNameRequested);
75 UserNameRequested = name ? strdup(name) : 0;
76 }
77
78 void
auth_encrypt_connect(int cnt)79 auth_encrypt_connect(int cnt)
80 {
81 }
82
83 void
printd(const unsigned char * data,int cnt)84 printd(const unsigned char *data, int cnt)
85 {
86 if (cnt > 16)
87 cnt = 16;
88 while (cnt-- > 0) {
89 printf(" %02x", *data);
90 ++data;
91 }
92 }
93
94 /* This is stolen from libroken; it's the only thing actually needed from
95 * libroken.
96 */
97 void
esetenv(const char * var,const char * val,int rewrite)98 esetenv(const char *var, const char *val, int rewrite)
99 {
100 if (setenv ((char *)var, (char *)val, rewrite))
101 errx (1, "failed setting environment variable %s", var);
102 }
103