1*4a421b63SDag-Erling Smørgrav /* $OpenBSD: sshconnect.h,v 1.27 2010/11/29 23:45:51 djm 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 2780628bacSDag-Erling Smørgrav typedef struct Sensitive Sensitive; 2880628bacSDag-Erling Smørgrav struct Sensitive { 2980628bacSDag-Erling Smørgrav Key **keys; 3080628bacSDag-Erling Smørgrav int nkeys; 3180628bacSDag-Erling Smørgrav int external_keysign; 3280628bacSDag-Erling Smørgrav }; 3380628bacSDag-Erling Smørgrav 34ca3176e7SBrian Feldman int 35af12a3e7SDag-Erling Smørgrav ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int, 36d4af9e69SDag-Erling Smørgrav int *, int, int, const char *); 37*4a421b63SDag-Erling Smørgrav void ssh_kill_proxy_command(void); 38ca3176e7SBrian Feldman 39*4a421b63SDag-Erling Smørgrav void ssh_login(Sensitive *, const char *, struct sockaddr *, u_short, 40*4a421b63SDag-Erling Smørgrav struct passwd *, int); 41ca3176e7SBrian Feldman 427aee6ffeSDag-Erling Smørgrav void ssh_exchange_identification(int); 437aee6ffeSDag-Erling Smørgrav 44af12a3e7SDag-Erling Smørgrav int verify_host_key(char *, struct sockaddr *, Key *); 45a04a10f8SKris Kennaway 46*4a421b63SDag-Erling Smørgrav void get_hostfile_hostname_ipaddr(char *, struct sockaddr *, u_short, 47*4a421b63SDag-Erling Smørgrav char **, char **); 48*4a421b63SDag-Erling Smørgrav 49af12a3e7SDag-Erling Smørgrav void ssh_kex(char *, struct sockaddr *); 50*4a421b63SDag-Erling Smørgrav void ssh_kex2(char *, struct sockaddr *, u_short); 51ca3176e7SBrian Feldman 5280628bacSDag-Erling Smørgrav void ssh_userauth1(const char *, const char *, char *, Sensitive *); 5380628bacSDag-Erling Smørgrav void ssh_userauth2(const char *, const char *, char *, Sensitive *); 54a04a10f8SKris Kennaway 55af12a3e7SDag-Erling Smørgrav void ssh_put_password(char *); 56b74df5b2SDag-Erling Smørgrav int ssh_local_cmd(const char *); 5780628bacSDag-Erling Smørgrav 5880628bacSDag-Erling Smørgrav /* 5980628bacSDag-Erling Smørgrav * Macros to raise/lower permissions. 6080628bacSDag-Erling Smørgrav */ 6180628bacSDag-Erling Smørgrav #define PRIV_START do { \ 6280628bacSDag-Erling Smørgrav int save_errno = errno; \ 63333ee039SDag-Erling Smørgrav if (seteuid(original_effective_uid) != 0) \ 64333ee039SDag-Erling Smørgrav fatal("PRIV_START: seteuid: %s", \ 65333ee039SDag-Erling Smørgrav strerror(errno)); \ 6680628bacSDag-Erling Smørgrav errno = save_errno; \ 6780628bacSDag-Erling Smørgrav } while (0) 6880628bacSDag-Erling Smørgrav 6980628bacSDag-Erling Smørgrav #define PRIV_END do { \ 7080628bacSDag-Erling Smørgrav int save_errno = errno; \ 71333ee039SDag-Erling Smørgrav if (seteuid(original_real_uid) != 0) \ 72333ee039SDag-Erling Smørgrav fatal("PRIV_END: seteuid: %s", \ 73333ee039SDag-Erling Smørgrav strerror(errno)); \ 7480628bacSDag-Erling Smørgrav errno = save_errno; \ 7580628bacSDag-Erling Smørgrav } while (0) 76