2 * Dropbear - a SSH2 server
4 * Copyright (c) 2002,2003 Matt Johnston
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include "chansession.h"
32 void svr_authinitialise();
33 void cli_authinitialise();
35 /* Server functions */
36 void recv_msg_userauth_request();
37 void send_msg_userauth_failure(int partial
, int incrfail
);
38 void send_msg_userauth_success();
39 void send_msg_userauth_banner(buffer
*msg
);
40 void svr_auth_password();
41 void svr_auth_pubkey();
44 #ifdef ENABLE_SVR_PUBKEY_OPTIONS
45 int svr_pubkey_allows_agentfwd();
46 int svr_pubkey_allows_tcpfwd();
47 int svr_pubkey_allows_x11fwd();
48 int svr_pubkey_allows_pty();
49 void svr_pubkey_set_forced_command(struct ChanSess
*chansess
);
50 void svr_pubkey_options_cleanup();
51 int svr_add_pubkey_options(buffer
*options_buf
, int line_num
, const char* filename
);
53 /* no option : success */
54 #define svr_pubkey_allows_agentfwd() 1
55 #define svr_pubkey_allows_tcpfwd() 1
56 #define svr_pubkey_allows_x11fwd() 1
57 #define svr_pubkey_allows_pty() 1
58 static inline void svr_pubkey_set_forced_command(struct ChanSess
*chansess
) { }
59 static inline void svr_pubkey_options_cleanup() { }
60 #define svr_add_pubkey_options(x,y,z) DROPBEAR_SUCCESS
63 /* Client functions */
64 void recv_msg_userauth_failure();
65 void recv_msg_userauth_success();
66 void recv_msg_userauth_specific_60();
67 void recv_msg_userauth_pk_ok();
68 void recv_msg_userauth_info_request();
70 void cli_auth_getmethods();
72 void recv_msg_userauth_banner();
73 void cli_pubkeyfail();
74 void cli_auth_password();
75 int cli_auth_pubkey();
76 void cli_auth_interactive();
77 char* getpass_or_cancel(char* prompt
);
78 void cli_auth_pubkey_cleanup();
81 #define MAX_USERNAME_LEN 25 /* arbitrary for the moment */
83 #define AUTH_TYPE_NONE 1
84 #define AUTH_TYPE_PUBKEY 1 << 1
85 #define AUTH_TYPE_PASSWORD 1 << 2
86 #define AUTH_TYPE_INTERACT 1 << 3
88 #define AUTH_METHOD_NONE "none"
89 #define AUTH_METHOD_NONE_LEN 4
90 #define AUTH_METHOD_PUBKEY "publickey"
91 #define AUTH_METHOD_PUBKEY_LEN 9
92 #define AUTH_METHOD_PASSWORD "password"
93 #define AUTH_METHOD_PASSWORD_LEN 8
94 #define AUTH_METHOD_INTERACT "keyboard-interactive"
95 #define AUTH_METHOD_INTERACT_LEN 20
99 /* This structure is shared between server and client - it contains
100 * relatively little extraneous bits when used for the client rather than the
103 char *username
; /* This is the username the client presents to check. It
104 is updated each run through, used for auth checking */
105 unsigned char authtypes
; /* Flags indicating which auth types are still
107 unsigned int failcount
; /* Number of (failed) authentication attempts.*/
108 unsigned authdone
: 1; /* 0 if we haven't authed, 1 if we have. Applies for
109 client and server (though has differing
111 unsigned perm_warn
: 1; /* Server only, set if bad permissions on
112 ~/.ssh/authorized_keys have already been
115 /* These are only used for the server */
122 #ifdef ENABLE_SVR_PUBKEY_OPTIONS
123 struct PubKeyOptions
* pubkey_options
;
127 #ifdef ENABLE_SVR_PUBKEY_OPTIONS
128 struct PubKeyOptions
;
129 struct PubKeyOptions
{
131 int no_port_forwarding_flag
;
132 int no_agent_forwarding_flag
;
133 int no_x11_forwarding_flag
;
135 /* "command=" option. */
136 unsigned char * forced_command
;
140 #endif /* _AUTH_H_ */