17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright (c) 2000 Markus Friedl. All rights reserved. 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 57c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions 67c478bd9Sstevel@tonic-gate * are met: 77c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 87c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 97c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 107c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 117c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 147c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 157c478bd9Sstevel@tonic-gate * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 167c478bd9Sstevel@tonic-gate * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 177c478bd9Sstevel@tonic-gate * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 187c478bd9Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 197c478bd9Sstevel@tonic-gate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 207c478bd9Sstevel@tonic-gate * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 217c478bd9Sstevel@tonic-gate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 227c478bd9Sstevel@tonic-gate * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 237c478bd9Sstevel@tonic-gate */ 24*b9aa66a7SJan Pechanec /* 25*b9aa66a7SJan Pechanec * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 26*b9aa66a7SJan Pechanec * Use is subject to license terms. 27*b9aa66a7SJan Pechanec */ 28*b9aa66a7SJan Pechanec 29*b9aa66a7SJan Pechanec /* $OpenBSD: sshconnect.h,v 1.17 2002/06/19 00:27:55 deraadt Exp $ */ 30*b9aa66a7SJan Pechanec 31*b9aa66a7SJan Pechanec #ifndef _SSHCONNECT_H 32*b9aa66a7SJan Pechanec #define _SSHCONNECT_H 33*b9aa66a7SJan Pechanec 34*b9aa66a7SJan Pechanec #ifdef __cplusplus 35*b9aa66a7SJan Pechanec extern "C" { 36*b9aa66a7SJan Pechanec #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate typedef struct Sensitive Sensitive; 397c478bd9Sstevel@tonic-gate struct Sensitive { 407c478bd9Sstevel@tonic-gate Key **keys; 417c478bd9Sstevel@tonic-gate int nkeys; 427c478bd9Sstevel@tonic-gate int external_keysign; 437c478bd9Sstevel@tonic-gate }; 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate int 46*b9aa66a7SJan Pechanec ssh_connect(const char *, struct sockaddr_storage *, ushort_t, int, int, 477c478bd9Sstevel@tonic-gate int, const char *); 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate void 50*b9aa66a7SJan Pechanec ssh_login(Sensitive *, const char *, struct sockaddr *, char *); 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate int verify_host_key(char *, struct sockaddr *, Key *); 537c478bd9Sstevel@tonic-gate int accept_host_key(char *, struct sockaddr *, Key *); 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate void ssh_kex(char *, struct sockaddr *); 567c478bd9Sstevel@tonic-gate void ssh_kex2(char *, struct sockaddr *); 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate void ssh_userauth1(const char *, const char *, char *, Sensitive *); 597c478bd9Sstevel@tonic-gate void ssh_userauth2(const char *, const char *, char *, Sensitive *); 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate void ssh_put_password(char *); 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * Macros to raise/lower permissions. 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate #define PRIV_START do { \ 687c478bd9Sstevel@tonic-gate int save_errno = errno; \ 697c478bd9Sstevel@tonic-gate (void) seteuid(original_effective_uid); \ 707c478bd9Sstevel@tonic-gate errno = save_errno; \ 717c478bd9Sstevel@tonic-gate } while (0) 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #define PRIV_END do { \ 747c478bd9Sstevel@tonic-gate int save_errno = errno; \ 757c478bd9Sstevel@tonic-gate (void) seteuid(original_real_uid); \ 767c478bd9Sstevel@tonic-gate errno = save_errno; \ 777c478bd9Sstevel@tonic-gate } while (0) 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate #ifdef __cplusplus 807c478bd9Sstevel@tonic-gate } 817c478bd9Sstevel@tonic-gate #endif 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate #endif /* _SSHCONNECT_H */ 84