| 502 | } |
| 503 | |
| 504 | void credential_fill(struct repository *r, |
| 505 | struct credential *c, int all_capabilities) |
| 506 | { |
| 507 | int i; |
| 508 | |
| 509 | if ((c->username && c->password) || c->credential) |
| 510 | return; |
| 511 | |
| 512 | credential_next_state(c); |
| 513 | c->multistage = 0; |
| 514 | |
| 515 | credential_apply_config(r, c); |
| 516 | if (all_capabilities) |
| 517 | credential_set_all_capabilities(c, CREDENTIAL_OP_INITIAL); |
| 518 | |
| 519 | for (i = 0; i < c->helpers.nr; i++) { |
| 520 | credential_do(c, c->helpers.items[i].string, "get"); |
| 521 | |
| 522 | if (c->password_expiry_utc < time(NULL)) { |
| 523 | /* |
| 524 | * Don't use credential_clear() here: callers such as |
| 525 | * cmd_credential() expect to still be able to call |
| 526 | * credential_write() on a struct credential whose |
| 527 | * secrets have expired. |
| 528 | */ |
| 529 | credential_clear_secrets(c); |
| 530 | /* Reset expiry to maintain consistency */ |
| 531 | c->password_expiry_utc = TIME_MAX; |
| 532 | } |
| 533 | if ((c->username && c->password) || c->credential) { |
| 534 | strvec_clear(&c->wwwauth_headers); |
| 535 | return; |
| 536 | } |
| 537 | if (c->quit) |
| 538 | die("credential helper '%s' told us to quit", |
| 539 | c->helpers.items[i].string); |
| 540 | } |
| 541 | |
| 542 | if (credential_getpass(r, c) || |
| 543 | (!c->username && !c->password && !c->credential)) |
| 544 | die("unable to get password from user"); |
| 545 | } |
| 546 | |
| 547 | void credential_approve(struct repository *r, struct credential *c) |
| 548 | { |
no test coverage detected