xref: /titanic_41/usr/src/cmd/ssh/include/sshconnect.h (revision 54925bf60766fbb4f1f2d7c843721406a7b7a3fb)
1 /*
2  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 /*	$OpenBSD: sshconnect.h,v 1.17 2002/06/19 00:27:55 deraadt Exp $	*/
6 
7 #ifndef	_SSHCONNECT_H
8 #define	_SSHCONNECT_H
9 
10 #pragma ident	"%Z%%M%	%I%	%E% SMI"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 
17 /*
18  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
19  *
20  * Redistribution and use in source and binary forms, with or without
21  * modification, are permitted provided that the following conditions
22  * are met:
23  * 1. Redistributions of source code must retain the above copyright
24  *    notice, this list of conditions and the following disclaimer.
25  * 2. Redistributions in binary form must reproduce the above copyright
26  *    notice, this list of conditions and the following disclaimer in the
27  *    documentation and/or other materials provided with the distribution.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
30  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
31  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
33  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
34  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
38  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 typedef struct Sensitive Sensitive;
42 struct Sensitive {
43 	Key	**keys;
44 	int	nkeys;
45 	int	external_keysign;
46 };
47 
48 int
49 ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int,
50     int, const char *);
51 
52 void
53 ssh_login(Sensitive *, const char *, struct sockaddr *, struct passwd *);
54 
55 int	 verify_host_key(char *, struct sockaddr *, Key *);
56 int	 accept_host_key(char *, struct sockaddr *, Key *);
57 
58 void	 ssh_kex(char *, struct sockaddr *);
59 void	 ssh_kex2(char *, struct sockaddr *);
60 
61 void	 ssh_userauth1(const char *, const char *, char *, Sensitive *);
62 void	 ssh_userauth2(const char *, const char *, char *, Sensitive *);
63 
64 void	 ssh_put_password(char *);
65 
66 
67 /*
68  * Macros to raise/lower permissions.
69  */
70 #define PRIV_START do {				\
71 	int save_errno = errno;			\
72 	(void)seteuid(original_effective_uid);	\
73 	errno = save_errno;			\
74 } while (0)
75 
76 #define PRIV_END do {				\
77 	int save_errno = errno;			\
78 	(void)seteuid(original_real_uid);	\
79 	errno = save_errno;			\
80 } while (0)
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif /* _SSHCONNECT_H */
87