summaryrefslogtreecommitdiff
path: root/auth2.c
diff options
context:
space:
mode:
Diffstat (limited to 'auth2.c')
-rw-r--r--auth2.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/auth2.c b/auth2.c
index e77358a3b..3d997f45b 100644
--- a/auth2.c
+++ b/auth2.c
@@ -27,7 +27,7 @@
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29#include "includes.h" 29#include "includes.h"
30RCSID("$OpenBSD: auth2.c,v 1.5 2000/05/01 23:13:39 djm Exp $"); 30RCSID("$OpenBSD: auth2.c,v 1.7 2000/05/06 17:45:36 markus Exp $");
31 31
32#include <openssl/dsa.h> 32#include <openssl/dsa.h>
33#include <openssl/rsa.h> 33#include <openssl/rsa.h>
@@ -188,9 +188,29 @@ input_userauth_request(int type, int plen)
188 authenticated = 0; 188 authenticated = 0;
189#endif /* USE_PAM */ 189#endif /* USE_PAM */
190 190
191 /* XXX todo: check if multiple auth methods are needed */ 191 /* Raise logging level */
192 if (authenticated == 1 ||
193 attempt == AUTH_FAIL_LOG ||
194 strcmp(method, "password") == 0)
195 authlog = log;
196
197 /* Log before sending the reply */
192 if (authenticated == 1) { 198 if (authenticated == 1) {
193 authmsg = "Accepted"; 199 authmsg = "Accepted";
200 } else if (authenticated == 0) {
201 authmsg = "Failed";
202 } else {
203 authmsg = "Postponed";
204 }
205 authlog("%s %s for %.200s from %.200s port %d ssh2",
206 authmsg,
207 method,
208 pw && pw->pw_uid == 0 ? "ROOT" : user,
209 get_remote_ipaddr(),
210 get_remote_port());
211
212 /* XXX todo: check if multiple auth methods are needed */
213 if (authenticated == 1) {
194 /* turn off userauth */ 214 /* turn off userauth */
195 dispatch_set(SSH2_MSG_USERAUTH_REQUEST, &protocol_error); 215 dispatch_set(SSH2_MSG_USERAUTH_REQUEST, &protocol_error);
196 packet_start(SSH2_MSG_USERAUTH_SUCCESS); 216 packet_start(SSH2_MSG_USERAUTH_SUCCESS);
@@ -199,27 +219,12 @@ input_userauth_request(int type, int plen)
199 /* now we can break out */ 219 /* now we can break out */
200 userauth_success = 1; 220 userauth_success = 1;
201 } else if (authenticated == 0) { 221 } else if (authenticated == 0) {
202 authmsg = "Failed";
203 packet_start(SSH2_MSG_USERAUTH_FAILURE); 222 packet_start(SSH2_MSG_USERAUTH_FAILURE);
204 packet_put_cstring("publickey,password"); /* XXX dynamic */ 223 packet_put_cstring("publickey,password"); /* XXX dynamic */
205 packet_put_char(0); /* XXX partial success, unused */ 224 packet_put_char(0); /* XXX partial success, unused */
206 packet_send(); 225 packet_send();
207 packet_write_wait(); 226 packet_write_wait();
208 } else {
209 authmsg = "Postponed";
210 } 227 }
211 /* Raise logging level */
212 if (authenticated == 1||
213 attempt == AUTH_FAIL_LOG ||
214 strcmp(method, "password") == 0)
215 authlog = log;
216
217 authlog("%s %s for %.200s from %.200s port %d ssh2",
218 authmsg,
219 method,
220 pw && pw->pw_uid == 0 ? "ROOT" : user,
221 get_remote_ipaddr(),
222 get_remote_port());
223 228
224 xfree(service); 229 xfree(service);
225 xfree(user); 230 xfree(user);
@@ -269,7 +274,7 @@ ssh2_auth_pubkey(struct passwd *pw, unsigned char *raw, unsigned int rlen)
269 int have_sig; 274 int have_sig;
270 int authenticated = 0; 275 int authenticated = 0;
271 276
272 if (options.rsa_authentication == 0) { 277 if (options.dsa_authentication == 0) {
273 debug("pubkey auth disabled"); 278 debug("pubkey auth disabled");
274 return 0; 279 return 0;
275 } 280 }
@@ -306,6 +311,13 @@ ssh2_auth_pubkey(struct passwd *pw, unsigned char *raw, unsigned int rlen)
306 debug("test key..."); 311 debug("test key...");
307 /* test whether pkalg/pkblob are acceptable */ 312 /* test whether pkalg/pkblob are acceptable */
308 /* XXX fake reply and always send PK_OK ? */ 313 /* XXX fake reply and always send PK_OK ? */
314 /*
315 * XXX this allows testing whether a user is allowed
316 * to login: if you happen to have a valid pubkey this
317 * message is sent. the message is NEVER sent at all
318 * if a user is not allowed to login. is this an
319 * issue? -markus
320 */
309 if (user_dsa_key_allowed(pw, key)) { 321 if (user_dsa_key_allowed(pw, key)) {
310 packet_start(SSH2_MSG_USERAUTH_PK_OK); 322 packet_start(SSH2_MSG_USERAUTH_PK_OK);
311 packet_put_string(pkalg, alen); 323 packet_put_string(pkalg, alen);