1b74df5b2SDag-Erling Smørgrav /* $OpenBSD: sshconnect.h,v 1.18 2005/12/06 22:38:28 reyk Exp $ */ 2ca3176e7SBrian Feldman 3b66f2d16SKris Kennaway /* 4b66f2d16SKris Kennaway * Copyright (c) 2000 Markus Friedl. All rights reserved. 5b66f2d16SKris Kennaway * 6b66f2d16SKris Kennaway * Redistribution and use in source and binary forms, with or without 7b66f2d16SKris Kennaway * modification, are permitted provided that the following conditions 8b66f2d16SKris Kennaway * are met: 9b66f2d16SKris Kennaway * 1. Redistributions of source code must retain the above copyright 10b66f2d16SKris Kennaway * notice, this list of conditions and the following disclaimer. 11b66f2d16SKris Kennaway * 2. Redistributions in binary form must reproduce the above copyright 12b66f2d16SKris Kennaway * notice, this list of conditions and the following disclaimer in the 13b66f2d16SKris Kennaway * documentation and/or other materials provided with the distribution. 14b66f2d16SKris Kennaway * 15b66f2d16SKris Kennaway * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16b66f2d16SKris Kennaway * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17b66f2d16SKris Kennaway * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18b66f2d16SKris Kennaway * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19b66f2d16SKris Kennaway * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20b66f2d16SKris Kennaway * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21b66f2d16SKris Kennaway * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22b66f2d16SKris Kennaway * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23b66f2d16SKris Kennaway * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24b66f2d16SKris Kennaway * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25b66f2d16SKris Kennaway */ 26a04a10f8SKris Kennaway #ifndef SSHCONNECT_H 27a04a10f8SKris Kennaway #define SSHCONNECT_H 28a04a10f8SKris Kennaway 2980628bacSDag-Erling Smørgrav typedef struct Sensitive Sensitive; 3080628bacSDag-Erling Smørgrav struct Sensitive { 3180628bacSDag-Erling Smørgrav Key **keys; 3280628bacSDag-Erling Smørgrav int nkeys; 3380628bacSDag-Erling Smørgrav int external_keysign; 3480628bacSDag-Erling Smørgrav }; 3580628bacSDag-Erling Smørgrav 36ca3176e7SBrian Feldman int 37af12a3e7SDag-Erling Smørgrav ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int, 3880628bacSDag-Erling Smørgrav int, const char *); 39ca3176e7SBrian Feldman 40ca3176e7SBrian Feldman void 4180628bacSDag-Erling Smørgrav ssh_login(Sensitive *, const char *, struct sockaddr *, struct passwd *); 42ca3176e7SBrian Feldman 43af12a3e7SDag-Erling Smørgrav int verify_host_key(char *, struct sockaddr *, Key *); 44a04a10f8SKris Kennaway 45af12a3e7SDag-Erling Smørgrav void ssh_kex(char *, struct sockaddr *); 46af12a3e7SDag-Erling Smørgrav void ssh_kex2(char *, struct sockaddr *); 47ca3176e7SBrian Feldman 4880628bacSDag-Erling Smørgrav void ssh_userauth1(const char *, const char *, char *, Sensitive *); 4980628bacSDag-Erling Smørgrav void ssh_userauth2(const char *, const char *, char *, Sensitive *); 50a04a10f8SKris Kennaway 51af12a3e7SDag-Erling Smørgrav void ssh_put_password(char *); 52b74df5b2SDag-Erling Smørgrav int ssh_local_cmd(const char *); 5380628bacSDag-Erling Smørgrav 5480628bacSDag-Erling Smørgrav /* 5580628bacSDag-Erling Smørgrav * Macros to raise/lower permissions. 5680628bacSDag-Erling Smørgrav */ 5780628bacSDag-Erling Smørgrav #define PRIV_START do { \ 5880628bacSDag-Erling Smørgrav int save_errno = errno; \ 5980628bacSDag-Erling Smørgrav (void)seteuid(original_effective_uid); \ 6080628bacSDag-Erling Smørgrav errno = save_errno; \ 6180628bacSDag-Erling Smørgrav } while (0) 6280628bacSDag-Erling Smørgrav 6380628bacSDag-Erling Smørgrav #define PRIV_END do { \ 6480628bacSDag-Erling Smørgrav int save_errno = errno; \ 6580628bacSDag-Erling Smørgrav (void)seteuid(original_real_uid); \ 6680628bacSDag-Erling Smørgrav errno = save_errno; \ 6780628bacSDag-Erling Smørgrav } while (0) 6880628bacSDag-Erling Smørgrav 69a04a10f8SKris Kennaway #endif 70