summaryrefslogtreecommitdiff
path: root/servconf.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2013-05-07 11:47:26 +0100
committerColin Watson <cjwatson@debian.org>2013-05-07 11:47:26 +0100
commit2ea3f720daeb1ca9f765365fce3a9546961fe624 (patch)
treec4fb7d1f51fa51e7677232de806aae150e29e2ac /servconf.c
parentf5efcd3450bbf8261915e0c4a6f851229dddaa79 (diff)
parentecebda56da46a03dafff923d91c382f31faa9eec (diff)
* New upstream release (http://www.openssh.com/txt/release-6.2).
- Add support for multiple required authentication in SSH protocol 2 via an AuthenticationMethods option (closes: #195716). - Fix Sophie Germain formula in moduli(5) (closes: #698612). - Update ssh-copy-id to Phil Hands' greatly revised version (closes: #99785, #322228, #620428; LP: #518883, #835901, #1074798).
Diffstat (limited to 'servconf.c')
-rw-r--r--servconf.c75
1 files changed, 69 insertions, 6 deletions
diff --git a/servconf.c b/servconf.c
index 9a8822938..1700d5aa6 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,5 +1,5 @@
1 1
2/* $OpenBSD: servconf.c,v 1.229 2012/07/13 01:35:21 dtucker Exp $ */ 2/* $OpenBSD: servconf.c,v 1.234 2013/02/06 00:20:42 dtucker Exp $ */
3/* 3/*
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved 5 * All rights reserved
@@ -48,6 +48,8 @@
48#include "groupaccess.h" 48#include "groupaccess.h"
49#include "canohost.h" 49#include "canohost.h"
50#include "packet.h" 50#include "packet.h"
51#include "hostfile.h"
52#include "auth.h"
51 53
52static void add_listen_addr(ServerOptions *, char *, int); 54static void add_listen_addr(ServerOptions *, char *, int);
53static void add_one_listen_addr(ServerOptions *, char *, int); 55static void add_one_listen_addr(ServerOptions *, char *, int);
@@ -139,6 +141,8 @@ initialize_server_options(ServerOptions *options)
139 options->num_permitted_opens = -1; 141 options->num_permitted_opens = -1;
140 options->adm_forced_command = NULL; 142 options->adm_forced_command = NULL;
141 options->chroot_directory = NULL; 143 options->chroot_directory = NULL;
144 options->authorized_keys_command = NULL;
145 options->authorized_keys_command_user = NULL;
142 options->zero_knowledge_password_authentication = -1; 146 options->zero_knowledge_password_authentication = -1;
143 options->revoked_keys_file = NULL; 147 options->revoked_keys_file = NULL;
144 options->trusted_user_ca_keys = NULL; 148 options->trusted_user_ca_keys = NULL;
@@ -259,7 +263,7 @@ fill_default_server_options(ServerOptions *options)
259 if (options->compression == -1) 263 if (options->compression == -1)
260 options->compression = COMP_DELAYED; 264 options->compression = COMP_DELAYED;
261 if (options->allow_tcp_forwarding == -1) 265 if (options->allow_tcp_forwarding == -1)
262 options->allow_tcp_forwarding = 1; 266 options->allow_tcp_forwarding = FORWARD_ALLOW;
263 if (options->allow_agent_forwarding == -1) 267 if (options->allow_agent_forwarding == -1)
264 options->allow_agent_forwarding = 1; 268 options->allow_agent_forwarding = 1;
265 if (options->gateway_ports == -1) 269 if (options->gateway_ports == -1)
@@ -346,6 +350,8 @@ typedef enum {
346 sZeroKnowledgePasswordAuthentication, sHostCertificate, 350 sZeroKnowledgePasswordAuthentication, sHostCertificate,
347 sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile, 351 sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile,
348 sKexAlgorithms, sIPQoS, sVersionAddendum, 352 sKexAlgorithms, sIPQoS, sVersionAddendum,
353 sAuthorizedKeysCommand, sAuthorizedKeysCommandUser,
354 sAuthenticationMethods,
349 sDebianBanner, 355 sDebianBanner,
350 sDeprecated, sUnsupported 356 sDeprecated, sUnsupported
351} ServerOpCodes; 357} ServerOpCodes;
@@ -482,7 +488,10 @@ static struct {
482 { "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL }, 488 { "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL },
483 { "kexalgorithms", sKexAlgorithms, SSHCFG_GLOBAL }, 489 { "kexalgorithms", sKexAlgorithms, SSHCFG_GLOBAL },
484 { "ipqos", sIPQoS, SSHCFG_ALL }, 490 { "ipqos", sIPQoS, SSHCFG_ALL },
491 { "authorizedkeyscommand", sAuthorizedKeysCommand, SSHCFG_ALL },
492 { "authorizedkeyscommanduser", sAuthorizedKeysCommandUser, SSHCFG_ALL },
485 { "versionaddendum", sVersionAddendum, SSHCFG_GLOBAL }, 493 { "versionaddendum", sVersionAddendum, SSHCFG_GLOBAL },
494 { "authenticationmethods", sAuthenticationMethods, SSHCFG_ALL },
486 { "debianbanner", sDebianBanner, SSHCFG_GLOBAL }, 495 { "debianbanner", sDebianBanner, SSHCFG_GLOBAL },
487 { NULL, sBadOption, 0 } 496 { NULL, sBadOption, 0 }
488}; 497};
@@ -648,8 +657,9 @@ out:
648} 657}
649 658
650/* 659/*
651 * All of the attributes on a single Match line are ANDed together, so we need to check every 660 * All of the attributes on a single Match line are ANDed together, so we need
652 * attribute and set the result to zero if any attribute does not match. 661 * to check every * attribute and set the result to zero if any attribute does
662 * not match.
653 */ 663 */
654static int 664static int
655match_cfg_line(char **condition, int line, struct connection_info *ci) 665match_cfg_line(char **condition, int line, struct connection_info *ci)
@@ -806,6 +816,14 @@ static const struct multistate multistate_privsep[] = {
806 { "no", PRIVSEP_OFF }, 816 { "no", PRIVSEP_OFF },
807 { NULL, -1 } 817 { NULL, -1 }
808}; 818};
819static const struct multistate multistate_tcpfwd[] = {
820 { "yes", FORWARD_ALLOW },
821 { "all", FORWARD_ALLOW },
822 { "no", FORWARD_DENY },
823 { "remote", FORWARD_REMOTE },
824 { "local", FORWARD_LOCAL },
825 { NULL, -1 }
826};
809 827
810int 828int
811process_server_config_line(ServerOptions *options, char *line, 829process_server_config_line(ServerOptions *options, char *line,
@@ -1179,7 +1197,8 @@ process_server_config_line(ServerOptions *options, char *line,
1179 1197
1180 case sAllowTcpForwarding: 1198 case sAllowTcpForwarding:
1181 intptr = &options->allow_tcp_forwarding; 1199 intptr = &options->allow_tcp_forwarding;
1182 goto parse_flag; 1200 multistate_ptr = multistate_tcpfwd;
1201 goto parse_multistate;
1183 1202
1184 case sAllowAgentForwarding: 1203 case sAllowAgentForwarding:
1185 intptr = &options->allow_agent_forwarding; 1204 intptr = &options->allow_agent_forwarding;
@@ -1459,7 +1478,6 @@ process_server_config_line(ServerOptions *options, char *line,
1459 } 1478 }
1460 if (strcmp(arg, "none") == 0) { 1479 if (strcmp(arg, "none") == 0) {
1461 if (*activep && n == -1) { 1480 if (*activep && n == -1) {
1462 channel_clear_adm_permitted_opens();
1463 options->num_permitted_opens = 1; 1481 options->num_permitted_opens = 1;
1464 channel_disable_adm_local_opens(); 1482 channel_disable_adm_local_opens();
1465 } 1483 }
@@ -1543,6 +1561,43 @@ process_server_config_line(ServerOptions *options, char *line,
1543 } 1561 }
1544 return 0; 1562 return 0;
1545 1563
1564 case sAuthorizedKeysCommand:
1565 len = strspn(cp, WHITESPACE);
1566 if (*activep && options->authorized_keys_command == NULL) {
1567 if (cp[len] != '/' && strcasecmp(cp + len, "none") != 0)
1568 fatal("%.200s line %d: AuthorizedKeysCommand "
1569 "must be an absolute path",
1570 filename, linenum);
1571 options->authorized_keys_command = xstrdup(cp + len);
1572 }
1573 return 0;
1574
1575 case sAuthorizedKeysCommandUser:
1576 charptr = &options->authorized_keys_command_user;
1577
1578 arg = strdelim(&cp);
1579 if (*activep && *charptr == NULL)
1580 *charptr = xstrdup(arg);
1581 break;
1582
1583 case sAuthenticationMethods:
1584 if (*activep && options->num_auth_methods == 0) {
1585 while ((arg = strdelim(&cp)) && *arg != '\0') {
1586 if (options->num_auth_methods >=
1587 MAX_AUTH_METHODS)
1588 fatal("%s line %d: "
1589 "too many authentication methods.",
1590 filename, linenum);
1591 if (auth2_methods_valid(arg, 0) != 0)
1592 fatal("%s line %d: invalid "
1593 "authentication method list.",
1594 filename, linenum);
1595 options->auth_methods[
1596 options->num_auth_methods++] = xstrdup(arg);
1597 }
1598 }
1599 return 0;
1600
1546 case sDebianBanner: 1601 case sDebianBanner:
1547 intptr = &options->debian_banner; 1602 intptr = &options->debian_banner;
1548 goto parse_int; 1603 goto parse_int;
@@ -1697,6 +1752,8 @@ copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
1697 M_CP_INTOPT(hostbased_uses_name_from_packet_only); 1752 M_CP_INTOPT(hostbased_uses_name_from_packet_only);
1698 M_CP_INTOPT(kbd_interactive_authentication); 1753 M_CP_INTOPT(kbd_interactive_authentication);
1699 M_CP_INTOPT(zero_knowledge_password_authentication); 1754 M_CP_INTOPT(zero_knowledge_password_authentication);
1755 M_CP_STROPT(authorized_keys_command);
1756 M_CP_STROPT(authorized_keys_command_user);
1700 M_CP_INTOPT(permit_root_login); 1757 M_CP_INTOPT(permit_root_login);
1701 M_CP_INTOPT(permit_empty_passwd); 1758 M_CP_INTOPT(permit_empty_passwd);
1702 1759
@@ -1781,6 +1838,8 @@ fmt_intarg(ServerOpCodes code, int val)
1781 return fmt_multistate_int(val, multistate_compression); 1838 return fmt_multistate_int(val, multistate_compression);
1782 case sUsePrivilegeSeparation: 1839 case sUsePrivilegeSeparation:
1783 return fmt_multistate_int(val, multistate_privsep); 1840 return fmt_multistate_int(val, multistate_privsep);
1841 case sAllowTcpForwarding:
1842 return fmt_multistate_int(val, multistate_tcpfwd);
1784 case sProtocol: 1843 case sProtocol:
1785 switch (val) { 1844 switch (val) {
1786 case SSH_PROTO_1: 1845 case SSH_PROTO_1:
@@ -1961,6 +2020,8 @@ dump_config(ServerOptions *o)
1961 dump_cfg_string(sAuthorizedPrincipalsFile, 2020 dump_cfg_string(sAuthorizedPrincipalsFile,
1962 o->authorized_principals_file); 2021 o->authorized_principals_file);
1963 dump_cfg_string(sVersionAddendum, o->version_addendum); 2022 dump_cfg_string(sVersionAddendum, o->version_addendum);
2023 dump_cfg_string(sAuthorizedKeysCommand, o->authorized_keys_command);
2024 dump_cfg_string(sAuthorizedKeysCommandUser, o->authorized_keys_command_user);
1964 2025
1965 /* string arguments requiring a lookup */ 2026 /* string arguments requiring a lookup */
1966 dump_cfg_string(sLogLevel, log_level_name(o->log_level)); 2027 dump_cfg_string(sLogLevel, log_level_name(o->log_level));
@@ -1978,6 +2039,8 @@ dump_config(ServerOptions *o)
1978 dump_cfg_strarray(sAllowGroups, o->num_allow_groups, o->allow_groups); 2039 dump_cfg_strarray(sAllowGroups, o->num_allow_groups, o->allow_groups);
1979 dump_cfg_strarray(sDenyGroups, o->num_deny_groups, o->deny_groups); 2040 dump_cfg_strarray(sDenyGroups, o->num_deny_groups, o->deny_groups);
1980 dump_cfg_strarray(sAcceptEnv, o->num_accept_env, o->accept_env); 2041 dump_cfg_strarray(sAcceptEnv, o->num_accept_env, o->accept_env);
2042 dump_cfg_strarray_oneline(sAuthenticationMethods,
2043 o->num_auth_methods, o->auth_methods);
1981 2044
1982 /* other arguments */ 2045 /* other arguments */
1983 for (i = 0; i < o->num_subsystems; i++) 2046 for (i = 0; i < o->num_subsystems; i++)