libsodium: Needed for Dnscrypto-proxy Release 1.3.0
[tomato.git] / release / src / router / dropbear / auth.h
blob0fd9c73e18d28d7c9c279dcbca5316b109ef8b55
1 /*
2 * Dropbear - a SSH2 server
3 *
4 * Copyright (c) 2002,2003 Matt Johnston
5 * All rights reserved.
6 *
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
23 * SOFTWARE. */
25 #ifndef _AUTH_H_
26 #define _AUTH_H_
28 #include "includes.h"
29 #include "signkey.h"
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 svr_auth_password();
40 void svr_auth_pubkey();
41 void svr_auth_pam();
43 #ifdef ENABLE_SVR_PUBKEY_OPTIONS
44 int svr_pubkey_allows_agentfwd();
45 int svr_pubkey_allows_tcpfwd();
46 int svr_pubkey_allows_x11fwd();
47 int svr_pubkey_allows_pty();
48 void svr_pubkey_set_forced_command(struct ChanSess *chansess);
49 void svr_pubkey_options_cleanup();
50 int svr_add_pubkey_options(buffer *options_buf, int line_num, const char* filename);
51 #else
52 /* no option : success */
53 #define svr_pubkey_allows_agentfwd() 1
54 #define svr_pubkey_allows_tcpfwd() 1
55 #define svr_pubkey_allows_x11fwd() 1
56 #define svr_pubkey_allows_pty() 1
57 static inline void svr_pubkey_set_forced_command(struct ChanSess *chansess) { }
58 static inline void svr_pubkey_options_cleanup() { }
59 #define svr_add_pubkey_options(x,y,z) DROPBEAR_SUCCESS
60 #endif
62 /* Client functions */
63 void recv_msg_userauth_failure();
64 void recv_msg_userauth_success();
65 void recv_msg_userauth_specific_60();
66 void recv_msg_userauth_pk_ok();
67 void recv_msg_userauth_info_request();
68 void cli_get_user();
69 void cli_auth_getmethods();
70 void cli_auth_try();
71 void recv_msg_userauth_banner();
72 void cli_pubkeyfail();
73 void cli_auth_password();
74 int cli_auth_pubkey();
75 void cli_auth_interactive();
76 char* getpass_or_cancel(char* prompt);
77 void cli_auth_pubkey_cleanup();
80 #define MAX_USERNAME_LEN 25 /* arbitrary for the moment */
82 #define AUTH_TYPE_NONE 1
83 #define AUTH_TYPE_PUBKEY 1 << 1
84 #define AUTH_TYPE_PASSWORD 1 << 2
85 #define AUTH_TYPE_INTERACT 1 << 3
87 #define AUTH_METHOD_NONE "none"
88 #define AUTH_METHOD_NONE_LEN 4
89 #define AUTH_METHOD_PUBKEY "publickey"
90 #define AUTH_METHOD_PUBKEY_LEN 9
91 #define AUTH_METHOD_PASSWORD "password"
92 #define AUTH_METHOD_PASSWORD_LEN 8
93 #define AUTH_METHOD_INTERACT "keyboard-interactive"
94 #define AUTH_METHOD_INTERACT_LEN 20
98 /* This structure is shared between server and client - it contains
99 * relatively little extraneous bits when used for the client rather than the
100 * server */
101 struct AuthState {
102 char *username; /* This is the username the client presents to check. It
103 is updated each run through, used for auth checking */
104 unsigned char authtypes; /* Flags indicating which auth types are still
105 valid */
106 unsigned int failcount; /* Number of (failed) authentication attempts.*/
107 unsigned authdone : 1; /* 0 if we haven't authed, 1 if we have. Applies for
108 client and server (though has differing [obvious]
109 meanings). */
110 unsigned perm_warn : 1; /* Server only, set if bad permissions on
111 ~/.ssh/authorized_keys have already been
112 logged. */
114 /* These are only used for the server */
115 uid_t pw_uid;
116 gid_t pw_gid;
117 char *pw_dir;
118 char *pw_shell;
119 char *pw_name;
120 char *pw_passwd;
121 #ifdef ENABLE_SVR_PUBKEY_OPTIONS
122 struct PubKeyOptions* pubkey_options;
123 #endif
126 #ifdef ENABLE_SVR_PUBKEY_OPTIONS
127 struct PubKeyOptions;
128 struct PubKeyOptions {
129 /* Flags */
130 int no_port_forwarding_flag;
131 int no_agent_forwarding_flag;
132 int no_x11_forwarding_flag;
133 int no_pty_flag;
134 /* "command=" option. */
135 unsigned char * forced_command;
137 #endif
139 #endif /* _AUTH_H_ */