2 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
7 * Miscellaneous routines needed by the telnet client for authentication
12 * Copyright (c) 1991, 1993
13 * The Regents of the University of California. All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. All advertising materials mentioning features or use of this software
24 * must display the following acknowledgement:
25 * This product includes software developed by the University of
26 * California, Berkeley and its contributors.
27 * 4. Neither the name of the University nor the names of its contributors
28 * may be used to endorse or promote products derived from this software
29 * without specific prior written permission.
31 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 static char sccsid
[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93";
46 #include <sys/types.h>
47 #include <arpa/telnet.h>
55 char *RemoteHostName
= NULL
;
56 char *UserNameRequested
= NULL
;
61 * Get ready to do authentication and encryption by calling their
62 * init routines, and clearing the user name variable
66 auth_encrypt_init(char *local
, char *remote
, char *name
)
68 RemoteHostName
= remote
;
74 if (UserNameRequested
) {
75 free(UserNameRequested
);
76 UserNameRequested
= NULL
;
81 * Set the user name variable. This is the user name used from now
82 * on for authentication and encryption
85 auth_encrypt_user(char *name
)
87 free(UserNameRequested
);
88 UserNameRequested
= name
? strdup(name
) : NULL
;
92 net_write(unsigned char *str
, int len
)
94 if (NETROOM() > len
) {
95 ring_supply_data(&netoring
, str
, len
);
96 if (str
[0] == IAC
&& str
[1] == SE
)
97 printsub('>', &str
[2], len
- 2);
107 ring_encrypt(&netoring
, encrypt_output
);
109 ring_clearto(&netoring
);
113 * Spin to wait for authentication to complete
114 * This allows for a timeout
119 extern boolean_t scheduler_lockout_tty
;
121 scheduler_lockout_tty
= B_TRUE
;
123 scheduler_lockout_tty
= B_FALSE
;
128 * Used to print out unsigned chars as decimals for debugging options
131 printd(unsigned char *data
, int cnt
)
133 cnt
= (cnt
< MAXNETDATA
) ? cnt
:MAXNETDATA
;
135 (void) printf(" %02x", *data
++);