diff options
author | djm@openbsd.org <djm@openbsd.org> | 2020-04-17 03:30:05 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2020-04-17 14:03:36 +1000 |
commit | c90f72d29e84b4a2709078bf5546a72c29a65177 (patch) | |
tree | 58f38f99566d13f7e142c3181878f54e4cd2af21 | |
parent | 321c7147079270f3a154f91b59e66219aac3d514 (diff) |
upstream: make IgnoreRhosts a tri-state option: "yes" ignore
rhosts/shosts, "no" allow rhosts/shosts or (new) "shosts-only" to allow
.shosts files but not .rhosts. ok dtucker@
OpenBSD-Commit-ID: d08d6930ed06377a80cf53923c1955e9589342e9
-rw-r--r-- | auth-rhosts.c | 6 | ||||
-rw-r--r-- | servconf.c | 17 | ||||
-rw-r--r-- | servconf.h | 7 | ||||
-rw-r--r-- | sshd_config.5 | 27 |
4 files changed, 43 insertions, 14 deletions
diff --git a/auth-rhosts.c b/auth-rhosts.c index 7a10210b6..e81321b49 100644 --- a/auth-rhosts.c +++ b/auth-rhosts.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth-rhosts.c,v 1.51 2019/10/02 00:42:30 djm Exp $ */ | 1 | /* $OpenBSD: auth-rhosts.c,v 1.52 2020/04/17 03:30:05 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -298,7 +298,9 @@ auth_rhosts2(struct passwd *pw, const char *client_user, const char *hostname, | |||
298 | * Check if we have been configured to ignore .rhosts | 298 | * Check if we have been configured to ignore .rhosts |
299 | * and .shosts files. | 299 | * and .shosts files. |
300 | */ | 300 | */ |
301 | if (options.ignore_rhosts) { | 301 | if (options.ignore_rhosts == IGNORE_RHOSTS_YES || |
302 | (options.ignore_rhosts == IGNORE_RHOSTS_SHOSTS && | ||
303 | strcmp(rhosts_files[rhosts_file_index], ".shosts") != 0)) { | ||
302 | auth_debug_add("Server has been configured to " | 304 | auth_debug_add("Server has been configured to " |
303 | "ignore %.100s.", rhosts_files[rhosts_file_index]); | 305 | "ignore %.100s.", rhosts_files[rhosts_file_index]); |
304 | continue; | 306 | continue; |
diff --git a/servconf.c b/servconf.c index ae45099ab..7e422ec8f 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | /* $OpenBSD: servconf.c,v 1.362 2020/04/17 03:23:13 djm Exp $ */ | 2 | /* $OpenBSD: servconf.c,v 1.363 2020/04/17 03:30:05 djm 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 |
@@ -1213,6 +1213,12 @@ static const struct multistate multistate_flag[] = { | |||
1213 | { "no", 0 }, | 1213 | { "no", 0 }, |
1214 | { NULL, -1 } | 1214 | { NULL, -1 } |
1215 | }; | 1215 | }; |
1216 | static const struct multistate multistate_ignore_rhosts[] = { | ||
1217 | { "yes", IGNORE_RHOSTS_YES }, | ||
1218 | { "no", IGNORE_RHOSTS_NO }, | ||
1219 | { "shosts-only", IGNORE_RHOSTS_SHOSTS }, | ||
1220 | { NULL, -1 } | ||
1221 | }; | ||
1216 | static const struct multistate multistate_addressfamily[] = { | 1222 | static const struct multistate multistate_addressfamily[] = { |
1217 | { "inet", AF_INET }, | 1223 | { "inet", AF_INET }, |
1218 | { "inet6", AF_INET6 }, | 1224 | { "inet6", AF_INET6 }, |
@@ -1462,13 +1468,14 @@ process_server_config_line_depth(ServerOptions *options, char *line, | |||
1462 | 1468 | ||
1463 | case sIgnoreRhosts: | 1469 | case sIgnoreRhosts: |
1464 | intptr = &options->ignore_rhosts; | 1470 | intptr = &options->ignore_rhosts; |
1465 | parse_flag: | 1471 | multistate_ptr = multistate_ignore_rhosts; |
1466 | multistate_ptr = multistate_flag; | ||
1467 | goto parse_multistate; | 1472 | goto parse_multistate; |
1468 | 1473 | ||
1469 | case sIgnoreUserKnownHosts: | 1474 | case sIgnoreUserKnownHosts: |
1470 | intptr = &options->ignore_user_known_hosts; | 1475 | intptr = &options->ignore_user_known_hosts; |
1471 | goto parse_flag; | 1476 | parse_flag: |
1477 | multistate_ptr = multistate_flag; | ||
1478 | goto parse_multistate; | ||
1472 | 1479 | ||
1473 | case sHostbasedAuthentication: | 1480 | case sHostbasedAuthentication: |
1474 | intptr = &options->hostbased_authentication; | 1481 | intptr = &options->hostbased_authentication; |
@@ -2628,6 +2635,8 @@ fmt_intarg(ServerOpCodes code, int val) | |||
2628 | return fmt_multistate_int(val, multistate_tcpfwd); | 2635 | return fmt_multistate_int(val, multistate_tcpfwd); |
2629 | case sAllowStreamLocalForwarding: | 2636 | case sAllowStreamLocalForwarding: |
2630 | return fmt_multistate_int(val, multistate_tcpfwd); | 2637 | return fmt_multistate_int(val, multistate_tcpfwd); |
2638 | case sIgnoreRhosts: | ||
2639 | return fmt_multistate_int(val, multistate_ignore_rhosts); | ||
2631 | case sFingerprintHash: | 2640 | case sFingerprintHash: |
2632 | return ssh_digest_alg_name(val); | 2641 | return ssh_digest_alg_name(val); |
2633 | default: | 2642 | default: |
diff --git a/servconf.h b/servconf.h index 4202a2d02..a420f398d 100644 --- a/servconf.h +++ b/servconf.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: servconf.h,v 1.143 2020/01/31 22:42:45 djm Exp $ */ | 1 | /* $OpenBSD: servconf.h,v 1.144 2020/04/17 03:30:05 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -38,6 +38,11 @@ | |||
38 | #define PERMITOPEN_ANY 0 | 38 | #define PERMITOPEN_ANY 0 |
39 | #define PERMITOPEN_NONE -2 | 39 | #define PERMITOPEN_NONE -2 |
40 | 40 | ||
41 | /* IgnoreRhosts */ | ||
42 | #define IGNORE_RHOSTS_NO 0 | ||
43 | #define IGNORE_RHOSTS_YES 1 | ||
44 | #define IGNORE_RHOSTS_SHOSTS 2 | ||
45 | |||
41 | #define DEFAULT_AUTH_FAIL_MAX 6 /* Default for MaxAuthTries */ | 46 | #define DEFAULT_AUTH_FAIL_MAX 6 /* Default for MaxAuthTries */ |
42 | #define DEFAULT_SESSIONS_MAX 10 /* Default for MaxSessions */ | 47 | #define DEFAULT_SESSIONS_MAX 10 /* Default for MaxSessions */ |
43 | 48 | ||
diff --git a/sshd_config.5 b/sshd_config.5 index a60be383d..5648337a6 100644 --- a/sshd_config.5 +++ b/sshd_config.5 | |||
@@ -33,7 +33,7 @@ | |||
33 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 33 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
34 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 34 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
35 | .\" | 35 | .\" |
36 | .\" $OpenBSD: sshd_config.5,v 1.308 2020/04/17 03:23:13 djm Exp $ | 36 | .\" $OpenBSD: sshd_config.5,v 1.309 2020/04/17 03:30:05 djm Exp $ |
37 | .Dd $Mdocdate: April 17 2020 $ | 37 | .Dd $Mdocdate: April 17 2020 $ |
38 | .Dt SSHD_CONFIG 5 | 38 | .Dt SSHD_CONFIG 5 |
39 | .Os | 39 | .Os |
@@ -778,19 +778,32 @@ rsa-sha2-512,rsa-sha2-256,ssh-rsa | |||
778 | The list of available key types may also be obtained using | 778 | The list of available key types may also be obtained using |
779 | .Qq ssh -Q HostKeyAlgorithms . | 779 | .Qq ssh -Q HostKeyAlgorithms . |
780 | .It Cm IgnoreRhosts | 780 | .It Cm IgnoreRhosts |
781 | Specifies that | 781 | Specifies whether to ignore per-user |
782 | .Pa .rhosts | 782 | .Pa .rhosts |
783 | and | 783 | and |
784 | .Pa .shosts | 784 | .Pa .shosts |
785 | files will not be used in | 785 | files during |
786 | .Cm HostbasedAuthentication . | 786 | .Cm HostbasedAuthentication . |
787 | .Pp | 787 | The system-wide |
788 | .Pa /etc/hosts.equiv | 788 | .Pa /etc/hosts.equiv |
789 | and | 789 | and |
790 | .Pa /etc/shosts.equiv | 790 | .Pa /etc/shosts.equiv |
791 | are still used. | 791 | are still used regardless of this setting. |
792 | The default is | 792 | .Pp |
793 | .Cm yes . | 793 | Accepted values are |
794 | .Cm yes | ||
795 | (the default) to ignore all per-user files, | ||
796 | .Cm shosts-only | ||
797 | to allow the use of | ||
798 | .Pa .shosts | ||
799 | but to ignore | ||
800 | .Pa .rhosts | ||
801 | or | ||
802 | .Cm no | ||
803 | to allow both | ||
804 | .Pa .shosts | ||
805 | and | ||
806 | .Pa rhosts. | ||
794 | .It Cm IgnoreUserKnownHosts | 807 | .It Cm IgnoreUserKnownHosts |
795 | Specifies whether | 808 | Specifies whether |
796 | .Xr sshd 8 | 809 | .Xr sshd 8 |