summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2013-04-23 15:17:52 +1000
committerDamien Miller <djm@mindrot.org>2013-04-23 15:17:52 +1000
commit4ce189d9108c62090a0dd5dea973d175328440db (patch)
tree94f59288486756c522514572f4d9962e865790b2 /monitor.c
parent5cbec4c25954b184e43bf3d3ac09e65eb474f5f9 (diff)
- djm@cvs.openbsd.org 2013/03/07 00:19:59
[auth2-pubkey.c monitor.c] reconstruct the original username that was sent by the client, which may have included a style (e.g. "root:skey") when checking public key signatures. Fixes public key and hostbased auth when the client specified a style; ok markus@
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/monitor.c b/monitor.c
index 6560740b6..34d7e1805 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor.c,v 1.120 2012/12/11 22:16:21 markus Exp $ */ 1/* $OpenBSD: monitor.c,v 1.121 2013/03/07 00:19:59 djm Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -1237,7 +1237,7 @@ static int
1237monitor_valid_userblob(u_char *data, u_int datalen) 1237monitor_valid_userblob(u_char *data, u_int datalen)
1238{ 1238{
1239 Buffer b; 1239 Buffer b;
1240 char *p; 1240 char *p, *userstyle;
1241 u_int len; 1241 u_int len;
1242 int fail = 0; 1242 int fail = 0;
1243 1243
@@ -1262,19 +1262,23 @@ monitor_valid_userblob(u_char *data, u_int datalen)
1262 } 1262 }
1263 if (buffer_get_char(&b) != SSH2_MSG_USERAUTH_REQUEST) 1263 if (buffer_get_char(&b) != SSH2_MSG_USERAUTH_REQUEST)
1264 fail++; 1264 fail++;
1265 p = buffer_get_string(&b, NULL); 1265 p = buffer_get_cstring(&b, NULL);
1266 if (strcmp(authctxt->user, p) != 0) { 1266 xasprintf(&userstyle, "%s%s%s", authctxt->user,
1267 authctxt->style ? ":" : "",
1268 authctxt->style ? authctxt->style : "");
1269 if (strcmp(userstyle, p) != 0) {
1267 logit("wrong user name passed to monitor: expected %s != %.100s", 1270 logit("wrong user name passed to monitor: expected %s != %.100s",
1268 authctxt->user, p); 1271 userstyle, p);
1269 fail++; 1272 fail++;
1270 } 1273 }
1274 xfree(userstyle);
1271 xfree(p); 1275 xfree(p);
1272 buffer_skip_string(&b); 1276 buffer_skip_string(&b);
1273 if (datafellows & SSH_BUG_PKAUTH) { 1277 if (datafellows & SSH_BUG_PKAUTH) {
1274 if (!buffer_get_char(&b)) 1278 if (!buffer_get_char(&b))
1275 fail++; 1279 fail++;
1276 } else { 1280 } else {
1277 p = buffer_get_string(&b, NULL); 1281 p = buffer_get_cstring(&b, NULL);
1278 if (strcmp("publickey", p) != 0) 1282 if (strcmp("publickey", p) != 0)
1279 fail++; 1283 fail++;
1280 xfree(p); 1284 xfree(p);
@@ -1294,7 +1298,7 @@ monitor_valid_hostbasedblob(u_char *data, u_int datalen, char *cuser,
1294 char *chost) 1298 char *chost)
1295{ 1299{
1296 Buffer b; 1300 Buffer b;
1297 char *p; 1301 char *p, *userstyle;
1298 u_int len; 1302 u_int len;
1299 int fail = 0; 1303 int fail = 0;
1300 1304
@@ -1310,15 +1314,19 @@ monitor_valid_hostbasedblob(u_char *data, u_int datalen, char *cuser,
1310 1314
1311 if (buffer_get_char(&b) != SSH2_MSG_USERAUTH_REQUEST) 1315 if (buffer_get_char(&b) != SSH2_MSG_USERAUTH_REQUEST)
1312 fail++; 1316 fail++;
1313 p = buffer_get_string(&b, NULL); 1317 p = buffer_get_cstring(&b, NULL);
1314 if (strcmp(authctxt->user, p) != 0) { 1318 xasprintf(&userstyle, "%s%s%s", authctxt->user,
1319 authctxt->style ? ":" : "",
1320 authctxt->style ? authctxt->style : "");
1321 if (strcmp(userstyle, p) != 0) {
1315 logit("wrong user name passed to monitor: expected %s != %.100s", 1322 logit("wrong user name passed to monitor: expected %s != %.100s",
1316 authctxt->user, p); 1323 userstyle, p);
1317 fail++; 1324 fail++;
1318 } 1325 }
1326 free(userstyle);
1319 xfree(p); 1327 xfree(p);
1320 buffer_skip_string(&b); /* service */ 1328 buffer_skip_string(&b); /* service */
1321 p = buffer_get_string(&b, NULL); 1329 p = buffer_get_cstring(&b, NULL);
1322 if (strcmp(p, "hostbased") != 0) 1330 if (strcmp(p, "hostbased") != 0)
1323 fail++; 1331 fail++;
1324 xfree(p); 1332 xfree(p);