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