|
Lines 135-140
cert_option_list(struct sshauthopt *opts, struct sshbuf *oblob,
Link Here
|
| 135 |
opts->force_command = command; |
135 |
opts->force_command = command; |
| 136 |
found = 1; |
136 |
found = 1; |
| 137 |
} |
137 |
} |
|
|
138 |
if (strcmp(name, "chroot-directory") == 0) { |
| 139 |
if ((r = sshbuf_get_cstring(data, &command, |
| 140 |
NULL)) != 0) { |
| 141 |
error("Unable to parse \"%s\" " |
| 142 |
"section: %s", name, ssh_err(r)); |
| 143 |
goto out; |
| 144 |
} |
| 145 |
if (opts->chroot_directory != NULL) { |
| 146 |
error("Certificate has multiple " |
| 147 |
"chroot-directory options"); |
| 148 |
free(command); |
| 149 |
goto out; |
| 150 |
} |
| 151 |
opts->chroot_directory = command; |
| 152 |
found = 1; |
| 153 |
} |
| 138 |
if (strcmp(name, "source-address") == 0) { |
154 |
if (strcmp(name, "source-address") == 0) { |
| 139 |
if ((r = sshbuf_get_cstring(data, &allowed, |
155 |
if ((r = sshbuf_get_cstring(data, &allowed, |
| 140 |
NULL)) != 0) { |
156 |
NULL)) != 0) { |
|
Lines 207-212
sshauthopt_free(struct sshauthopt *opts)
Link Here
|
| 207 |
|
223 |
|
| 208 |
free(opts->cert_principals); |
224 |
free(opts->cert_principals); |
| 209 |
free(opts->force_command); |
225 |
free(opts->force_command); |
|
|
226 |
free(opts->chroot_directory); |
| 210 |
free(opts->required_from_host_cert); |
227 |
free(opts->required_from_host_cert); |
| 211 |
free(opts->required_from_host_keys); |
228 |
free(opts->required_from_host_keys); |
| 212 |
|
229 |
|
|
Lines 364-369
sshauthopt_parse(const char *opts, const char **errstrp)
Link Here
|
| 364 |
ret->force_command = opt_dequote(&opts, &errstr); |
381 |
ret->force_command = opt_dequote(&opts, &errstr); |
| 365 |
if (ret->force_command == NULL) |
382 |
if (ret->force_command == NULL) |
| 366 |
goto fail; |
383 |
goto fail; |
|
|
384 |
} else if (opt_match(&opts, "chroot-directory")) { |
| 385 |
if (ret->chroot_directory != NULL) { |
| 386 |
errstr = "multiple \"chroot-directory\" clauses"; |
| 387 |
goto fail; |
| 388 |
} |
| 389 |
ret->chroot_directory = opt_dequote(&opts, &errstr); |
| 390 |
if (ret->chroot_directory == NULL) |
| 391 |
goto fail; |
| 367 |
} else if (opt_match(&opts, "principals")) { |
392 |
} else if (opt_match(&opts, "principals")) { |
| 368 |
if (ret->cert_principals != NULL) { |
393 |
if (ret->cert_principals != NULL) { |
| 369 |
errstr = "multiple \"principals\" clauses"; |
394 |
errstr = "multiple \"principals\" clauses"; |
|
Lines 614-619
sshauthopt_merge(const struct sshauthopt *primary,
Link Here
|
| 614 |
additional->force_command)) == NULL) |
639 |
additional->force_command)) == NULL) |
| 615 |
goto alloc_fail; |
640 |
goto alloc_fail; |
| 616 |
} |
641 |
} |
|
|
642 |
|
| 643 |
/* |
| 644 |
* When both multiple chroot-directory are specified, only |
| 645 |
* proceed if they are identical, otherwise fail. |
| 646 |
*/ |
| 647 |
if (primary->chroot_directory != NULL && |
| 648 |
additional->chroot_directory != NULL) { |
| 649 |
if (strcmp(primary->chroot_directory, |
| 650 |
additional->chroot_directory) == 0) { |
| 651 |
/* ok */ |
| 652 |
ret->chroot_directory = strdup(primary->chroot_directory); |
| 653 |
if (ret->chroot_directory == NULL) |
| 654 |
goto alloc_fail; |
| 655 |
} else { |
| 656 |
errstr = "chroot directory options do not match"; |
| 657 |
goto fail; |
| 658 |
} |
| 659 |
} else if (primary->chroot_directory != NULL) { |
| 660 |
if ((ret->chroot_directory = strdup( |
| 661 |
primary->chroot_directory)) == NULL) |
| 662 |
goto alloc_fail; |
| 663 |
} else if (additional->chroot_directory != NULL) { |
| 664 |
if ((ret->chroot_directory = strdup( |
| 665 |
additional->chroot_directory)) == NULL) |
| 666 |
goto alloc_fail; |
| 667 |
} |
| 617 |
/* success */ |
668 |
/* success */ |
| 618 |
if (errstrp != NULL) |
669 |
if (errstrp != NULL) |
| 619 |
*errstrp = NULL; |
670 |
*errstrp = NULL; |
|
Lines 660-665
sshauthopt_copy(const struct sshauthopt *orig)
Link Here
|
| 660 |
} while (0) |
711 |
} while (0) |
| 661 |
OPTSTRING(cert_principals); |
712 |
OPTSTRING(cert_principals); |
| 662 |
OPTSTRING(force_command); |
713 |
OPTSTRING(force_command); |
|
|
714 |
OPTSTRING(chroot_directory); |
| 663 |
OPTSTRING(required_from_host_cert); |
715 |
OPTSTRING(required_from_host_cert); |
| 664 |
OPTSTRING(required_from_host_keys); |
716 |
OPTSTRING(required_from_host_keys); |
| 665 |
#undef OPTSTRING |
717 |
#undef OPTSTRING |
|
Lines 799-804
sshauthopt_serialise(const struct sshauthopt *opts, struct sshbuf *m,
Link Here
|
| 799 |
(r = serialise_nullable_string(m, |
851 |
(r = serialise_nullable_string(m, |
| 800 |
untrusted ? "true" : opts->force_command)) != 0 || |
852 |
untrusted ? "true" : opts->force_command)) != 0 || |
| 801 |
(r = serialise_nullable_string(m, |
853 |
(r = serialise_nullable_string(m, |
|
|
854 |
untrusted ? "true" : opts->chroot_directory)) != 0 || |
| 855 |
(r = serialise_nullable_string(m, |
| 802 |
untrusted ? NULL : opts->required_from_host_cert)) != 0 || |
856 |
untrusted ? NULL : opts->required_from_host_cert)) != 0 || |
| 803 |
(r = serialise_nullable_string(m, |
857 |
(r = serialise_nullable_string(m, |
| 804 |
untrusted ? NULL : opts->required_from_host_keys)) != 0) |
858 |
untrusted ? NULL : opts->required_from_host_keys)) != 0) |