|
Lines 248-253
struct identity {
Link Here
|
| 248 |
char *filename; /* comment for agent-only keys */ |
248 |
char *filename; /* comment for agent-only keys */ |
| 249 |
int tried; |
249 |
int tried; |
| 250 |
int isprivate; /* key points to the private key */ |
250 |
int isprivate; /* key points to the private key */ |
|
|
251 |
int userprovided; |
| 251 |
}; |
252 |
}; |
| 252 |
TAILQ_HEAD(idlist, identity); |
253 |
TAILQ_HEAD(idlist, identity); |
| 253 |
|
254 |
|
|
Lines 312-318
void userauth(Authctxt *, char *);
Link Here
|
| 312 |
static int sign_and_send_pubkey(Authctxt *, Identity *); |
313 |
static int sign_and_send_pubkey(Authctxt *, Identity *); |
| 313 |
static void pubkey_prepare(Authctxt *); |
314 |
static void pubkey_prepare(Authctxt *); |
| 314 |
static void pubkey_cleanup(Authctxt *); |
315 |
static void pubkey_cleanup(Authctxt *); |
| 315 |
static Key *load_identity_file(char *); |
316 |
static Key *load_identity_file(char *, int); |
| 316 |
|
317 |
|
| 317 |
static Authmethod *authmethod_get(char *authlist); |
318 |
static Authmethod *authmethod_get(char *authlist); |
| 318 |
static Authmethod *authmethod_lookup(const char *name); |
319 |
static Authmethod *authmethod_lookup(const char *name); |
|
Lines 1186-1192
identity_sign(Identity *id, u_char **sig
Link Here
|
| 1186 |
if (id->isprivate || (id->key->flags & KEY_FLAG_EXT)) |
1187 |
if (id->isprivate || (id->key->flags & KEY_FLAG_EXT)) |
| 1187 |
return (key_sign(id->key, sigp, lenp, data, datalen)); |
1188 |
return (key_sign(id->key, sigp, lenp, data, datalen)); |
| 1188 |
/* load the private key from the file */ |
1189 |
/* load the private key from the file */ |
| 1189 |
if ((prv = load_identity_file(id->filename)) == NULL) |
1190 |
if ((prv = load_identity_file(id->filename, id->userprovided)) == NULL) |
| 1190 |
return (-1); |
1191 |
return (-1); |
| 1191 |
ret = key_sign(prv, sigp, lenp, data, datalen); |
1192 |
ret = key_sign(prv, sigp, lenp, data, datalen); |
| 1192 |
key_free(prv); |
1193 |
key_free(prv); |
|
Lines 1311-1317
send_pubkey_test(Authctxt *authctxt, Ide
Link Here
|
| 1311 |
} |
1312 |
} |
| 1312 |
|
1313 |
|
| 1313 |
static Key * |
1314 |
static Key * |
| 1314 |
load_identity_file(char *filename) |
1315 |
load_identity_file(char *filename, int userprovided) |
| 1315 |
{ |
1316 |
{ |
| 1316 |
Key *private; |
1317 |
Key *private; |
| 1317 |
char prompt[300], *passphrase; |
1318 |
char prompt[300], *passphrase; |
|
Lines 1319-1325
load_identity_file(char *filename)
Link Here
|
| 1319 |
struct stat st; |
1320 |
struct stat st; |
| 1320 |
|
1321 |
|
| 1321 |
if (stat(filename, &st) < 0) { |
1322 |
if (stat(filename, &st) < 0) { |
| 1322 |
debug3("no such identity: %s", filename); |
1323 |
if (userprovided) |
|
|
1324 |
logit("no such identity: %s: %s", filename, |
| 1325 |
strerror(errno)); |
| 1326 |
else |
| 1327 |
debug3("no such identity: %s: %s", filename, |
| 1328 |
strerror(errno)); |
| 1323 |
return NULL; |
1329 |
return NULL; |
| 1324 |
} |
1330 |
} |
| 1325 |
private = key_load_private_type(KEY_UNSPEC, filename, "", NULL, &perm_ok); |
1331 |
private = key_load_private_type(KEY_UNSPEC, filename, "", NULL, &perm_ok); |
|
Lines 1382-1387
pubkey_prepare(Authctxt *authctxt)
Link Here
|
| 1382 |
id = xcalloc(1, sizeof(*id)); |
1388 |
id = xcalloc(1, sizeof(*id)); |
| 1383 |
id->key = key; |
1389 |
id->key = key; |
| 1384 |
id->filename = xstrdup(options.identity_files[i]); |
1390 |
id->filename = xstrdup(options.identity_files[i]); |
|
|
1391 |
id->userprovided = 1; |
| 1385 |
TAILQ_INSERT_TAIL(&files, id, next); |
1392 |
TAILQ_INSERT_TAIL(&files, id, next); |
| 1386 |
} |
1393 |
} |
| 1387 |
/* list of keys supported by the agent */ |
1394 |
/* list of keys supported by the agent */ |
|
Lines 1423-1429
pubkey_prepare(Authctxt *authctxt)
Link Here
|
| 1423 |
TAILQ_INSERT_TAIL(preferred, id, next); |
1430 |
TAILQ_INSERT_TAIL(preferred, id, next); |
| 1424 |
} |
1431 |
} |
| 1425 |
TAILQ_FOREACH(id, preferred, next) { |
1432 |
TAILQ_FOREACH(id, preferred, next) { |
| 1426 |
debug2("key: %s (%p)", id->filename, id->key); |
1433 |
debug2("key: %s (%p), userprovided %d", id->filename, id->key, |
|
|
1434 |
id->userprovided); |
| 1427 |
} |
1435 |
} |
| 1428 |
} |
1436 |
} |
| 1429 |
|
1437 |
|
|
Lines 1468-1474
userauth_pubkey(Authctxt *authctxt)
Link Here
|
| 1468 |
sent = send_pubkey_test(authctxt, id); |
1476 |
sent = send_pubkey_test(authctxt, id); |
| 1469 |
} else if (id->key == NULL) { |
1477 |
} else if (id->key == NULL) { |
| 1470 |
debug("Trying private key: %s", id->filename); |
1478 |
debug("Trying private key: %s", id->filename); |
| 1471 |
id->key = load_identity_file(id->filename); |
1479 |
id->key = load_identity_file(id->filename, |
|
|
1480 |
id->userprovided); |
| 1472 |
if (id->key != NULL) { |
1481 |
if (id->key != NULL) { |
| 1473 |
id->isprivate = 1; |
1482 |
id->isprivate = 1; |
| 1474 |
sent = sign_and_send_pubkey(authctxt, id); |
1483 |
sent = sign_and_send_pubkey(authctxt, id); |