diff options
Diffstat (limited to 'servconf.c')
-rw-r--r-- | servconf.c | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/servconf.c b/servconf.c index daed26a66..74710c41f 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: servconf.c,v 1.218 2011/05/20 03:25:45 djm Exp $ */ | 1 | /* $OpenBSD: servconf.c,v 1.219 2011/05/23 03:30:07 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
4 | * All rights reserved | 4 | * All rights reserved |
@@ -126,7 +126,7 @@ initialize_server_options(ServerOptions *options) | |||
126 | options->use_dns = -1; | 126 | options->use_dns = -1; |
127 | options->client_alive_interval = -1; | 127 | options->client_alive_interval = -1; |
128 | options->client_alive_count_max = -1; | 128 | options->client_alive_count_max = -1; |
129 | options->authorized_keys_file = NULL; | 129 | options->num_authkeys_files = 0; |
130 | options->num_accept_env = 0; | 130 | options->num_accept_env = 0; |
131 | options->permit_tun = -1; | 131 | options->permit_tun = -1; |
132 | options->num_permitted_opens = -1; | 132 | options->num_permitted_opens = -1; |
@@ -263,8 +263,12 @@ fill_default_server_options(ServerOptions *options) | |||
263 | options->client_alive_interval = 0; | 263 | options->client_alive_interval = 0; |
264 | if (options->client_alive_count_max == -1) | 264 | if (options->client_alive_count_max == -1) |
265 | options->client_alive_count_max = 3; | 265 | options->client_alive_count_max = 3; |
266 | if (options->authorized_keys_file == NULL) | 266 | if (options->num_authkeys_files == 0) { |
267 | options->authorized_keys_file = xstrdup(_PATH_SSH_USER_PERMITTED_KEYS); | 267 | options->authorized_keys_files[options->num_authkeys_files++] = |
268 | xstrdup(_PATH_SSH_USER_PERMITTED_KEYS); | ||
269 | options->authorized_keys_files[options->num_authkeys_files++] = | ||
270 | xstrdup(_PATH_SSH_USER_PERMITTED_KEYS2); | ||
271 | } | ||
268 | if (options->permit_tun == -1) | 272 | if (options->permit_tun == -1) |
269 | options->permit_tun = SSH_TUNMODE_NO; | 273 | options->permit_tun = SSH_TUNMODE_NO; |
270 | if (options->zero_knowledge_password_authentication == -1) | 274 | if (options->zero_knowledge_password_authentication == -1) |
@@ -430,6 +434,7 @@ static struct { | |||
430 | { "clientaliveinterval", sClientAliveInterval, SSHCFG_GLOBAL }, | 434 | { "clientaliveinterval", sClientAliveInterval, SSHCFG_GLOBAL }, |
431 | { "clientalivecountmax", sClientAliveCountMax, SSHCFG_GLOBAL }, | 435 | { "clientalivecountmax", sClientAliveCountMax, SSHCFG_GLOBAL }, |
432 | { "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_ALL }, | 436 | { "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_ALL }, |
437 | { "authorizedkeysfile2", sDeprecated, SSHCFG_ALL }, | ||
433 | { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL}, | 438 | { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL}, |
434 | { "acceptenv", sAcceptEnv, SSHCFG_GLOBAL }, | 439 | { "acceptenv", sAcceptEnv, SSHCFG_GLOBAL }, |
435 | { "permittunnel", sPermitTunnel, SSHCFG_ALL }, | 440 | { "permittunnel", sPermitTunnel, SSHCFG_ALL }, |
@@ -1241,11 +1246,22 @@ process_server_config_line(ServerOptions *options, char *line, | |||
1241 | * AuthorizedKeysFile /etc/ssh_keys/%u | 1246 | * AuthorizedKeysFile /etc/ssh_keys/%u |
1242 | */ | 1247 | */ |
1243 | case sAuthorizedKeysFile: | 1248 | case sAuthorizedKeysFile: |
1244 | charptr = &options->authorized_keys_file; | 1249 | if (*activep && options->num_authkeys_files == 0) { |
1245 | goto parse_tilde_filename; | 1250 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
1251 | if (options->num_authkeys_files >= | ||
1252 | MAX_AUTHKEYS_FILES) | ||
1253 | fatal("%s line %d: " | ||
1254 | "too many authorized keys files.", | ||
1255 | filename, linenum); | ||
1256 | options->authorized_keys_files[ | ||
1257 | options->num_authkeys_files++] = | ||
1258 | tilde_expand_filename(arg, getuid()); | ||
1259 | } | ||
1260 | } | ||
1261 | return 0; | ||
1262 | |||
1246 | case sAuthorizedPrincipalsFile: | 1263 | case sAuthorizedPrincipalsFile: |
1247 | charptr = &options->authorized_principals_file; | 1264 | charptr = &options->authorized_principals_file; |
1248 | parse_tilde_filename: | ||
1249 | arg = strdelim(&cp); | 1265 | arg = strdelim(&cp); |
1250 | if (!arg || *arg == '\0') | 1266 | if (!arg || *arg == '\0') |
1251 | fatal("%s line %d: missing file name.", | 1267 | fatal("%s line %d: missing file name.", |
@@ -1464,6 +1480,12 @@ parse_server_match_config(ServerOptions *options, const char *user, | |||
1464 | dst->n = src->n; \ | 1480 | dst->n = src->n; \ |
1465 | } \ | 1481 | } \ |
1466 | } while(0) | 1482 | } while(0) |
1483 | #define M_CP_STRARRAYOPT(n, num_n) do {\ | ||
1484 | if (src->num_n != 0) { \ | ||
1485 | for (dst->num_n = 0; dst->num_n < src->num_n; dst->num_n++) \ | ||
1486 | dst->n[dst->num_n] = xstrdup(src->n[dst->num_n]); \ | ||
1487 | } \ | ||
1488 | } while(0) | ||
1467 | 1489 | ||
1468 | /* | 1490 | /* |
1469 | * Copy any supported values that are set. | 1491 | * Copy any supported values that are set. |
@@ -1508,12 +1530,14 @@ copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth) | |||
1508 | */ | 1530 | */ |
1509 | if (preauth) | 1531 | if (preauth) |
1510 | return; | 1532 | return; |
1533 | |||
1511 | M_CP_STROPT(adm_forced_command); | 1534 | M_CP_STROPT(adm_forced_command); |
1512 | M_CP_STROPT(chroot_directory); | 1535 | M_CP_STROPT(chroot_directory); |
1513 | } | 1536 | } |
1514 | 1537 | ||
1515 | #undef M_CP_INTOPT | 1538 | #undef M_CP_INTOPT |
1516 | #undef M_CP_STROPT | 1539 | #undef M_CP_STROPT |
1540 | #undef M_CP_STRARRAYOPT | ||
1517 | 1541 | ||
1518 | void | 1542 | void |
1519 | parse_server_config(ServerOptions *options, const char *filename, Buffer *conf, | 1543 | parse_server_config(ServerOptions *options, const char *filename, Buffer *conf, |
@@ -1627,7 +1651,18 @@ dump_cfg_strarray(ServerOpCodes code, u_int count, char **vals) | |||
1627 | u_int i; | 1651 | u_int i; |
1628 | 1652 | ||
1629 | for (i = 0; i < count; i++) | 1653 | for (i = 0; i < count; i++) |
1630 | printf("%s %s\n", lookup_opcode_name(code), vals[i]); | 1654 | printf("%s %s\n", lookup_opcode_name(code), vals[i]); |
1655 | } | ||
1656 | |||
1657 | static void | ||
1658 | dump_cfg_strarray_oneline(ServerOpCodes code, u_int count, char **vals) | ||
1659 | { | ||
1660 | u_int i; | ||
1661 | |||
1662 | printf("%s", lookup_opcode_name(code)); | ||
1663 | for (i = 0; i < count; i++) | ||
1664 | printf(" %s", vals[i]); | ||
1665 | printf("\n"); | ||
1631 | } | 1666 | } |
1632 | 1667 | ||
1633 | void | 1668 | void |
@@ -1725,7 +1760,6 @@ dump_config(ServerOptions *o) | |||
1725 | dump_cfg_string(sCiphers, o->ciphers); | 1760 | dump_cfg_string(sCiphers, o->ciphers); |
1726 | dump_cfg_string(sMacs, o->macs); | 1761 | dump_cfg_string(sMacs, o->macs); |
1727 | dump_cfg_string(sBanner, o->banner); | 1762 | dump_cfg_string(sBanner, o->banner); |
1728 | dump_cfg_string(sAuthorizedKeysFile, o->authorized_keys_file); | ||
1729 | dump_cfg_string(sForceCommand, o->adm_forced_command); | 1763 | dump_cfg_string(sForceCommand, o->adm_forced_command); |
1730 | dump_cfg_string(sChrootDirectory, o->chroot_directory); | 1764 | dump_cfg_string(sChrootDirectory, o->chroot_directory); |
1731 | dump_cfg_string(sTrustedUserCAKeys, o->trusted_user_ca_keys); | 1765 | dump_cfg_string(sTrustedUserCAKeys, o->trusted_user_ca_keys); |
@@ -1738,6 +1772,8 @@ dump_config(ServerOptions *o) | |||
1738 | dump_cfg_string(sLogFacility, log_facility_name(o->log_facility)); | 1772 | dump_cfg_string(sLogFacility, log_facility_name(o->log_facility)); |
1739 | 1773 | ||
1740 | /* string array arguments */ | 1774 | /* string array arguments */ |
1775 | dump_cfg_strarray_oneline(sAuthorizedKeysFile, o->num_authkeys_files, | ||
1776 | o->authorized_keys_files); | ||
1741 | dump_cfg_strarray(sHostKeyFile, o->num_host_key_files, | 1777 | dump_cfg_strarray(sHostKeyFile, o->num_host_key_files, |
1742 | o->host_key_files); | 1778 | o->host_key_files); |
1743 | dump_cfg_strarray(sHostKeyFile, o->num_host_cert_files, | 1779 | dump_cfg_strarray(sHostKeyFile, o->num_host_cert_files, |