diff options
Diffstat (limited to 'debian/patches')
31 files changed, 5931 insertions, 0 deletions
diff --git a/debian/patches/auth-log-verbosity.patch b/debian/patches/auth-log-verbosity.patch new file mode 100644 index 000000000..ba7642d83 --- /dev/null +++ b/debian/patches/auth-log-verbosity.patch | |||
@@ -0,0 +1,120 @@ | |||
1 | From 50e9edb57b6808cbbf63fe3433febb103baac1e8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:02 +0000 | ||
4 | Subject: Quieten logs when multiple from= restrictions are used | ||
5 | |||
6 | Bug-Debian: http://bugs.debian.org/630606 | ||
7 | Forwarded: no | ||
8 | Last-Update: 2017-10-04 | ||
9 | |||
10 | Patch-Name: auth-log-verbosity.patch | ||
11 | --- | ||
12 | auth-options.c | 35 ++++++++++++++++++++++++++--------- | ||
13 | auth-options.h | 1 + | ||
14 | auth2-pubkey.c | 3 +++ | ||
15 | 3 files changed, 30 insertions(+), 9 deletions(-) | ||
16 | |||
17 | diff --git a/auth-options.c b/auth-options.c | ||
18 | index bed00eef..ccdd0b20 100644 | ||
19 | --- a/auth-options.c | ||
20 | +++ b/auth-options.c | ||
21 | @@ -59,10 +59,21 @@ int forced_tun_device = -1; | ||
22 | /* "principals=" option. */ | ||
23 | char *authorized_principals = NULL; | ||
24 | |||
25 | +/* Throttle log messages. */ | ||
26 | +int logged_from_hostip = 0; | ||
27 | +int logged_cert_hostip = 0; | ||
28 | + | ||
29 | extern ServerOptions options; | ||
30 | |||
31 | /* XXX refactor to be stateless */ | ||
32 | |||
33 | +void | ||
34 | +auth_start_parse_options(void) | ||
35 | +{ | ||
36 | + logged_from_hostip = 0; | ||
37 | + logged_cert_hostip = 0; | ||
38 | +} | ||
39 | + | ||
40 | void | ||
41 | auth_clear_options(void) | ||
42 | { | ||
43 | @@ -322,10 +333,13 @@ auth_parse_options(struct passwd *pw, char *opts, const char *file, | ||
44 | /* FALLTHROUGH */ | ||
45 | case 0: | ||
46 | free(patterns); | ||
47 | - logit("Authentication tried for %.100s with " | ||
48 | - "correct key but not from a permitted " | ||
49 | - "host (host=%.200s, ip=%.200s).", | ||
50 | - pw->pw_name, remote_host, remote_ip); | ||
51 | + if (!logged_from_hostip) { | ||
52 | + logit("Authentication tried for %.100s with " | ||
53 | + "correct key but not from a permitted " | ||
54 | + "host (host=%.200s, ip=%.200s).", | ||
55 | + pw->pw_name, remote_host, remote_ip); | ||
56 | + logged_from_hostip = 1; | ||
57 | + } | ||
58 | auth_debug_add("Your host '%.200s' is not " | ||
59 | "permitted to use this key for login.", | ||
60 | remote_host); | ||
61 | @@ -549,11 +563,14 @@ parse_option_list(struct sshbuf *oblob, struct passwd *pw, | ||
62 | break; | ||
63 | case 0: | ||
64 | /* no match */ | ||
65 | - logit("Authentication tried for %.100s " | ||
66 | - "with valid certificate but not " | ||
67 | - "from a permitted host " | ||
68 | - "(ip=%.200s).", pw->pw_name, | ||
69 | - remote_ip); | ||
70 | + if (!logged_cert_hostip) { | ||
71 | + logit("Authentication tried for %.100s " | ||
72 | + "with valid certificate but not " | ||
73 | + "from a permitted host " | ||
74 | + "(ip=%.200s).", pw->pw_name, | ||
75 | + remote_ip); | ||
76 | + logged_cert_hostip = 1; | ||
77 | + } | ||
78 | auth_debug_add("Your address '%.200s' " | ||
79 | "is not permitted to use this " | ||
80 | "certificate for login.", | ||
81 | diff --git a/auth-options.h b/auth-options.h | ||
82 | index 547f0163..4de0f14d 100644 | ||
83 | --- a/auth-options.h | ||
84 | +++ b/auth-options.h | ||
85 | @@ -33,6 +33,7 @@ extern int forced_tun_device; | ||
86 | extern int key_is_cert_authority; | ||
87 | extern char *authorized_principals; | ||
88 | |||
89 | +void auth_start_parse_options(void); | ||
90 | int auth_parse_options(struct passwd *, char *, const char *, u_long); | ||
91 | void auth_clear_options(void); | ||
92 | int auth_cert_options(struct sshkey *, struct passwd *, const char **); | ||
93 | diff --git a/auth2-pubkey.c b/auth2-pubkey.c | ||
94 | index 169839b0..43f880b6 100644 | ||
95 | --- a/auth2-pubkey.c | ||
96 | +++ b/auth2-pubkey.c | ||
97 | @@ -269,6 +269,7 @@ process_principals(FILE *f, const char *file, struct passwd *pw, | ||
98 | u_long linenum = 0; | ||
99 | u_int i, found_principal = 0; | ||
100 | |||
101 | + auth_start_parse_options(); | ||
102 | while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) { | ||
103 | /* Always consume entire input */ | ||
104 | if (found_principal) | ||
105 | @@ -471,6 +472,7 @@ check_authkeys_file(FILE *f, char *file, struct sshkey *key, struct passwd *pw) | ||
106 | u_long linenum = 0; | ||
107 | struct sshkey *found = NULL; | ||
108 | |||
109 | + auth_start_parse_options(); | ||
110 | while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) { | ||
111 | char *cp, *key_options = NULL, *fp = NULL; | ||
112 | const char *reason = NULL; | ||
113 | @@ -624,6 +626,7 @@ user_cert_trusted_ca(struct passwd *pw, struct sshkey *key) | ||
114 | if (sshkey_cert_check_authority(key, 0, 1, | ||
115 | use_authorized_principals ? NULL : pw->pw_name, &reason) != 0) | ||
116 | goto fail_reason; | ||
117 | + auth_start_parse_options(); | ||
118 | if (auth_cert_options(key, pw, &reason) != 0) | ||
119 | goto fail_reason; | ||
120 | |||
diff --git a/debian/patches/authorized-keys-man-symlink.patch b/debian/patches/authorized-keys-man-symlink.patch new file mode 100644 index 000000000..56f6de37f --- /dev/null +++ b/debian/patches/authorized-keys-man-symlink.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | From 312eb64a9faf4e8cdb95f2ae147ecbfa6c0efd83 Mon Sep 17 00:00:00 2001 | ||
2 | From: Tomas Pospisek <tpo_deb@sourcepole.ch> | ||
3 | Date: Sun, 9 Feb 2014 16:10:07 +0000 | ||
4 | Subject: Install authorized_keys(5) as a symlink to sshd(8) | ||
5 | |||
6 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1720 | ||
7 | Bug-Debian: http://bugs.debian.org/441817 | ||
8 | Last-Update: 2013-09-14 | ||
9 | |||
10 | Patch-Name: authorized-keys-man-symlink.patch | ||
11 | --- | ||
12 | Makefile.in | 1 + | ||
13 | 1 file changed, 1 insertion(+) | ||
14 | |||
15 | diff --git a/Makefile.in b/Makefile.in | ||
16 | index f6e9fe4c..08b989a4 100644 | ||
17 | --- a/Makefile.in | ||
18 | +++ b/Makefile.in | ||
19 | @@ -340,6 +340,7 @@ install-files: | ||
20 | $(INSTALL) -m 644 sshd_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/sshd_config.5 | ||
21 | $(INSTALL) -m 644 ssh_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/ssh_config.5 | ||
22 | $(INSTALL) -m 644 sshd.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sshd.8 | ||
23 | + ln -s ../$(mansubdir)8/sshd.8 $(DESTDIR)$(mandir)/$(mansubdir)5/authorized_keys.5 | ||
24 | $(INSTALL) -m 644 sftp.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/sftp.1 | ||
25 | $(INSTALL) -m 644 sftp-server.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8 | ||
26 | $(INSTALL) -m 644 ssh-keysign.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8 | ||
diff --git a/debian/patches/debian-banner.patch b/debian/patches/debian-banner.patch new file mode 100644 index 000000000..8134afba4 --- /dev/null +++ b/debian/patches/debian-banner.patch | |||
@@ -0,0 +1,111 @@ | |||
1 | From ae96c03ce51af2c529bfa2f2de57f4fa938ea552 Mon Sep 17 00:00:00 2001 | ||
2 | From: Kees Cook <kees@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:06 +0000 | ||
4 | Subject: Add DebianBanner server configuration option | ||
5 | |||
6 | Setting this to "no" causes sshd to omit the Debian revision from its | ||
7 | initial protocol handshake, for those scared by package-versioning.patch. | ||
8 | |||
9 | Bug-Debian: http://bugs.debian.org/562048 | ||
10 | Forwarded: not-needed | ||
11 | Last-Update: 2017-10-04 | ||
12 | |||
13 | Patch-Name: debian-banner.patch | ||
14 | --- | ||
15 | servconf.c | 9 +++++++++ | ||
16 | servconf.h | 2 ++ | ||
17 | sshd.c | 3 ++- | ||
18 | sshd_config.5 | 5 +++++ | ||
19 | 4 files changed, 18 insertions(+), 1 deletion(-) | ||
20 | |||
21 | diff --git a/servconf.c b/servconf.c | ||
22 | index 9889fb0a..b0146405 100644 | ||
23 | --- a/servconf.c | ||
24 | +++ b/servconf.c | ||
25 | @@ -167,6 +167,7 @@ initialize_server_options(ServerOptions *options) | ||
26 | options->fingerprint_hash = -1; | ||
27 | options->disable_forwarding = -1; | ||
28 | options->expose_userauth_info = -1; | ||
29 | + options->debian_banner = -1; | ||
30 | } | ||
31 | |||
32 | /* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */ | ||
33 | @@ -342,6 +343,8 @@ fill_default_server_options(ServerOptions *options) | ||
34 | options->disable_forwarding = 0; | ||
35 | if (options->expose_userauth_info == -1) | ||
36 | options->expose_userauth_info = 0; | ||
37 | + if (options->debian_banner == -1) | ||
38 | + options->debian_banner = 1; | ||
39 | |||
40 | assemble_algorithms(options); | ||
41 | |||
42 | @@ -429,6 +432,7 @@ typedef enum { | ||
43 | sStreamLocalBindMask, sStreamLocalBindUnlink, | ||
44 | sAllowStreamLocalForwarding, sFingerprintHash, sDisableForwarding, | ||
45 | sExposeAuthInfo, | ||
46 | + sDebianBanner, | ||
47 | sDeprecated, sIgnore, sUnsupported | ||
48 | } ServerOpCodes; | ||
49 | |||
50 | @@ -582,6 +586,7 @@ static struct { | ||
51 | { "fingerprinthash", sFingerprintHash, SSHCFG_GLOBAL }, | ||
52 | { "disableforwarding", sDisableForwarding, SSHCFG_ALL }, | ||
53 | { "exposeauthinfo", sExposeAuthInfo, SSHCFG_ALL }, | ||
54 | + { "debianbanner", sDebianBanner, SSHCFG_GLOBAL }, | ||
55 | { NULL, sBadOption, 0 } | ||
56 | }; | ||
57 | |||
58 | @@ -1907,6 +1912,10 @@ process_server_config_line(ServerOptions *options, char *line, | ||
59 | intptr = &options->expose_userauth_info; | ||
60 | goto parse_flag; | ||
61 | |||
62 | + case sDebianBanner: | ||
63 | + intptr = &options->debian_banner; | ||
64 | + goto parse_int; | ||
65 | + | ||
66 | case sDeprecated: | ||
67 | case sIgnore: | ||
68 | case sUnsupported: | ||
69 | diff --git a/servconf.h b/servconf.h | ||
70 | index 641e93c8..410c4275 100644 | ||
71 | --- a/servconf.h | ||
72 | +++ b/servconf.h | ||
73 | @@ -200,6 +200,8 @@ typedef struct { | ||
74 | |||
75 | int fingerprint_hash; | ||
76 | int expose_userauth_info; | ||
77 | + | ||
78 | + int debian_banner; | ||
79 | } ServerOptions; | ||
80 | |||
81 | /* Information about the incoming connection as used by Match */ | ||
82 | diff --git a/sshd.c b/sshd.c | ||
83 | index eccf81bb..a5a1193d 100644 | ||
84 | --- a/sshd.c | ||
85 | +++ b/sshd.c | ||
86 | @@ -378,7 +378,8 @@ sshd_exchange_identification(struct ssh *ssh, int sock_in, int sock_out) | ||
87 | char remote_version[256]; /* Must be at least as big as buf. */ | ||
88 | |||
89 | xasprintf(&server_version_string, "SSH-%d.%d-%.100s%s%s\r\n", | ||
90 | - PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_RELEASE, | ||
91 | + PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, | ||
92 | + options.debian_banner ? SSH_RELEASE : SSH_RELEASE_MINIMUM, | ||
93 | *options.version_addendum == '\0' ? "" : " ", | ||
94 | options.version_addendum); | ||
95 | |||
96 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
97 | index 7db25552..41e8c939 100644 | ||
98 | --- a/sshd_config.5 | ||
99 | +++ b/sshd_config.5 | ||
100 | @@ -530,6 +530,11 @@ or | ||
101 | .Cm no . | ||
102 | The default is | ||
103 | .Cm yes . | ||
104 | +.It Cm DebianBanner | ||
105 | +Specifies whether the distribution-specified extra version suffix is | ||
106 | +included during initial protocol handshake. | ||
107 | +The default is | ||
108 | +.Cm yes . | ||
109 | .It Cm DenyGroups | ||
110 | This keyword can be followed by a list of group name patterns, separated | ||
111 | by spaces. | ||
diff --git a/debian/patches/debian-config.patch b/debian/patches/debian-config.patch new file mode 100644 index 000000000..a3f595752 --- /dev/null +++ b/debian/patches/debian-config.patch | |||
@@ -0,0 +1,238 @@ | |||
1 | From 4847e512c0b94c615b838904a5f139a761bee284 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:18 +0000 | ||
4 | Subject: Various Debian-specific configuration changes | ||
5 | |||
6 | ssh: Enable ForwardX11Trusted, returning to earlier semantics which cause | ||
7 | fewer problems with existing setups (http://bugs.debian.org/237021). | ||
8 | |||
9 | ssh: Set 'SendEnv LANG LC_*' by default (http://bugs.debian.org/264024). | ||
10 | |||
11 | ssh: Enable HashKnownHosts by default to try to limit the spread of ssh | ||
12 | worms. | ||
13 | |||
14 | ssh: Enable GSSAPIAuthentication by default. | ||
15 | |||
16 | sshd: Enable PAM, disable ChallengeResponseAuthentication, and disable | ||
17 | PrintMotd. | ||
18 | |||
19 | sshd: Enable X11Forwarding. | ||
20 | |||
21 | sshd: Set 'AcceptEnv LANG LC_*' by default. | ||
22 | |||
23 | sshd: Change sftp subsystem path to /usr/lib/openssh/sftp-server. | ||
24 | |||
25 | Document all of this. | ||
26 | |||
27 | Author: Russ Allbery <rra@debian.org> | ||
28 | Forwarded: not-needed | ||
29 | Last-Update: 2017-10-04 | ||
30 | |||
31 | Patch-Name: debian-config.patch | ||
32 | --- | ||
33 | readconf.c | 2 +- | ||
34 | ssh.1 | 21 +++++++++++++++++++++ | ||
35 | ssh_config | 6 +++++- | ||
36 | ssh_config.5 | 19 ++++++++++++++++++- | ||
37 | sshd_config | 16 ++++++++++------ | ||
38 | sshd_config.5 | 22 ++++++++++++++++++++++ | ||
39 | 6 files changed, 77 insertions(+), 9 deletions(-) | ||
40 | |||
41 | diff --git a/readconf.c b/readconf.c | ||
42 | index be3d5873..41f36aa8 100644 | ||
43 | --- a/readconf.c | ||
44 | +++ b/readconf.c | ||
45 | @@ -1940,7 +1940,7 @@ fill_default_options(Options * options) | ||
46 | if (options->forward_x11 == -1) | ||
47 | options->forward_x11 = 0; | ||
48 | if (options->forward_x11_trusted == -1) | ||
49 | - options->forward_x11_trusted = 0; | ||
50 | + options->forward_x11_trusted = 1; | ||
51 | if (options->forward_x11_timeout == -1) | ||
52 | options->forward_x11_timeout = 1200; | ||
53 | /* | ||
54 | diff --git a/ssh.1 b/ssh.1 | ||
55 | index 711fe608..f1b01c56 100644 | ||
56 | --- a/ssh.1 | ||
57 | +++ b/ssh.1 | ||
58 | @@ -764,6 +764,16 @@ directive in | ||
59 | .Xr ssh_config 5 | ||
60 | for more information. | ||
61 | .Pp | ||
62 | +(Debian-specific: X11 forwarding is not subjected to X11 SECURITY extension | ||
63 | +restrictions by default, because too many programs currently crash in this | ||
64 | +mode. | ||
65 | +Set the | ||
66 | +.Cm ForwardX11Trusted | ||
67 | +option to | ||
68 | +.Dq no | ||
69 | +to restore the upstream behaviour. | ||
70 | +This may change in future depending on client-side improvements.) | ||
71 | +.Pp | ||
72 | .It Fl x | ||
73 | Disables X11 forwarding. | ||
74 | .Pp | ||
75 | @@ -772,6 +782,17 @@ Enables trusted X11 forwarding. | ||
76 | Trusted X11 forwardings are not subjected to the X11 SECURITY extension | ||
77 | controls. | ||
78 | .Pp | ||
79 | +(Debian-specific: This option does nothing in the default configuration: it | ||
80 | +is equivalent to | ||
81 | +.Dq Cm ForwardX11Trusted No yes , | ||
82 | +which is the default as described above. | ||
83 | +Set the | ||
84 | +.Cm ForwardX11Trusted | ||
85 | +option to | ||
86 | +.Dq no | ||
87 | +to restore the upstream behaviour. | ||
88 | +This may change in future depending on client-side improvements.) | ||
89 | +.Pp | ||
90 | .It Fl y | ||
91 | Send log information using the | ||
92 | .Xr syslog 3 | ||
93 | diff --git a/ssh_config b/ssh_config | ||
94 | index bcb9f153..1b676fb2 100644 | ||
95 | --- a/ssh_config | ||
96 | +++ b/ssh_config | ||
97 | @@ -17,9 +17,10 @@ | ||
98 | # list of available options, their meanings and defaults, please see the | ||
99 | # ssh_config(5) man page. | ||
100 | |||
101 | -# Host * | ||
102 | +Host * | ||
103 | # ForwardAgent no | ||
104 | # ForwardX11 no | ||
105 | +# ForwardX11Trusted yes | ||
106 | # PasswordAuthentication yes | ||
107 | # HostbasedAuthentication no | ||
108 | # GSSAPIAuthentication no | ||
109 | @@ -46,3 +47,6 @@ | ||
110 | # VisualHostKey no | ||
111 | # ProxyCommand ssh -q -W %h:%p gateway.example.com | ||
112 | # RekeyLimit 1G 1h | ||
113 | + SendEnv LANG LC_* | ||
114 | + HashKnownHosts yes | ||
115 | + GSSAPIAuthentication yes | ||
116 | diff --git a/ssh_config.5 b/ssh_config.5 | ||
117 | index 1edfe761..2da7029a 100644 | ||
118 | --- a/ssh_config.5 | ||
119 | +++ b/ssh_config.5 | ||
120 | @@ -71,6 +71,22 @@ Since the first obtained value for each parameter is used, more | ||
121 | host-specific declarations should be given near the beginning of the | ||
122 | file, and general defaults at the end. | ||
123 | .Pp | ||
124 | +Note that the Debian | ||
125 | +.Ic openssh-client | ||
126 | +package sets several options as standard in | ||
127 | +.Pa /etc/ssh/ssh_config | ||
128 | +which are not the default in | ||
129 | +.Xr ssh 1 : | ||
130 | +.Pp | ||
131 | +.Bl -bullet -offset indent -compact | ||
132 | +.It | ||
133 | +.Cm SendEnv No LANG LC_* | ||
134 | +.It | ||
135 | +.Cm HashKnownHosts No yes | ||
136 | +.It | ||
137 | +.Cm GSSAPIAuthentication No yes | ||
138 | +.El | ||
139 | +.Pp | ||
140 | The file contains keyword-argument pairs, one per line. | ||
141 | Lines starting with | ||
142 | .Ql # | ||
143 | @@ -683,11 +699,12 @@ elapsed. | ||
144 | .It Cm ForwardX11Trusted | ||
145 | If this option is set to | ||
146 | .Cm yes , | ||
147 | +(the Debian-specific default), | ||
148 | remote X11 clients will have full access to the original X11 display. | ||
149 | .Pp | ||
150 | If this option is set to | ||
151 | .Cm no | ||
152 | -(the default), | ||
153 | +(the upstream default), | ||
154 | remote X11 clients will be considered untrusted and prevented | ||
155 | from stealing or tampering with data belonging to trusted X11 | ||
156 | clients. | ||
157 | diff --git a/sshd_config b/sshd_config | ||
158 | index c01dd656..f68edf36 100644 | ||
159 | --- a/sshd_config | ||
160 | +++ b/sshd_config | ||
161 | @@ -58,8 +58,9 @@ AuthorizedKeysFile .ssh/authorized_keys | ||
162 | #PasswordAuthentication yes | ||
163 | #PermitEmptyPasswords no | ||
164 | |||
165 | -# Change to no to disable s/key passwords | ||
166 | -#ChallengeResponseAuthentication yes | ||
167 | +# Change to yes to enable challenge-response passwords (beware issues with | ||
168 | +# some PAM modules and threads) | ||
169 | +ChallengeResponseAuthentication no | ||
170 | |||
171 | # Kerberos options | ||
172 | #KerberosAuthentication no | ||
173 | @@ -82,16 +83,16 @@ AuthorizedKeysFile .ssh/authorized_keys | ||
174 | # If you just want the PAM account and session checks to run without | ||
175 | # PAM authentication, then enable this but set PasswordAuthentication | ||
176 | # and ChallengeResponseAuthentication to 'no'. | ||
177 | -#UsePAM no | ||
178 | +UsePAM yes | ||
179 | |||
180 | #AllowAgentForwarding yes | ||
181 | #AllowTcpForwarding yes | ||
182 | #GatewayPorts no | ||
183 | -#X11Forwarding no | ||
184 | +X11Forwarding yes | ||
185 | #X11DisplayOffset 10 | ||
186 | #X11UseLocalhost yes | ||
187 | #PermitTTY yes | ||
188 | -#PrintMotd yes | ||
189 | +PrintMotd no | ||
190 | #PrintLastLog yes | ||
191 | #TCPKeepAlive yes | ||
192 | #UseLogin no | ||
193 | @@ -109,8 +110,11 @@ AuthorizedKeysFile .ssh/authorized_keys | ||
194 | # no default banner path | ||
195 | #Banner none | ||
196 | |||
197 | +# Allow client to pass locale environment variables | ||
198 | +AcceptEnv LANG LC_* | ||
199 | + | ||
200 | # override default of no subsystems | ||
201 | -Subsystem sftp /usr/libexec/sftp-server | ||
202 | +Subsystem sftp /usr/lib/openssh/sftp-server | ||
203 | |||
204 | # Example of overriding settings on a per-user basis | ||
205 | #Match User anoncvs | ||
206 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
207 | index 79676a95..16be4f62 100644 | ||
208 | --- a/sshd_config.5 | ||
209 | +++ b/sshd_config.5 | ||
210 | @@ -55,6 +55,28 @@ Arguments may optionally be enclosed in double quotes | ||
211 | .Pq \&" | ||
212 | in order to represent arguments containing spaces. | ||
213 | .Pp | ||
214 | +Note that the Debian | ||
215 | +.Ic openssh-server | ||
216 | +package sets several options as standard in | ||
217 | +.Pa /etc/ssh/sshd_config | ||
218 | +which are not the default in | ||
219 | +.Xr sshd 8 : | ||
220 | +.Pp | ||
221 | +.Bl -bullet -offset indent -compact | ||
222 | +.It | ||
223 | +.Cm ChallengeResponseAuthentication No no | ||
224 | +.It | ||
225 | +.Cm X11Forwarding No yes | ||
226 | +.It | ||
227 | +.Cm PrintMotd No no | ||
228 | +.It | ||
229 | +.Cm AcceptEnv No LANG LC_* | ||
230 | +.It | ||
231 | +.Cm Subsystem No sftp /usr/lib/openssh/sftp-server | ||
232 | +.It | ||
233 | +.Cm UsePAM No yes | ||
234 | +.El | ||
235 | +.Pp | ||
236 | The possible | ||
237 | keywords and their meanings are as follows (note that | ||
238 | keywords are case-insensitive and arguments are case-sensitive): | ||
diff --git a/debian/patches/dnssec-sshfp.patch b/debian/patches/dnssec-sshfp.patch new file mode 100644 index 000000000..a8d98855a --- /dev/null +++ b/debian/patches/dnssec-sshfp.patch | |||
@@ -0,0 +1,94 @@ | |||
1 | From f500e89e2310f6308a998357d72d767e3b01553c Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:01 +0000 | ||
4 | Subject: Force use of DNSSEC even if "options edns0" isn't in resolv.conf | ||
5 | |||
6 | This allows SSHFP DNS records to be verified if glibc 2.11 is installed. | ||
7 | |||
8 | Origin: vendor, https://cvs.fedoraproject.org/viewvc/F-12/openssh/openssh-5.2p1-edns.patch?revision=1.1&view=markup | ||
9 | Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572049 | ||
10 | Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572049 | ||
11 | Last-Update: 2010-04-06 | ||
12 | |||
13 | Patch-Name: dnssec-sshfp.patch | ||
14 | --- | ||
15 | dns.c | 14 +++++++++++++- | ||
16 | openbsd-compat/getrrsetbyname.c | 10 +++++----- | ||
17 | openbsd-compat/getrrsetbyname.h | 3 +++ | ||
18 | 3 files changed, 21 insertions(+), 6 deletions(-) | ||
19 | |||
20 | diff --git a/dns.c b/dns.c | ||
21 | index 6e1abb53..8e0ca691 100644 | ||
22 | --- a/dns.c | ||
23 | +++ b/dns.c | ||
24 | @@ -206,6 +206,7 @@ verify_host_key_dns(const char *hostname, struct sockaddr *address, | ||
25 | { | ||
26 | u_int counter; | ||
27 | int result; | ||
28 | + unsigned int rrset_flags = 0; | ||
29 | struct rrsetinfo *fingerprints = NULL; | ||
30 | |||
31 | u_int8_t hostkey_algorithm; | ||
32 | @@ -229,8 +230,19 @@ verify_host_key_dns(const char *hostname, struct sockaddr *address, | ||
33 | return -1; | ||
34 | } | ||
35 | |||
36 | + /* | ||
37 | + * Original getrrsetbyname function, found on OpenBSD for example, | ||
38 | + * doesn't accept any flag and prerequisite for obtaining AD bit in | ||
39 | + * DNS response is set by "options edns0" in resolv.conf. | ||
40 | + * | ||
41 | + * Our version is more clever and use RRSET_FORCE_EDNS0 flag. | ||
42 | + */ | ||
43 | +#ifndef HAVE_GETRRSETBYNAME | ||
44 | + rrset_flags |= RRSET_FORCE_EDNS0; | ||
45 | +#endif | ||
46 | result = getrrsetbyname(hostname, DNS_RDATACLASS_IN, | ||
47 | - DNS_RDATATYPE_SSHFP, 0, &fingerprints); | ||
48 | + DNS_RDATATYPE_SSHFP, rrset_flags, &fingerprints); | ||
49 | + | ||
50 | if (result) { | ||
51 | verbose("DNS lookup error: %s", dns_result_totext(result)); | ||
52 | return -1; | ||
53 | diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c | ||
54 | index dc6fe053..e061a290 100644 | ||
55 | --- a/openbsd-compat/getrrsetbyname.c | ||
56 | +++ b/openbsd-compat/getrrsetbyname.c | ||
57 | @@ -209,8 +209,8 @@ getrrsetbyname(const char *hostname, unsigned int rdclass, | ||
58 | goto fail; | ||
59 | } | ||
60 | |||
61 | - /* don't allow flags yet, unimplemented */ | ||
62 | - if (flags) { | ||
63 | + /* Allow RRSET_FORCE_EDNS0 flag only. */ | ||
64 | + if ((flags & !RRSET_FORCE_EDNS0) != 0) { | ||
65 | result = ERRSET_INVAL; | ||
66 | goto fail; | ||
67 | } | ||
68 | @@ -226,9 +226,9 @@ getrrsetbyname(const char *hostname, unsigned int rdclass, | ||
69 | #endif /* DEBUG */ | ||
70 | |||
71 | #ifdef RES_USE_DNSSEC | ||
72 | - /* turn on DNSSEC if EDNS0 is configured */ | ||
73 | - if (_resp->options & RES_USE_EDNS0) | ||
74 | - _resp->options |= RES_USE_DNSSEC; | ||
75 | + /* turn on DNSSEC if required */ | ||
76 | + if (flags & RRSET_FORCE_EDNS0) | ||
77 | + _resp->options |= (RES_USE_EDNS0|RES_USE_DNSSEC); | ||
78 | #endif /* RES_USE_DNSEC */ | ||
79 | |||
80 | /* make query */ | ||
81 | diff --git a/openbsd-compat/getrrsetbyname.h b/openbsd-compat/getrrsetbyname.h | ||
82 | index 1283f550..dbbc85a2 100644 | ||
83 | --- a/openbsd-compat/getrrsetbyname.h | ||
84 | +++ b/openbsd-compat/getrrsetbyname.h | ||
85 | @@ -72,6 +72,9 @@ | ||
86 | #ifndef RRSET_VALIDATED | ||
87 | # define RRSET_VALIDATED 1 | ||
88 | #endif | ||
89 | +#ifndef RRSET_FORCE_EDNS0 | ||
90 | +# define RRSET_FORCE_EDNS0 0x0001 | ||
91 | +#endif | ||
92 | |||
93 | /* | ||
94 | * Return codes for getrrsetbyname() | ||
diff --git a/debian/patches/doc-hash-tab-completion.patch b/debian/patches/doc-hash-tab-completion.patch new file mode 100644 index 000000000..c4342181d --- /dev/null +++ b/debian/patches/doc-hash-tab-completion.patch | |||
@@ -0,0 +1,28 @@ | |||
1 | From a07f7c1fe9d8dc3bfe4cb8bbe6bb5a27b638d024 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:11 +0000 | ||
4 | Subject: Document that HashKnownHosts may break tab-completion | ||
5 | |||
6 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1727 | ||
7 | Bug-Debian: http://bugs.debian.org/430154 | ||
8 | Last-Update: 2013-09-14 | ||
9 | |||
10 | Patch-Name: doc-hash-tab-completion.patch | ||
11 | --- | ||
12 | ssh_config.5 | 3 +++ | ||
13 | 1 file changed, 3 insertions(+) | ||
14 | |||
15 | diff --git a/ssh_config.5 b/ssh_config.5 | ||
16 | index 7810a418..1edfe761 100644 | ||
17 | --- a/ssh_config.5 | ||
18 | +++ b/ssh_config.5 | ||
19 | @@ -777,6 +777,9 @@ Note that existing names and addresses in known hosts files | ||
20 | will not be converted automatically, | ||
21 | but may be manually hashed using | ||
22 | .Xr ssh-keygen 1 . | ||
23 | +Use of this option may break facilities such as tab-completion that rely | ||
24 | +on being able to read unhashed host names from | ||
25 | +.Pa ~/.ssh/known_hosts . | ||
26 | .It Cm HostbasedAuthentication | ||
27 | Specifies whether to try rhosts based authentication with public key | ||
28 | authentication. | ||
diff --git a/debian/patches/fix-regress-putty-transfer.patch b/debian/patches/fix-regress-putty-transfer.patch new file mode 100644 index 000000000..cfec3a9d2 --- /dev/null +++ b/debian/patches/fix-regress-putty-transfer.patch | |||
@@ -0,0 +1,37 @@ | |||
1 | From bd081a1ae125c7c6b2cfec89746d1298a306ad78 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Tue, 16 Jan 2018 17:38:36 +0000 | ||
4 | Subject: Fix putty-transfer regression test | ||
5 | |||
6 | The test key file is still called putty.rsa2, not putty.rsa. | ||
7 | |||
8 | Forwarded: no | ||
9 | Last-Update: 2018-01-16 | ||
10 | |||
11 | Patch-Name: fix-regress-putty-transfer.patch | ||
12 | --- | ||
13 | regress/putty-transfer.sh | 4 ++-- | ||
14 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/regress/putty-transfer.sh b/regress/putty-transfer.sh | ||
17 | index 32c79f9e..57e46540 100644 | ||
18 | --- a/regress/putty-transfer.sh | ||
19 | +++ b/regress/putty-transfer.sh | ||
20 | @@ -15,7 +15,7 @@ for c in 0 1 ; do | ||
21 | ${OBJ}/.putty/sessions/compression_$c | ||
22 | echo "Compression=$c" >> ${OBJ}/.putty/sessions/kex_$k | ||
23 | env HOME=$PWD ${PLINK} -load compression_$c -batch \ | ||
24 | - -i putty.rsa cat ${DATA} > ${COPY} | ||
25 | + -i putty.rsa2 cat ${DATA} > ${COPY} | ||
26 | if [ $? -ne 0 ]; then | ||
27 | fail "ssh cat $DATA failed" | ||
28 | fi | ||
29 | @@ -26,7 +26,7 @@ for c in 0 1 ; do | ||
30 | rm -f ${COPY} | ||
31 | dd if=$DATA obs=${s} 2> /dev/null | \ | ||
32 | env HOME=$PWD ${PLINK} -load compression_$c \ | ||
33 | - -batch -i putty.rsa \ | ||
34 | + -batch -i putty.rsa2 \ | ||
35 | "cat > ${COPY}" | ||
36 | if [ $? -ne 0 ]; then | ||
37 | fail "ssh cat $DATA failed" | ||
diff --git a/debian/patches/gnome-ssh-askpass2-icon.patch b/debian/patches/gnome-ssh-askpass2-icon.patch new file mode 100644 index 000000000..e46c0f8b2 --- /dev/null +++ b/debian/patches/gnome-ssh-askpass2-icon.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | From 18950b79898be885c6b77d463367639647e54e28 Mon Sep 17 00:00:00 2001 | ||
2 | From: Vincent Untz <vuntz@ubuntu.com> | ||
3 | Date: Sun, 9 Feb 2014 16:10:16 +0000 | ||
4 | Subject: Give the ssh-askpass-gnome window a default icon | ||
5 | |||
6 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/27152 | ||
7 | Last-Update: 2010-02-28 | ||
8 | |||
9 | Patch-Name: gnome-ssh-askpass2-icon.patch | ||
10 | --- | ||
11 | contrib/gnome-ssh-askpass2.c | 2 ++ | ||
12 | 1 file changed, 2 insertions(+) | ||
13 | |||
14 | diff --git a/contrib/gnome-ssh-askpass2.c b/contrib/gnome-ssh-askpass2.c | ||
15 | index 535a6927..e37a1338 100644 | ||
16 | --- a/contrib/gnome-ssh-askpass2.c | ||
17 | +++ b/contrib/gnome-ssh-askpass2.c | ||
18 | @@ -211,6 +211,8 @@ main(int argc, char **argv) | ||
19 | |||
20 | gtk_init(&argc, &argv); | ||
21 | |||
22 | + gtk_window_set_default_icon_from_file ("/usr/share/pixmaps/ssh-askpass-gnome.png", NULL); | ||
23 | + | ||
24 | if (argc > 1) { | ||
25 | message = g_strjoinv(" ", argv + 1); | ||
26 | } else { | ||
diff --git a/debian/patches/gssapi.patch b/debian/patches/gssapi.patch new file mode 100644 index 000000000..0726a5020 --- /dev/null +++ b/debian/patches/gssapi.patch | |||
@@ -0,0 +1,3300 @@ | |||
1 | From 4e70490950e5c5134df48848affaf73685bf0284 Mon Sep 17 00:00:00 2001 | ||
2 | From: Simon Wilkinson <simon@sxw.org.uk> | ||
3 | Date: Sun, 9 Feb 2014 16:09:48 +0000 | ||
4 | Subject: GSSAPI key exchange support | ||
5 | |||
6 | This patch has been rejected upstream: "None of the OpenSSH developers are | ||
7 | in favour of adding this, and this situation has not changed for several | ||
8 | years. This is not a slight on Simon's patch, which is of fine quality, but | ||
9 | just that a) we don't trust GSSAPI implementations that much and b) we don't | ||
10 | like adding new KEX since they are pre-auth attack surface. This one is | ||
11 | particularly scary, since it requires hooks out to typically root-owned | ||
12 | system resources." | ||
13 | |||
14 | However, quite a lot of people rely on this in Debian, and it's better to | ||
15 | have it merged into the main openssh package rather than having separate | ||
16 | -krb5 packages (as we used to have). It seems to have a generally good | ||
17 | security history. | ||
18 | |||
19 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1242 | ||
20 | Last-Updated: 2017-10-04 | ||
21 | |||
22 | Patch-Name: gssapi.patch | ||
23 | --- | ||
24 | ChangeLog.gssapi | 113 +++++++++++++++++++ | ||
25 | Makefile.in | 3 +- | ||
26 | auth-krb5.c | 17 ++- | ||
27 | auth.c | 96 +--------------- | ||
28 | auth2-gss.c | 49 +++++++- | ||
29 | auth2.c | 2 + | ||
30 | canohost.c | 93 +++++++++++++++ | ||
31 | canohost.h | 3 + | ||
32 | clientloop.c | 15 ++- | ||
33 | config.h.in | 6 + | ||
34 | configure.ac | 24 ++++ | ||
35 | gss-genr.c | 275 +++++++++++++++++++++++++++++++++++++++++++- | ||
36 | gss-serv-krb5.c | 85 ++++++++++++-- | ||
37 | gss-serv.c | 184 +++++++++++++++++++++++++++--- | ||
38 | kex.c | 19 ++++ | ||
39 | kex.h | 14 +++ | ||
40 | kexgssc.c | 338 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
41 | kexgsss.c | 295 ++++++++++++++++++++++++++++++++++++++++++++++++ | ||
42 | monitor.c | 115 +++++++++++++++++-- | ||
43 | monitor.h | 3 + | ||
44 | monitor_wrap.c | 47 +++++++- | ||
45 | monitor_wrap.h | 4 +- | ||
46 | readconf.c | 43 +++++++ | ||
47 | readconf.h | 5 + | ||
48 | servconf.c | 26 +++++ | ||
49 | servconf.h | 2 + | ||
50 | ssh-gss.h | 41 ++++++- | ||
51 | ssh_config | 2 + | ||
52 | ssh_config.5 | 32 ++++++ | ||
53 | sshconnect2.c | 131 ++++++++++++++++++++- | ||
54 | sshd.c | 112 +++++++++++++++++- | ||
55 | sshd_config | 2 + | ||
56 | sshd_config.5 | 10 ++ | ||
57 | sshkey.c | 3 +- | ||
58 | sshkey.h | 1 + | ||
59 | 35 files changed, 2063 insertions(+), 147 deletions(-) | ||
60 | create mode 100644 ChangeLog.gssapi | ||
61 | create mode 100644 kexgssc.c | ||
62 | create mode 100644 kexgsss.c | ||
63 | |||
64 | diff --git a/ChangeLog.gssapi b/ChangeLog.gssapi | ||
65 | new file mode 100644 | ||
66 | index 00000000..f117a336 | ||
67 | --- /dev/null | ||
68 | +++ b/ChangeLog.gssapi | ||
69 | @@ -0,0 +1,113 @@ | ||
70 | +20110101 | ||
71 | + - Finally update for OpenSSH 5.6p1 | ||
72 | + - Add GSSAPIServerIdentity option from Jim Basney | ||
73 | + | ||
74 | +20100308 | ||
75 | + - [ Makefile.in, key.c, key.h ] | ||
76 | + Updates for OpenSSH 5.4p1 | ||
77 | + - [ servconf.c ] | ||
78 | + Include GSSAPI options in the sshd -T configuration dump, and flag | ||
79 | + some older configuration options as being unsupported. Thanks to Colin | ||
80 | + Watson. | ||
81 | + - | ||
82 | + | ||
83 | +20100124 | ||
84 | + - [ sshconnect2.c ] | ||
85 | + Adapt to deal with additional element in Authmethod structure. Thanks to | ||
86 | + Colin Watson | ||
87 | + | ||
88 | +20090615 | ||
89 | + - [ gss-genr.c gss-serv.c kexgssc.c kexgsss.c monitor.c sshconnect2.c | ||
90 | + sshd.c ] | ||
91 | + Fix issues identified by Greg Hudson following a code review | ||
92 | + Check return value of gss_indicate_mechs | ||
93 | + Protect GSSAPI calls in monitor, so they can only be used if enabled | ||
94 | + Check return values of bignum functions in key exchange | ||
95 | + Use BN_clear_free to clear other side's DH value | ||
96 | + Make ssh_gssapi_id_kex more robust | ||
97 | + Only configure kex table pointers if GSSAPI is enabled | ||
98 | + Don't leak mechanism list, or gss mechanism list | ||
99 | + Cast data.length before printing | ||
100 | + If serverkey isn't provided, use an empty string, rather than NULL | ||
101 | + | ||
102 | +20090201 | ||
103 | + - [ gss-genr.c gss-serv.c kex.h kexgssc.c readconf.c readconf.h ssh-gss.h | ||
104 | + ssh_config.5 sshconnet2.c ] | ||
105 | + Add support for the GSSAPIClientIdentity option, which allows the user | ||
106 | + to specify which GSSAPI identity to use to contact a given server | ||
107 | + | ||
108 | +20080404 | ||
109 | + - [ gss-serv.c ] | ||
110 | + Add code to actually implement GSSAPIStrictAcceptCheck, which had somehow | ||
111 | + been omitted from a previous version of this patch. Reported by Borislav | ||
112 | + Stoichkov | ||
113 | + | ||
114 | +20070317 | ||
115 | + - [ gss-serv-krb5.c ] | ||
116 | + Remove C99ism, where new_ccname was being declared in the middle of a | ||
117 | + function | ||
118 | + | ||
119 | +20061220 | ||
120 | + - [ servconf.c ] | ||
121 | + Make default for GSSAPIStrictAcceptorCheck be Yes, to match previous, and | ||
122 | + documented, behaviour. Reported by Dan Watson. | ||
123 | + | ||
124 | +20060910 | ||
125 | + - [ gss-genr.c kexgssc.c kexgsss.c kex.h monitor.c sshconnect2.c sshd.c | ||
126 | + ssh-gss.h ] | ||
127 | + add support for gss-group14-sha1 key exchange mechanisms | ||
128 | + - [ gss-serv.c servconf.c servconf.h sshd_config sshd_config.5 ] | ||
129 | + Add GSSAPIStrictAcceptorCheck option to allow the disabling of | ||
130 | + acceptor principal checking on multi-homed machines. | ||
131 | + <Bugzilla #928> | ||
132 | + - [ sshd_config ssh_config ] | ||
133 | + Add settings for GSSAPIKeyExchange and GSSAPITrustDNS to the sample | ||
134 | + configuration files | ||
135 | + - [ kexgss.c kegsss.c sshconnect2.c sshd.c ] | ||
136 | + Code cleanup. Replace strlen/xmalloc/snprintf sequences with xasprintf() | ||
137 | + Limit length of error messages displayed by client | ||
138 | + | ||
139 | +20060909 | ||
140 | + - [ gss-genr.c gss-serv.c ] | ||
141 | + move ssh_gssapi_acquire_cred() and ssh_gssapi_server_ctx to be server | ||
142 | + only, where they belong | ||
143 | + <Bugzilla #1225> | ||
144 | + | ||
145 | +20060829 | ||
146 | + - [ gss-serv-krb5.c ] | ||
147 | + Fix CCAPI credentials cache name when creating KRB5CCNAME environment | ||
148 | + variable | ||
149 | + | ||
150 | +20060828 | ||
151 | + - [ gss-genr.c ] | ||
152 | + Avoid Heimdal context freeing problem | ||
153 | + <Fixed upstream 20060829> | ||
154 | + | ||
155 | +20060818 | ||
156 | + - [ gss-genr.c ssh-gss.h sshconnect2.c ] | ||
157 | + Make sure that SPENGO is disabled | ||
158 | + <Bugzilla #1218 - Fixed upstream 20060818> | ||
159 | + | ||
160 | +20060421 | ||
161 | + - [ gssgenr.c, sshconnect2.c ] | ||
162 | + a few type changes (signed versus unsigned, int versus size_t) to | ||
163 | + fix compiler errors/warnings | ||
164 | + (from jbasney AT ncsa.uiuc.edu) | ||
165 | + - [ kexgssc.c, sshconnect2.c ] | ||
166 | + fix uninitialized variable warnings | ||
167 | + (from jbasney AT ncsa.uiuc.edu) | ||
168 | + - [ gssgenr.c ] | ||
169 | + pass oid to gss_display_status (helpful when using GSSAPI mechglue) | ||
170 | + (from jbasney AT ncsa.uiuc.edu) | ||
171 | + <Bugzilla #1220 > | ||
172 | + - [ gss-serv-krb5.c ] | ||
173 | + #ifdef HAVE_GSSAPI_KRB5 should be #ifdef HAVE_GSSAPI_KRB5_H | ||
174 | + (from jbasney AT ncsa.uiuc.edu) | ||
175 | + <Fixed upstream 20060304> | ||
176 | + - [ readconf.c, readconf.h, ssh_config.5, sshconnect2.c | ||
177 | + add client-side GssapiKeyExchange option | ||
178 | + (from jbasney AT ncsa.uiuc.edu) | ||
179 | + - [ sshconnect2.c ] | ||
180 | + add support for GssapiTrustDns option for gssapi-with-mic | ||
181 | + (from jbasney AT ncsa.uiuc.edu) | ||
182 | + <gssapi-with-mic support is Bugzilla #1008> | ||
183 | diff --git a/Makefile.in b/Makefile.in | ||
184 | index c52ce191..f6e9fe4c 100644 | ||
185 | --- a/Makefile.in | ||
186 | +++ b/Makefile.in | ||
187 | @@ -92,6 +92,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \ | ||
188 | kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \ | ||
189 | kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \ | ||
190 | kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o \ | ||
191 | + kexgssc.o \ | ||
192 | platform-pledge.o platform-tracing.o platform-misc.o | ||
193 | |||
194 | SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \ | ||
195 | @@ -105,7 +106,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o \ | ||
196 | auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \ | ||
197 | auth2-none.o auth2-passwd.o auth2-pubkey.o \ | ||
198 | monitor.o monitor_wrap.o auth-krb5.o \ | ||
199 | - auth2-gss.o gss-serv.o gss-serv-krb5.o \ | ||
200 | + auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o \ | ||
201 | loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \ | ||
202 | sftp-server.o sftp-common.o \ | ||
203 | sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \ | ||
204 | diff --git a/auth-krb5.c b/auth-krb5.c | ||
205 | index a5a81ed2..38e7fee2 100644 | ||
206 | --- a/auth-krb5.c | ||
207 | +++ b/auth-krb5.c | ||
208 | @@ -182,8 +182,13 @@ auth_krb5_password(Authctxt *authctxt, const char *password) | ||
209 | |||
210 | len = strlen(authctxt->krb5_ticket_file) + 6; | ||
211 | authctxt->krb5_ccname = xmalloc(len); | ||
212 | +#ifdef USE_CCAPI | ||
213 | + snprintf(authctxt->krb5_ccname, len, "API:%s", | ||
214 | + authctxt->krb5_ticket_file); | ||
215 | +#else | ||
216 | snprintf(authctxt->krb5_ccname, len, "FILE:%s", | ||
217 | authctxt->krb5_ticket_file); | ||
218 | +#endif | ||
219 | |||
220 | #ifdef USE_PAM | ||
221 | if (options.use_pam) | ||
222 | @@ -240,15 +245,22 @@ krb5_cleanup_proc(Authctxt *authctxt) | ||
223 | #ifndef HEIMDAL | ||
224 | krb5_error_code | ||
225 | ssh_krb5_cc_gen(krb5_context ctx, krb5_ccache *ccache) { | ||
226 | - int tmpfd, ret, oerrno; | ||
227 | + int ret, oerrno; | ||
228 | char ccname[40]; | ||
229 | mode_t old_umask; | ||
230 | +#ifdef USE_CCAPI | ||
231 | + char cctemplate[] = "API:krb5cc_%d"; | ||
232 | +#else | ||
233 | + char cctemplate[] = "FILE:/tmp/krb5cc_%d_XXXXXXXXXX"; | ||
234 | + int tmpfd; | ||
235 | +#endif | ||
236 | |||
237 | ret = snprintf(ccname, sizeof(ccname), | ||
238 | - "FILE:/tmp/krb5cc_%d_XXXXXXXXXX", geteuid()); | ||
239 | + cctemplate, geteuid()); | ||
240 | if (ret < 0 || (size_t)ret >= sizeof(ccname)) | ||
241 | return ENOMEM; | ||
242 | |||
243 | +#ifndef USE_CCAPI | ||
244 | old_umask = umask(0177); | ||
245 | tmpfd = mkstemp(ccname + strlen("FILE:")); | ||
246 | oerrno = errno; | ||
247 | @@ -265,6 +277,7 @@ ssh_krb5_cc_gen(krb5_context ctx, krb5_ccache *ccache) { | ||
248 | return oerrno; | ||
249 | } | ||
250 | close(tmpfd); | ||
251 | +#endif | ||
252 | |||
253 | return (krb5_cc_resolve(ctx, ccname, ccache)); | ||
254 | } | ||
255 | diff --git a/auth.c b/auth.c | ||
256 | index a4490617..6aec3605 100644 | ||
257 | --- a/auth.c | ||
258 | +++ b/auth.c | ||
259 | @@ -395,7 +395,8 @@ auth_root_allowed(const char *method) | ||
260 | case PERMIT_NO_PASSWD: | ||
261 | if (strcmp(method, "publickey") == 0 || | ||
262 | strcmp(method, "hostbased") == 0 || | ||
263 | - strcmp(method, "gssapi-with-mic") == 0) | ||
264 | + strcmp(method, "gssapi-with-mic") == 0 || | ||
265 | + strcmp(method, "gssapi-keyex") == 0) | ||
266 | return 1; | ||
267 | break; | ||
268 | case PERMIT_FORCED_ONLY: | ||
269 | @@ -727,99 +728,6 @@ fakepw(void) | ||
270 | return (&fake); | ||
271 | } | ||
272 | |||
273 | -/* | ||
274 | - * Returns the remote DNS hostname as a string. The returned string must not | ||
275 | - * be freed. NB. this will usually trigger a DNS query the first time it is | ||
276 | - * called. | ||
277 | - * This function does additional checks on the hostname to mitigate some | ||
278 | - * attacks on legacy rhosts-style authentication. | ||
279 | - * XXX is RhostsRSAAuthentication vulnerable to these? | ||
280 | - * XXX Can we remove these checks? (or if not, remove RhostsRSAAuthentication?) | ||
281 | - */ | ||
282 | - | ||
283 | -static char * | ||
284 | -remote_hostname(struct ssh *ssh) | ||
285 | -{ | ||
286 | - struct sockaddr_storage from; | ||
287 | - socklen_t fromlen; | ||
288 | - struct addrinfo hints, *ai, *aitop; | ||
289 | - char name[NI_MAXHOST], ntop2[NI_MAXHOST]; | ||
290 | - const char *ntop = ssh_remote_ipaddr(ssh); | ||
291 | - | ||
292 | - /* Get IP address of client. */ | ||
293 | - fromlen = sizeof(from); | ||
294 | - memset(&from, 0, sizeof(from)); | ||
295 | - if (getpeername(ssh_packet_get_connection_in(ssh), | ||
296 | - (struct sockaddr *)&from, &fromlen) < 0) { | ||
297 | - debug("getpeername failed: %.100s", strerror(errno)); | ||
298 | - return strdup(ntop); | ||
299 | - } | ||
300 | - | ||
301 | - ipv64_normalise_mapped(&from, &fromlen); | ||
302 | - if (from.ss_family == AF_INET6) | ||
303 | - fromlen = sizeof(struct sockaddr_in6); | ||
304 | - | ||
305 | - debug3("Trying to reverse map address %.100s.", ntop); | ||
306 | - /* Map the IP address to a host name. */ | ||
307 | - if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name), | ||
308 | - NULL, 0, NI_NAMEREQD) != 0) { | ||
309 | - /* Host name not found. Use ip address. */ | ||
310 | - return strdup(ntop); | ||
311 | - } | ||
312 | - | ||
313 | - /* | ||
314 | - * if reverse lookup result looks like a numeric hostname, | ||
315 | - * someone is trying to trick us by PTR record like following: | ||
316 | - * 1.1.1.10.in-addr.arpa. IN PTR 2.3.4.5 | ||
317 | - */ | ||
318 | - memset(&hints, 0, sizeof(hints)); | ||
319 | - hints.ai_socktype = SOCK_DGRAM; /*dummy*/ | ||
320 | - hints.ai_flags = AI_NUMERICHOST; | ||
321 | - if (getaddrinfo(name, NULL, &hints, &ai) == 0) { | ||
322 | - logit("Nasty PTR record \"%s\" is set up for %s, ignoring", | ||
323 | - name, ntop); | ||
324 | - freeaddrinfo(ai); | ||
325 | - return strdup(ntop); | ||
326 | - } | ||
327 | - | ||
328 | - /* Names are stored in lowercase. */ | ||
329 | - lowercase(name); | ||
330 | - | ||
331 | - /* | ||
332 | - * Map it back to an IP address and check that the given | ||
333 | - * address actually is an address of this host. This is | ||
334 | - * necessary because anyone with access to a name server can | ||
335 | - * define arbitrary names for an IP address. Mapping from | ||
336 | - * name to IP address can be trusted better (but can still be | ||
337 | - * fooled if the intruder has access to the name server of | ||
338 | - * the domain). | ||
339 | - */ | ||
340 | - memset(&hints, 0, sizeof(hints)); | ||
341 | - hints.ai_family = from.ss_family; | ||
342 | - hints.ai_socktype = SOCK_STREAM; | ||
343 | - if (getaddrinfo(name, NULL, &hints, &aitop) != 0) { | ||
344 | - logit("reverse mapping checking getaddrinfo for %.700s " | ||
345 | - "[%s] failed.", name, ntop); | ||
346 | - return strdup(ntop); | ||
347 | - } | ||
348 | - /* Look for the address from the list of addresses. */ | ||
349 | - for (ai = aitop; ai; ai = ai->ai_next) { | ||
350 | - if (getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop2, | ||
351 | - sizeof(ntop2), NULL, 0, NI_NUMERICHOST) == 0 && | ||
352 | - (strcmp(ntop, ntop2) == 0)) | ||
353 | - break; | ||
354 | - } | ||
355 | - freeaddrinfo(aitop); | ||
356 | - /* If we reached the end of the list, the address was not there. */ | ||
357 | - if (ai == NULL) { | ||
358 | - /* Address not found for the host name. */ | ||
359 | - logit("Address %.100s maps to %.600s, but this does not " | ||
360 | - "map back to the address.", ntop, name); | ||
361 | - return strdup(ntop); | ||
362 | - } | ||
363 | - return strdup(name); | ||
364 | -} | ||
365 | - | ||
366 | /* | ||
367 | * Return the canonical name of the host in the other side of the current | ||
368 | * connection. The host name is cached, so it is efficient to call this | ||
369 | diff --git a/auth2-gss.c b/auth2-gss.c | ||
370 | index 589283b7..fd411d3a 100644 | ||
371 | --- a/auth2-gss.c | ||
372 | +++ b/auth2-gss.c | ||
373 | @@ -1,7 +1,7 @@ | ||
374 | /* $OpenBSD: auth2-gss.c,v 1.26 2017/06/24 06:34:38 djm Exp $ */ | ||
375 | |||
376 | /* | ||
377 | - * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | ||
378 | + * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved. | ||
379 | * | ||
380 | * Redistribution and use in source and binary forms, with or without | ||
381 | * modification, are permitted provided that the following conditions | ||
382 | @@ -53,6 +53,41 @@ static int input_gssapi_mic(int type, u_int32_t plen, struct ssh *ssh); | ||
383 | static int input_gssapi_exchange_complete(int type, u_int32_t plen, struct ssh *ssh); | ||
384 | static int input_gssapi_errtok(int, u_int32_t, struct ssh *); | ||
385 | |||
386 | +/* | ||
387 | + * The 'gssapi_keyex' userauth mechanism. | ||
388 | + */ | ||
389 | +static int | ||
390 | +userauth_gsskeyex(struct ssh *ssh) | ||
391 | +{ | ||
392 | + Authctxt *authctxt = ssh->authctxt; | ||
393 | + int authenticated = 0; | ||
394 | + Buffer b; | ||
395 | + gss_buffer_desc mic, gssbuf; | ||
396 | + u_int len; | ||
397 | + | ||
398 | + mic.value = packet_get_string(&len); | ||
399 | + mic.length = len; | ||
400 | + | ||
401 | + packet_check_eom(); | ||
402 | + | ||
403 | + ssh_gssapi_buildmic(&b, authctxt->user, authctxt->service, | ||
404 | + "gssapi-keyex"); | ||
405 | + | ||
406 | + gssbuf.value = buffer_ptr(&b); | ||
407 | + gssbuf.length = buffer_len(&b); | ||
408 | + | ||
409 | + /* gss_kex_context is NULL with privsep, so we can't check it here */ | ||
410 | + if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gss_kex_context, | ||
411 | + &gssbuf, &mic)))) | ||
412 | + authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user, | ||
413 | + authctxt->pw)); | ||
414 | + | ||
415 | + buffer_free(&b); | ||
416 | + free(mic.value); | ||
417 | + | ||
418 | + return (authenticated); | ||
419 | +} | ||
420 | + | ||
421 | /* | ||
422 | * We only support those mechanisms that we know about (ie ones that we know | ||
423 | * how to check local user kuserok and the like) | ||
424 | @@ -240,7 +275,8 @@ input_gssapi_exchange_complete(int type, u_int32_t plen, struct ssh *ssh) | ||
425 | |||
426 | packet_check_eom(); | ||
427 | |||
428 | - authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user)); | ||
429 | + authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user, | ||
430 | + authctxt->pw)); | ||
431 | |||
432 | if ((!use_privsep || mm_is_monitor()) && | ||
433 | (displayname = ssh_gssapi_displayname()) != NULL) | ||
434 | @@ -281,7 +317,8 @@ input_gssapi_mic(int type, u_int32_t plen, struct ssh *ssh) | ||
435 | gssbuf.length = buffer_len(&b); | ||
436 | |||
437 | if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gssctxt, &gssbuf, &mic)))) | ||
438 | - authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user)); | ||
439 | + authenticated = | ||
440 | + PRIVSEP(ssh_gssapi_userok(authctxt->user, authctxt->pw)); | ||
441 | else | ||
442 | logit("GSSAPI MIC check failed"); | ||
443 | |||
444 | @@ -301,6 +338,12 @@ input_gssapi_mic(int type, u_int32_t plen, struct ssh *ssh) | ||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | +Authmethod method_gsskeyex = { | ||
449 | + "gssapi-keyex", | ||
450 | + userauth_gsskeyex, | ||
451 | + &options.gss_authentication | ||
452 | +}; | ||
453 | + | ||
454 | Authmethod method_gssapi = { | ||
455 | "gssapi-with-mic", | ||
456 | userauth_gssapi, | ||
457 | diff --git a/auth2.c b/auth2.c | ||
458 | index 862e0996..54070e3a 100644 | ||
459 | --- a/auth2.c | ||
460 | +++ b/auth2.c | ||
461 | @@ -72,6 +72,7 @@ extern Authmethod method_passwd; | ||
462 | extern Authmethod method_kbdint; | ||
463 | extern Authmethod method_hostbased; | ||
464 | #ifdef GSSAPI | ||
465 | +extern Authmethod method_gsskeyex; | ||
466 | extern Authmethod method_gssapi; | ||
467 | #endif | ||
468 | |||
469 | @@ -79,6 +80,7 @@ Authmethod *authmethods[] = { | ||
470 | &method_none, | ||
471 | &method_pubkey, | ||
472 | #ifdef GSSAPI | ||
473 | + &method_gsskeyex, | ||
474 | &method_gssapi, | ||
475 | #endif | ||
476 | &method_passwd, | ||
477 | diff --git a/canohost.c b/canohost.c | ||
478 | index f71a0856..404731d2 100644 | ||
479 | --- a/canohost.c | ||
480 | +++ b/canohost.c | ||
481 | @@ -35,6 +35,99 @@ | ||
482 | #include "canohost.h" | ||
483 | #include "misc.h" | ||
484 | |||
485 | +/* | ||
486 | + * Returns the remote DNS hostname as a string. The returned string must not | ||
487 | + * be freed. NB. this will usually trigger a DNS query the first time it is | ||
488 | + * called. | ||
489 | + * This function does additional checks on the hostname to mitigate some | ||
490 | + * attacks on legacy rhosts-style authentication. | ||
491 | + * XXX is RhostsRSAAuthentication vulnerable to these? | ||
492 | + * XXX Can we remove these checks? (or if not, remove RhostsRSAAuthentication?) | ||
493 | + */ | ||
494 | + | ||
495 | +char * | ||
496 | +remote_hostname(struct ssh *ssh) | ||
497 | +{ | ||
498 | + struct sockaddr_storage from; | ||
499 | + socklen_t fromlen; | ||
500 | + struct addrinfo hints, *ai, *aitop; | ||
501 | + char name[NI_MAXHOST], ntop2[NI_MAXHOST]; | ||
502 | + const char *ntop = ssh_remote_ipaddr(ssh); | ||
503 | + | ||
504 | + /* Get IP address of client. */ | ||
505 | + fromlen = sizeof(from); | ||
506 | + memset(&from, 0, sizeof(from)); | ||
507 | + if (getpeername(ssh_packet_get_connection_in(ssh), | ||
508 | + (struct sockaddr *)&from, &fromlen) < 0) { | ||
509 | + debug("getpeername failed: %.100s", strerror(errno)); | ||
510 | + return strdup(ntop); | ||
511 | + } | ||
512 | + | ||
513 | + ipv64_normalise_mapped(&from, &fromlen); | ||
514 | + if (from.ss_family == AF_INET6) | ||
515 | + fromlen = sizeof(struct sockaddr_in6); | ||
516 | + | ||
517 | + debug3("Trying to reverse map address %.100s.", ntop); | ||
518 | + /* Map the IP address to a host name. */ | ||
519 | + if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name), | ||
520 | + NULL, 0, NI_NAMEREQD) != 0) { | ||
521 | + /* Host name not found. Use ip address. */ | ||
522 | + return strdup(ntop); | ||
523 | + } | ||
524 | + | ||
525 | + /* | ||
526 | + * if reverse lookup result looks like a numeric hostname, | ||
527 | + * someone is trying to trick us by PTR record like following: | ||
528 | + * 1.1.1.10.in-addr.arpa. IN PTR 2.3.4.5 | ||
529 | + */ | ||
530 | + memset(&hints, 0, sizeof(hints)); | ||
531 | + hints.ai_socktype = SOCK_DGRAM; /*dummy*/ | ||
532 | + hints.ai_flags = AI_NUMERICHOST; | ||
533 | + if (getaddrinfo(name, NULL, &hints, &ai) == 0) { | ||
534 | + logit("Nasty PTR record \"%s\" is set up for %s, ignoring", | ||
535 | + name, ntop); | ||
536 | + freeaddrinfo(ai); | ||
537 | + return strdup(ntop); | ||
538 | + } | ||
539 | + | ||
540 | + /* Names are stored in lowercase. */ | ||
541 | + lowercase(name); | ||
542 | + | ||
543 | + /* | ||
544 | + * Map it back to an IP address and check that the given | ||
545 | + * address actually is an address of this host. This is | ||
546 | + * necessary because anyone with access to a name server can | ||
547 | + * define arbitrary names for an IP address. Mapping from | ||
548 | + * name to IP address can be trusted better (but can still be | ||
549 | + * fooled if the intruder has access to the name server of | ||
550 | + * the domain). | ||
551 | + */ | ||
552 | + memset(&hints, 0, sizeof(hints)); | ||
553 | + hints.ai_family = from.ss_family; | ||
554 | + hints.ai_socktype = SOCK_STREAM; | ||
555 | + if (getaddrinfo(name, NULL, &hints, &aitop) != 0) { | ||
556 | + logit("reverse mapping checking getaddrinfo for %.700s " | ||
557 | + "[%s] failed.", name, ntop); | ||
558 | + return strdup(ntop); | ||
559 | + } | ||
560 | + /* Look for the address from the list of addresses. */ | ||
561 | + for (ai = aitop; ai; ai = ai->ai_next) { | ||
562 | + if (getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop2, | ||
563 | + sizeof(ntop2), NULL, 0, NI_NUMERICHOST) == 0 && | ||
564 | + (strcmp(ntop, ntop2) == 0)) | ||
565 | + break; | ||
566 | + } | ||
567 | + freeaddrinfo(aitop); | ||
568 | + /* If we reached the end of the list, the address was not there. */ | ||
569 | + if (ai == NULL) { | ||
570 | + /* Address not found for the host name. */ | ||
571 | + logit("Address %.100s maps to %.600s, but this does not " | ||
572 | + "map back to the address.", ntop, name); | ||
573 | + return strdup(ntop); | ||
574 | + } | ||
575 | + return strdup(name); | ||
576 | +} | ||
577 | + | ||
578 | void | ||
579 | ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len) | ||
580 | { | ||
581 | diff --git a/canohost.h b/canohost.h | ||
582 | index 26d62855..0cadc9f1 100644 | ||
583 | --- a/canohost.h | ||
584 | +++ b/canohost.h | ||
585 | @@ -15,6 +15,9 @@ | ||
586 | #ifndef _CANOHOST_H | ||
587 | #define _CANOHOST_H | ||
588 | |||
589 | +struct ssh; | ||
590 | + | ||
591 | +char *remote_hostname(struct ssh *); | ||
592 | char *get_peer_ipaddr(int); | ||
593 | int get_peer_port(int); | ||
594 | char *get_local_ipaddr(int); | ||
595 | diff --git a/clientloop.c b/clientloop.c | ||
596 | index 791d336e..0010b833 100644 | ||
597 | --- a/clientloop.c | ||
598 | +++ b/clientloop.c | ||
599 | @@ -112,6 +112,10 @@ | ||
600 | #include "ssherr.h" | ||
601 | #include "hostfile.h" | ||
602 | |||
603 | +#ifdef GSSAPI | ||
604 | +#include "ssh-gss.h" | ||
605 | +#endif | ||
606 | + | ||
607 | /* import options */ | ||
608 | extern Options options; | ||
609 | |||
610 | @@ -1349,9 +1353,18 @@ client_loop(struct ssh *ssh, int have_pty, int escape_char_arg, | ||
611 | break; | ||
612 | |||
613 | /* Do channel operations unless rekeying in progress. */ | ||
614 | - if (!ssh_packet_is_rekeying(ssh)) | ||
615 | + if (!ssh_packet_is_rekeying(ssh)) { | ||
616 | channel_after_select(ssh, readset, writeset); | ||
617 | |||
618 | +#ifdef GSSAPI | ||
619 | + if (options.gss_renewal_rekey && | ||
620 | + ssh_gssapi_credentials_updated(NULL)) { | ||
621 | + debug("credentials updated - forcing rekey"); | ||
622 | + need_rekeying = 1; | ||
623 | + } | ||
624 | +#endif | ||
625 | + } | ||
626 | + | ||
627 | /* Buffer input from the connection. */ | ||
628 | client_process_net_input(readset); | ||
629 | |||
630 | diff --git a/config.h.in b/config.h.in | ||
631 | index 63fc548b..0b244fd5 100644 | ||
632 | --- a/config.h.in | ||
633 | +++ b/config.h.in | ||
634 | @@ -1696,6 +1696,9 @@ | ||
635 | /* Use btmp to log bad logins */ | ||
636 | #undef USE_BTMP | ||
637 | |||
638 | +/* platform uses an in-memory credentials cache */ | ||
639 | +#undef USE_CCAPI | ||
640 | + | ||
641 | /* Use libedit for sftp */ | ||
642 | #undef USE_LIBEDIT | ||
643 | |||
644 | @@ -1711,6 +1714,9 @@ | ||
645 | /* Use PIPES instead of a socketpair() */ | ||
646 | #undef USE_PIPES | ||
647 | |||
648 | +/* platform has the Security Authorization Session API */ | ||
649 | +#undef USE_SECURITY_SESSION_API | ||
650 | + | ||
651 | /* Define if you have Solaris privileges */ | ||
652 | #undef USE_SOLARIS_PRIVS | ||
653 | |||
654 | diff --git a/configure.ac b/configure.ac | ||
655 | index 889f5063..84bfad8c 100644 | ||
656 | --- a/configure.ac | ||
657 | +++ b/configure.ac | ||
658 | @@ -621,6 +621,30 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) | ||
659 | [Use tunnel device compatibility to OpenBSD]) | ||
660 | AC_DEFINE([SSH_TUN_PREPEND_AF], [1], | ||
661 | [Prepend the address family to IP tunnel traffic]) | ||
662 | + AC_MSG_CHECKING([if we have the Security Authorization Session API]) | ||
663 | + AC_TRY_COMPILE([#include <Security/AuthSession.h>], | ||
664 | + [SessionCreate(0, 0);], | ||
665 | + [ac_cv_use_security_session_api="yes" | ||
666 | + AC_DEFINE([USE_SECURITY_SESSION_API], [1], | ||
667 | + [platform has the Security Authorization Session API]) | ||
668 | + LIBS="$LIBS -framework Security" | ||
669 | + AC_MSG_RESULT([yes])], | ||
670 | + [ac_cv_use_security_session_api="no" | ||
671 | + AC_MSG_RESULT([no])]) | ||
672 | + AC_MSG_CHECKING([if we have an in-memory credentials cache]) | ||
673 | + AC_TRY_COMPILE( | ||
674 | + [#include <Kerberos/Kerberos.h>], | ||
675 | + [cc_context_t c; | ||
676 | + (void) cc_initialize (&c, 0, NULL, NULL);], | ||
677 | + [AC_DEFINE([USE_CCAPI], [1], | ||
678 | + [platform uses an in-memory credentials cache]) | ||
679 | + LIBS="$LIBS -framework Security" | ||
680 | + AC_MSG_RESULT([yes]) | ||
681 | + if test "x$ac_cv_use_security_session_api" = "xno"; then | ||
682 | + AC_MSG_ERROR([*** Need a security framework to use the credentials cache API ***]) | ||
683 | + fi], | ||
684 | + [AC_MSG_RESULT([no])] | ||
685 | + ) | ||
686 | m4_pattern_allow([AU_IPv]) | ||
687 | AC_CHECK_DECL([AU_IPv4], [], | ||
688 | AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records]) | ||
689 | diff --git a/gss-genr.c b/gss-genr.c | ||
690 | index 62559ed9..0b3ae073 100644 | ||
691 | --- a/gss-genr.c | ||
692 | +++ b/gss-genr.c | ||
693 | @@ -1,7 +1,7 @@ | ||
694 | /* $OpenBSD: gss-genr.c,v 1.24 2016/09/12 01:22:38 deraadt Exp $ */ | ||
695 | |||
696 | /* | ||
697 | - * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved. | ||
698 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
699 | * | ||
700 | * Redistribution and use in source and binary forms, with or without | ||
701 | * modification, are permitted provided that the following conditions | ||
702 | @@ -40,12 +40,167 @@ | ||
703 | #include "buffer.h" | ||
704 | #include "log.h" | ||
705 | #include "ssh2.h" | ||
706 | +#include "cipher.h" | ||
707 | +#include "key.h" | ||
708 | +#include "kex.h" | ||
709 | +#include <openssl/evp.h> | ||
710 | |||
711 | #include "ssh-gss.h" | ||
712 | |||
713 | extern u_char *session_id2; | ||
714 | extern u_int session_id2_len; | ||
715 | |||
716 | +typedef struct { | ||
717 | + char *encoded; | ||
718 | + gss_OID oid; | ||
719 | +} ssh_gss_kex_mapping; | ||
720 | + | ||
721 | +/* | ||
722 | + * XXX - It would be nice to find a more elegant way of handling the | ||
723 | + * XXX passing of the key exchange context to the userauth routines | ||
724 | + */ | ||
725 | + | ||
726 | +Gssctxt *gss_kex_context = NULL; | ||
727 | + | ||
728 | +static ssh_gss_kex_mapping *gss_enc2oid = NULL; | ||
729 | + | ||
730 | +int | ||
731 | +ssh_gssapi_oid_table_ok(void) { | ||
732 | + return (gss_enc2oid != NULL); | ||
733 | +} | ||
734 | + | ||
735 | +/* | ||
736 | + * Return a list of the gss-group1-sha1 mechanisms supported by this program | ||
737 | + * | ||
738 | + * We test mechanisms to ensure that we can use them, to avoid starting | ||
739 | + * a key exchange with a bad mechanism | ||
740 | + */ | ||
741 | + | ||
742 | +char * | ||
743 | +ssh_gssapi_client_mechanisms(const char *host, const char *client) { | ||
744 | + gss_OID_set gss_supported; | ||
745 | + OM_uint32 min_status; | ||
746 | + | ||
747 | + if (GSS_ERROR(gss_indicate_mechs(&min_status, &gss_supported))) | ||
748 | + return NULL; | ||
749 | + | ||
750 | + return(ssh_gssapi_kex_mechs(gss_supported, ssh_gssapi_check_mechanism, | ||
751 | + host, client)); | ||
752 | +} | ||
753 | + | ||
754 | +char * | ||
755 | +ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check, | ||
756 | + const char *host, const char *client) { | ||
757 | + Buffer buf; | ||
758 | + size_t i; | ||
759 | + int oidpos, enclen; | ||
760 | + char *mechs, *encoded; | ||
761 | + u_char digest[EVP_MAX_MD_SIZE]; | ||
762 | + char deroid[2]; | ||
763 | + const EVP_MD *evp_md = EVP_md5(); | ||
764 | + EVP_MD_CTX md; | ||
765 | + | ||
766 | + if (gss_enc2oid != NULL) { | ||
767 | + for (i = 0; gss_enc2oid[i].encoded != NULL; i++) | ||
768 | + free(gss_enc2oid[i].encoded); | ||
769 | + free(gss_enc2oid); | ||
770 | + } | ||
771 | + | ||
772 | + gss_enc2oid = xmalloc(sizeof(ssh_gss_kex_mapping) * | ||
773 | + (gss_supported->count + 1)); | ||
774 | + | ||
775 | + buffer_init(&buf); | ||
776 | + | ||
777 | + oidpos = 0; | ||
778 | + for (i = 0; i < gss_supported->count; i++) { | ||
779 | + if (gss_supported->elements[i].length < 128 && | ||
780 | + (*check)(NULL, &(gss_supported->elements[i]), host, client)) { | ||
781 | + | ||
782 | + deroid[0] = SSH_GSS_OIDTYPE; | ||
783 | + deroid[1] = gss_supported->elements[i].length; | ||
784 | + | ||
785 | + EVP_DigestInit(&md, evp_md); | ||
786 | + EVP_DigestUpdate(&md, deroid, 2); | ||
787 | + EVP_DigestUpdate(&md, | ||
788 | + gss_supported->elements[i].elements, | ||
789 | + gss_supported->elements[i].length); | ||
790 | + EVP_DigestFinal(&md, digest, NULL); | ||
791 | + | ||
792 | + encoded = xmalloc(EVP_MD_size(evp_md) * 2); | ||
793 | + enclen = __b64_ntop(digest, EVP_MD_size(evp_md), | ||
794 | + encoded, EVP_MD_size(evp_md) * 2); | ||
795 | + | ||
796 | + if (oidpos != 0) | ||
797 | + buffer_put_char(&buf, ','); | ||
798 | + | ||
799 | + buffer_append(&buf, KEX_GSS_GEX_SHA1_ID, | ||
800 | + sizeof(KEX_GSS_GEX_SHA1_ID) - 1); | ||
801 | + buffer_append(&buf, encoded, enclen); | ||
802 | + buffer_put_char(&buf, ','); | ||
803 | + buffer_append(&buf, KEX_GSS_GRP1_SHA1_ID, | ||
804 | + sizeof(KEX_GSS_GRP1_SHA1_ID) - 1); | ||
805 | + buffer_append(&buf, encoded, enclen); | ||
806 | + buffer_put_char(&buf, ','); | ||
807 | + buffer_append(&buf, KEX_GSS_GRP14_SHA1_ID, | ||
808 | + sizeof(KEX_GSS_GRP14_SHA1_ID) - 1); | ||
809 | + buffer_append(&buf, encoded, enclen); | ||
810 | + | ||
811 | + gss_enc2oid[oidpos].oid = &(gss_supported->elements[i]); | ||
812 | + gss_enc2oid[oidpos].encoded = encoded; | ||
813 | + oidpos++; | ||
814 | + } | ||
815 | + } | ||
816 | + gss_enc2oid[oidpos].oid = NULL; | ||
817 | + gss_enc2oid[oidpos].encoded = NULL; | ||
818 | + | ||
819 | + buffer_put_char(&buf, '\0'); | ||
820 | + | ||
821 | + mechs = xmalloc(buffer_len(&buf)); | ||
822 | + buffer_get(&buf, mechs, buffer_len(&buf)); | ||
823 | + buffer_free(&buf); | ||
824 | + | ||
825 | + if (strlen(mechs) == 0) { | ||
826 | + free(mechs); | ||
827 | + mechs = NULL; | ||
828 | + } | ||
829 | + | ||
830 | + return (mechs); | ||
831 | +} | ||
832 | + | ||
833 | +gss_OID | ||
834 | +ssh_gssapi_id_kex(Gssctxt *ctx, char *name, int kex_type) { | ||
835 | + int i = 0; | ||
836 | + | ||
837 | + switch (kex_type) { | ||
838 | + case KEX_GSS_GRP1_SHA1: | ||
839 | + if (strlen(name) < sizeof(KEX_GSS_GRP1_SHA1_ID)) | ||
840 | + return GSS_C_NO_OID; | ||
841 | + name += sizeof(KEX_GSS_GRP1_SHA1_ID) - 1; | ||
842 | + break; | ||
843 | + case KEX_GSS_GRP14_SHA1: | ||
844 | + if (strlen(name) < sizeof(KEX_GSS_GRP14_SHA1_ID)) | ||
845 | + return GSS_C_NO_OID; | ||
846 | + name += sizeof(KEX_GSS_GRP14_SHA1_ID) - 1; | ||
847 | + break; | ||
848 | + case KEX_GSS_GEX_SHA1: | ||
849 | + if (strlen(name) < sizeof(KEX_GSS_GEX_SHA1_ID)) | ||
850 | + return GSS_C_NO_OID; | ||
851 | + name += sizeof(KEX_GSS_GEX_SHA1_ID) - 1; | ||
852 | + break; | ||
853 | + default: | ||
854 | + return GSS_C_NO_OID; | ||
855 | + } | ||
856 | + | ||
857 | + while (gss_enc2oid[i].encoded != NULL && | ||
858 | + strcmp(name, gss_enc2oid[i].encoded) != 0) | ||
859 | + i++; | ||
860 | + | ||
861 | + if (gss_enc2oid[i].oid != NULL && ctx != NULL) | ||
862 | + ssh_gssapi_set_oid(ctx, gss_enc2oid[i].oid); | ||
863 | + | ||
864 | + return gss_enc2oid[i].oid; | ||
865 | +} | ||
866 | + | ||
867 | /* Check that the OID in a data stream matches that in the context */ | ||
868 | int | ||
869 | ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len) | ||
870 | @@ -198,7 +353,7 @@ ssh_gssapi_init_ctx(Gssctxt *ctx, int deleg_creds, gss_buffer_desc *recv_tok, | ||
871 | } | ||
872 | |||
873 | ctx->major = gss_init_sec_context(&ctx->minor, | ||
874 | - GSS_C_NO_CREDENTIAL, &ctx->context, ctx->name, ctx->oid, | ||
875 | + ctx->client_creds, &ctx->context, ctx->name, ctx->oid, | ||
876 | GSS_C_MUTUAL_FLAG | GSS_C_INTEG_FLAG | deleg_flag, | ||
877 | 0, NULL, recv_tok, NULL, send_tok, flags, NULL); | ||
878 | |||
879 | @@ -227,9 +382,43 @@ ssh_gssapi_import_name(Gssctxt *ctx, const char *host) | ||
880 | return (ctx->major); | ||
881 | } | ||
882 | |||
883 | +OM_uint32 | ||
884 | +ssh_gssapi_client_identity(Gssctxt *ctx, const char *name) | ||
885 | +{ | ||
886 | + gss_buffer_desc gssbuf; | ||
887 | + gss_name_t gssname; | ||
888 | + OM_uint32 status; | ||
889 | + gss_OID_set oidset; | ||
890 | + | ||
891 | + gssbuf.value = (void *) name; | ||
892 | + gssbuf.length = strlen(gssbuf.value); | ||
893 | + | ||
894 | + gss_create_empty_oid_set(&status, &oidset); | ||
895 | + gss_add_oid_set_member(&status, ctx->oid, &oidset); | ||
896 | + | ||
897 | + ctx->major = gss_import_name(&ctx->minor, &gssbuf, | ||
898 | + GSS_C_NT_USER_NAME, &gssname); | ||
899 | + | ||
900 | + if (!ctx->major) | ||
901 | + ctx->major = gss_acquire_cred(&ctx->minor, | ||
902 | + gssname, 0, oidset, GSS_C_INITIATE, | ||
903 | + &ctx->client_creds, NULL, NULL); | ||
904 | + | ||
905 | + gss_release_name(&status, &gssname); | ||
906 | + gss_release_oid_set(&status, &oidset); | ||
907 | + | ||
908 | + if (ctx->major) | ||
909 | + ssh_gssapi_error(ctx); | ||
910 | + | ||
911 | + return(ctx->major); | ||
912 | +} | ||
913 | + | ||
914 | OM_uint32 | ||
915 | ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash) | ||
916 | { | ||
917 | + if (ctx == NULL) | ||
918 | + return -1; | ||
919 | + | ||
920 | if ((ctx->major = gss_get_mic(&ctx->minor, ctx->context, | ||
921 | GSS_C_QOP_DEFAULT, buffer, hash))) | ||
922 | ssh_gssapi_error(ctx); | ||
923 | @@ -237,6 +426,19 @@ ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash) | ||
924 | return (ctx->major); | ||
925 | } | ||
926 | |||
927 | +/* Priviledged when used by server */ | ||
928 | +OM_uint32 | ||
929 | +ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic) | ||
930 | +{ | ||
931 | + if (ctx == NULL) | ||
932 | + return -1; | ||
933 | + | ||
934 | + ctx->major = gss_verify_mic(&ctx->minor, ctx->context, | ||
935 | + gssbuf, gssmic, NULL); | ||
936 | + | ||
937 | + return (ctx->major); | ||
938 | +} | ||
939 | + | ||
940 | void | ||
941 | ssh_gssapi_buildmic(Buffer *b, const char *user, const char *service, | ||
942 | const char *context) | ||
943 | @@ -250,11 +452,16 @@ ssh_gssapi_buildmic(Buffer *b, const char *user, const char *service, | ||
944 | } | ||
945 | |||
946 | int | ||
947 | -ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host) | ||
948 | +ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host, | ||
949 | + const char *client) | ||
950 | { | ||
951 | gss_buffer_desc token = GSS_C_EMPTY_BUFFER; | ||
952 | OM_uint32 major, minor; | ||
953 | gss_OID_desc spnego_oid = {6, (void *)"\x2B\x06\x01\x05\x05\x02"}; | ||
954 | + Gssctxt *intctx = NULL; | ||
955 | + | ||
956 | + if (ctx == NULL) | ||
957 | + ctx = &intctx; | ||
958 | |||
959 | /* RFC 4462 says we MUST NOT do SPNEGO */ | ||
960 | if (oid->length == spnego_oid.length && | ||
961 | @@ -264,6 +471,10 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host) | ||
962 | ssh_gssapi_build_ctx(ctx); | ||
963 | ssh_gssapi_set_oid(*ctx, oid); | ||
964 | major = ssh_gssapi_import_name(*ctx, host); | ||
965 | + | ||
966 | + if (!GSS_ERROR(major) && client) | ||
967 | + major = ssh_gssapi_client_identity(*ctx, client); | ||
968 | + | ||
969 | if (!GSS_ERROR(major)) { | ||
970 | major = ssh_gssapi_init_ctx(*ctx, 0, GSS_C_NO_BUFFER, &token, | ||
971 | NULL); | ||
972 | @@ -273,10 +484,66 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host) | ||
973 | GSS_C_NO_BUFFER); | ||
974 | } | ||
975 | |||
976 | - if (GSS_ERROR(major)) | ||
977 | + if (GSS_ERROR(major) || intctx != NULL) | ||
978 | ssh_gssapi_delete_ctx(ctx); | ||
979 | |||
980 | return (!GSS_ERROR(major)); | ||
981 | } | ||
982 | |||
983 | +int | ||
984 | +ssh_gssapi_credentials_updated(Gssctxt *ctxt) { | ||
985 | + static gss_name_t saved_name = GSS_C_NO_NAME; | ||
986 | + static OM_uint32 saved_lifetime = 0; | ||
987 | + static gss_OID saved_mech = GSS_C_NO_OID; | ||
988 | + static gss_name_t name; | ||
989 | + static OM_uint32 last_call = 0; | ||
990 | + OM_uint32 lifetime, now, major, minor; | ||
991 | + int equal; | ||
992 | + | ||
993 | + now = time(NULL); | ||
994 | + | ||
995 | + if (ctxt) { | ||
996 | + debug("Rekey has happened - updating saved versions"); | ||
997 | + | ||
998 | + if (saved_name != GSS_C_NO_NAME) | ||
999 | + gss_release_name(&minor, &saved_name); | ||
1000 | + | ||
1001 | + major = gss_inquire_cred(&minor, GSS_C_NO_CREDENTIAL, | ||
1002 | + &saved_name, &saved_lifetime, NULL, NULL); | ||
1003 | + | ||
1004 | + if (!GSS_ERROR(major)) { | ||
1005 | + saved_mech = ctxt->oid; | ||
1006 | + saved_lifetime+= now; | ||
1007 | + } else { | ||
1008 | + /* Handle the error */ | ||
1009 | + } | ||
1010 | + return 0; | ||
1011 | + } | ||
1012 | + | ||
1013 | + if (now - last_call < 10) | ||
1014 | + return 0; | ||
1015 | + | ||
1016 | + last_call = now; | ||
1017 | + | ||
1018 | + if (saved_mech == GSS_C_NO_OID) | ||
1019 | + return 0; | ||
1020 | + | ||
1021 | + major = gss_inquire_cred(&minor, GSS_C_NO_CREDENTIAL, | ||
1022 | + &name, &lifetime, NULL, NULL); | ||
1023 | + if (major == GSS_S_CREDENTIALS_EXPIRED) | ||
1024 | + return 0; | ||
1025 | + else if (GSS_ERROR(major)) | ||
1026 | + return 0; | ||
1027 | + | ||
1028 | + major = gss_compare_name(&minor, saved_name, name, &equal); | ||
1029 | + gss_release_name(&minor, &name); | ||
1030 | + if (GSS_ERROR(major)) | ||
1031 | + return 0; | ||
1032 | + | ||
1033 | + if (equal && (saved_lifetime < lifetime + now - 10)) | ||
1034 | + return 1; | ||
1035 | + | ||
1036 | + return 0; | ||
1037 | +} | ||
1038 | + | ||
1039 | #endif /* GSSAPI */ | ||
1040 | diff --git a/gss-serv-krb5.c b/gss-serv-krb5.c | ||
1041 | index 795992d9..fd8b3718 100644 | ||
1042 | --- a/gss-serv-krb5.c | ||
1043 | +++ b/gss-serv-krb5.c | ||
1044 | @@ -1,7 +1,7 @@ | ||
1045 | /* $OpenBSD: gss-serv-krb5.c,v 1.8 2013/07/20 01:55:13 djm Exp $ */ | ||
1046 | |||
1047 | /* | ||
1048 | - * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | ||
1049 | + * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved. | ||
1050 | * | ||
1051 | * Redistribution and use in source and binary forms, with or without | ||
1052 | * modification, are permitted provided that the following conditions | ||
1053 | @@ -121,8 +121,8 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client) | ||
1054 | krb5_error_code problem; | ||
1055 | krb5_principal princ; | ||
1056 | OM_uint32 maj_status, min_status; | ||
1057 | - int len; | ||
1058 | const char *errmsg; | ||
1059 | + const char *new_ccname; | ||
1060 | |||
1061 | if (client->creds == NULL) { | ||
1062 | debug("No credentials stored"); | ||
1063 | @@ -181,11 +181,16 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client) | ||
1064 | return; | ||
1065 | } | ||
1066 | |||
1067 | - client->store.filename = xstrdup(krb5_cc_get_name(krb_context, ccache)); | ||
1068 | + new_ccname = krb5_cc_get_name(krb_context, ccache); | ||
1069 | + | ||
1070 | client->store.envvar = "KRB5CCNAME"; | ||
1071 | - len = strlen(client->store.filename) + 6; | ||
1072 | - client->store.envval = xmalloc(len); | ||
1073 | - snprintf(client->store.envval, len, "FILE:%s", client->store.filename); | ||
1074 | +#ifdef USE_CCAPI | ||
1075 | + xasprintf(&client->store.envval, "API:%s", new_ccname); | ||
1076 | + client->store.filename = NULL; | ||
1077 | +#else | ||
1078 | + xasprintf(&client->store.envval, "FILE:%s", new_ccname); | ||
1079 | + client->store.filename = xstrdup(new_ccname); | ||
1080 | +#endif | ||
1081 | |||
1082 | #ifdef USE_PAM | ||
1083 | if (options.use_pam) | ||
1084 | @@ -197,6 +202,71 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client) | ||
1085 | return; | ||
1086 | } | ||
1087 | |||
1088 | +int | ||
1089 | +ssh_gssapi_krb5_updatecreds(ssh_gssapi_ccache *store, | ||
1090 | + ssh_gssapi_client *client) | ||
1091 | +{ | ||
1092 | + krb5_ccache ccache = NULL; | ||
1093 | + krb5_principal principal = NULL; | ||
1094 | + char *name = NULL; | ||
1095 | + krb5_error_code problem; | ||
1096 | + OM_uint32 maj_status, min_status; | ||
1097 | + | ||
1098 | + if ((problem = krb5_cc_resolve(krb_context, store->envval, &ccache))) { | ||
1099 | + logit("krb5_cc_resolve(): %.100s", | ||
1100 | + krb5_get_err_text(krb_context, problem)); | ||
1101 | + return 0; | ||
1102 | + } | ||
1103 | + | ||
1104 | + /* Find out who the principal in this cache is */ | ||
1105 | + if ((problem = krb5_cc_get_principal(krb_context, ccache, | ||
1106 | + &principal))) { | ||
1107 | + logit("krb5_cc_get_principal(): %.100s", | ||
1108 | + krb5_get_err_text(krb_context, problem)); | ||
1109 | + krb5_cc_close(krb_context, ccache); | ||
1110 | + return 0; | ||
1111 | + } | ||
1112 | + | ||
1113 | + if ((problem = krb5_unparse_name(krb_context, principal, &name))) { | ||
1114 | + logit("krb5_unparse_name(): %.100s", | ||
1115 | + krb5_get_err_text(krb_context, problem)); | ||
1116 | + krb5_free_principal(krb_context, principal); | ||
1117 | + krb5_cc_close(krb_context, ccache); | ||
1118 | + return 0; | ||
1119 | + } | ||
1120 | + | ||
1121 | + | ||
1122 | + if (strcmp(name,client->exportedname.value)!=0) { | ||
1123 | + debug("Name in local credentials cache differs. Not storing"); | ||
1124 | + krb5_free_principal(krb_context, principal); | ||
1125 | + krb5_cc_close(krb_context, ccache); | ||
1126 | + krb5_free_unparsed_name(krb_context, name); | ||
1127 | + return 0; | ||
1128 | + } | ||
1129 | + krb5_free_unparsed_name(krb_context, name); | ||
1130 | + | ||
1131 | + /* Name matches, so lets get on with it! */ | ||
1132 | + | ||
1133 | + if ((problem = krb5_cc_initialize(krb_context, ccache, principal))) { | ||
1134 | + logit("krb5_cc_initialize(): %.100s", | ||
1135 | + krb5_get_err_text(krb_context, problem)); | ||
1136 | + krb5_free_principal(krb_context, principal); | ||
1137 | + krb5_cc_close(krb_context, ccache); | ||
1138 | + return 0; | ||
1139 | + } | ||
1140 | + | ||
1141 | + krb5_free_principal(krb_context, principal); | ||
1142 | + | ||
1143 | + if ((maj_status = gss_krb5_copy_ccache(&min_status, client->creds, | ||
1144 | + ccache))) { | ||
1145 | + logit("gss_krb5_copy_ccache() failed. Sorry!"); | ||
1146 | + krb5_cc_close(krb_context, ccache); | ||
1147 | + return 0; | ||
1148 | + } | ||
1149 | + | ||
1150 | + return 1; | ||
1151 | +} | ||
1152 | + | ||
1153 | ssh_gssapi_mech gssapi_kerberos_mech = { | ||
1154 | "toWM5Slw5Ew8Mqkay+al2g==", | ||
1155 | "Kerberos", | ||
1156 | @@ -204,7 +274,8 @@ ssh_gssapi_mech gssapi_kerberos_mech = { | ||
1157 | NULL, | ||
1158 | &ssh_gssapi_krb5_userok, | ||
1159 | NULL, | ||
1160 | - &ssh_gssapi_krb5_storecreds | ||
1161 | + &ssh_gssapi_krb5_storecreds, | ||
1162 | + &ssh_gssapi_krb5_updatecreds | ||
1163 | }; | ||
1164 | |||
1165 | #endif /* KRB5 */ | ||
1166 | diff --git a/gss-serv.c b/gss-serv.c | ||
1167 | index 6cae720e..967c6cfb 100644 | ||
1168 | --- a/gss-serv.c | ||
1169 | +++ b/gss-serv.c | ||
1170 | @@ -1,7 +1,7 @@ | ||
1171 | /* $OpenBSD: gss-serv.c,v 1.30 2017/06/24 06:34:38 djm Exp $ */ | ||
1172 | |||
1173 | /* | ||
1174 | - * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | ||
1175 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
1176 | * | ||
1177 | * Redistribution and use in source and binary forms, with or without | ||
1178 | * modification, are permitted provided that the following conditions | ||
1179 | @@ -45,17 +45,22 @@ | ||
1180 | #include "session.h" | ||
1181 | #include "misc.h" | ||
1182 | #include "servconf.h" | ||
1183 | +#include "uidswap.h" | ||
1184 | |||
1185 | #include "ssh-gss.h" | ||
1186 | +#include "monitor_wrap.h" | ||
1187 | + | ||
1188 | +extern ServerOptions options; | ||
1189 | |||
1190 | extern ServerOptions options; | ||
1191 | |||
1192 | static ssh_gssapi_client gssapi_client = | ||
1193 | { GSS_C_EMPTY_BUFFER, GSS_C_EMPTY_BUFFER, | ||
1194 | - GSS_C_NO_CREDENTIAL, NULL, {NULL, NULL, NULL, NULL}}; | ||
1195 | + GSS_C_NO_CREDENTIAL, GSS_C_NO_NAME, NULL, | ||
1196 | + {NULL, NULL, NULL, NULL, NULL}, 0, 0}; | ||
1197 | |||
1198 | ssh_gssapi_mech gssapi_null_mech = | ||
1199 | - { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL}; | ||
1200 | + { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL, NULL}; | ||
1201 | |||
1202 | #ifdef KRB5 | ||
1203 | extern ssh_gssapi_mech gssapi_kerberos_mech; | ||
1204 | @@ -141,6 +146,28 @@ ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid) | ||
1205 | return (ssh_gssapi_acquire_cred(*ctx)); | ||
1206 | } | ||
1207 | |||
1208 | +/* Unprivileged */ | ||
1209 | +char * | ||
1210 | +ssh_gssapi_server_mechanisms(void) { | ||
1211 | + if (supported_oids == NULL) | ||
1212 | + ssh_gssapi_prepare_supported_oids(); | ||
1213 | + return (ssh_gssapi_kex_mechs(supported_oids, | ||
1214 | + &ssh_gssapi_server_check_mech, NULL, NULL)); | ||
1215 | +} | ||
1216 | + | ||
1217 | +/* Unprivileged */ | ||
1218 | +int | ||
1219 | +ssh_gssapi_server_check_mech(Gssctxt **dum, gss_OID oid, const char *data, | ||
1220 | + const char *dummy) { | ||
1221 | + Gssctxt *ctx = NULL; | ||
1222 | + int res; | ||
1223 | + | ||
1224 | + res = !GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctx, oid))); | ||
1225 | + ssh_gssapi_delete_ctx(&ctx); | ||
1226 | + | ||
1227 | + return (res); | ||
1228 | +} | ||
1229 | + | ||
1230 | /* Unprivileged */ | ||
1231 | void | ||
1232 | ssh_gssapi_supported_oids(gss_OID_set *oidset) | ||
1233 | @@ -151,7 +178,9 @@ ssh_gssapi_supported_oids(gss_OID_set *oidset) | ||
1234 | gss_OID_set supported; | ||
1235 | |||
1236 | gss_create_empty_oid_set(&min_status, oidset); | ||
1237 | - gss_indicate_mechs(&min_status, &supported); | ||
1238 | + | ||
1239 | + if (GSS_ERROR(gss_indicate_mechs(&min_status, &supported))) | ||
1240 | + return; | ||
1241 | |||
1242 | while (supported_mechs[i]->name != NULL) { | ||
1243 | if (GSS_ERROR(gss_test_oid_set_member(&min_status, | ||
1244 | @@ -277,8 +306,48 @@ OM_uint32 | ||
1245 | ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client) | ||
1246 | { | ||
1247 | int i = 0; | ||
1248 | + int equal = 0; | ||
1249 | + gss_name_t new_name = GSS_C_NO_NAME; | ||
1250 | + gss_buffer_desc ename = GSS_C_EMPTY_BUFFER; | ||
1251 | + | ||
1252 | + if (options.gss_store_rekey && client->used && ctx->client_creds) { | ||
1253 | + if (client->mech->oid.length != ctx->oid->length || | ||
1254 | + (memcmp(client->mech->oid.elements, | ||
1255 | + ctx->oid->elements, ctx->oid->length) !=0)) { | ||
1256 | + debug("Rekeyed credentials have different mechanism"); | ||
1257 | + return GSS_S_COMPLETE; | ||
1258 | + } | ||
1259 | + | ||
1260 | + if ((ctx->major = gss_inquire_cred_by_mech(&ctx->minor, | ||
1261 | + ctx->client_creds, ctx->oid, &new_name, | ||
1262 | + NULL, NULL, NULL))) { | ||
1263 | + ssh_gssapi_error(ctx); | ||
1264 | + return (ctx->major); | ||
1265 | + } | ||
1266 | + | ||
1267 | + ctx->major = gss_compare_name(&ctx->minor, client->name, | ||
1268 | + new_name, &equal); | ||
1269 | + | ||
1270 | + if (GSS_ERROR(ctx->major)) { | ||
1271 | + ssh_gssapi_error(ctx); | ||
1272 | + return (ctx->major); | ||
1273 | + } | ||
1274 | + | ||
1275 | + if (!equal) { | ||
1276 | + debug("Rekeyed credentials have different name"); | ||
1277 | + return GSS_S_COMPLETE; | ||
1278 | + } | ||
1279 | |||
1280 | - gss_buffer_desc ename; | ||
1281 | + debug("Marking rekeyed credentials for export"); | ||
1282 | + | ||
1283 | + gss_release_name(&ctx->minor, &client->name); | ||
1284 | + gss_release_cred(&ctx->minor, &client->creds); | ||
1285 | + client->name = new_name; | ||
1286 | + client->creds = ctx->client_creds; | ||
1287 | + ctx->client_creds = GSS_C_NO_CREDENTIAL; | ||
1288 | + client->updated = 1; | ||
1289 | + return GSS_S_COMPLETE; | ||
1290 | + } | ||
1291 | |||
1292 | client->mech = NULL; | ||
1293 | |||
1294 | @@ -293,6 +362,13 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client) | ||
1295 | if (client->mech == NULL) | ||
1296 | return GSS_S_FAILURE; | ||
1297 | |||
1298 | + if (ctx->client_creds && | ||
1299 | + (ctx->major = gss_inquire_cred_by_mech(&ctx->minor, | ||
1300 | + ctx->client_creds, ctx->oid, &client->name, NULL, NULL, NULL))) { | ||
1301 | + ssh_gssapi_error(ctx); | ||
1302 | + return (ctx->major); | ||
1303 | + } | ||
1304 | + | ||
1305 | if ((ctx->major = gss_display_name(&ctx->minor, ctx->client, | ||
1306 | &client->displayname, NULL))) { | ||
1307 | ssh_gssapi_error(ctx); | ||
1308 | @@ -310,6 +386,8 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client) | ||
1309 | return (ctx->major); | ||
1310 | } | ||
1311 | |||
1312 | + gss_release_buffer(&ctx->minor, &ename); | ||
1313 | + | ||
1314 | /* We can't copy this structure, so we just move the pointer to it */ | ||
1315 | client->creds = ctx->client_creds; | ||
1316 | ctx->client_creds = GSS_C_NO_CREDENTIAL; | ||
1317 | @@ -357,7 +435,7 @@ ssh_gssapi_do_child(char ***envp, u_int *envsizep) | ||
1318 | |||
1319 | /* Privileged */ | ||
1320 | int | ||
1321 | -ssh_gssapi_userok(char *user) | ||
1322 | +ssh_gssapi_userok(char *user, struct passwd *pw) | ||
1323 | { | ||
1324 | OM_uint32 lmin; | ||
1325 | |||
1326 | @@ -367,9 +445,11 @@ ssh_gssapi_userok(char *user) | ||
1327 | return 0; | ||
1328 | } | ||
1329 | if (gssapi_client.mech && gssapi_client.mech->userok) | ||
1330 | - if ((*gssapi_client.mech->userok)(&gssapi_client, user)) | ||
1331 | + if ((*gssapi_client.mech->userok)(&gssapi_client, user)) { | ||
1332 | + gssapi_client.used = 1; | ||
1333 | + gssapi_client.store.owner = pw; | ||
1334 | return 1; | ||
1335 | - else { | ||
1336 | + } else { | ||
1337 | /* Destroy delegated credentials if userok fails */ | ||
1338 | gss_release_buffer(&lmin, &gssapi_client.displayname); | ||
1339 | gss_release_buffer(&lmin, &gssapi_client.exportedname); | ||
1340 | @@ -383,14 +463,90 @@ ssh_gssapi_userok(char *user) | ||
1341 | return (0); | ||
1342 | } | ||
1343 | |||
1344 | -/* Privileged */ | ||
1345 | -OM_uint32 | ||
1346 | -ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic) | ||
1347 | +/* These bits are only used for rekeying. The unpriviledged child is running | ||
1348 | + * as the user, the monitor is root. | ||
1349 | + * | ||
1350 | + * In the child, we want to : | ||
1351 | + * *) Ask the monitor to store our credentials into the store we specify | ||
1352 | + * *) If it succeeds, maybe do a PAM update | ||
1353 | + */ | ||
1354 | + | ||
1355 | +/* Stuff for PAM */ | ||
1356 | + | ||
1357 | +#ifdef USE_PAM | ||
1358 | +static int ssh_gssapi_simple_conv(int n, const struct pam_message **msg, | ||
1359 | + struct pam_response **resp, void *data) | ||
1360 | { | ||
1361 | - ctx->major = gss_verify_mic(&ctx->minor, ctx->context, | ||
1362 | - gssbuf, gssmic, NULL); | ||
1363 | + return (PAM_CONV_ERR); | ||
1364 | +} | ||
1365 | +#endif | ||
1366 | |||
1367 | - return (ctx->major); | ||
1368 | +void | ||
1369 | +ssh_gssapi_rekey_creds(void) { | ||
1370 | + int ok; | ||
1371 | + int ret; | ||
1372 | +#ifdef USE_PAM | ||
1373 | + pam_handle_t *pamh = NULL; | ||
1374 | + struct pam_conv pamconv = {ssh_gssapi_simple_conv, NULL}; | ||
1375 | + char *envstr; | ||
1376 | +#endif | ||
1377 | + | ||
1378 | + if (gssapi_client.store.filename == NULL && | ||
1379 | + gssapi_client.store.envval == NULL && | ||
1380 | + gssapi_client.store.envvar == NULL) | ||
1381 | + return; | ||
1382 | + | ||
1383 | + ok = PRIVSEP(ssh_gssapi_update_creds(&gssapi_client.store)); | ||
1384 | + | ||
1385 | + if (!ok) | ||
1386 | + return; | ||
1387 | + | ||
1388 | + debug("Rekeyed credentials stored successfully"); | ||
1389 | + | ||
1390 | + /* Actually managing to play with the ssh pam stack from here will | ||
1391 | + * be next to impossible. In any case, we may want different options | ||
1392 | + * for rekeying. So, use our own :) | ||
1393 | + */ | ||
1394 | +#ifdef USE_PAM | ||
1395 | + if (!use_privsep) { | ||
1396 | + debug("Not even going to try and do PAM with privsep disabled"); | ||
1397 | + return; | ||
1398 | + } | ||
1399 | + | ||
1400 | + ret = pam_start("sshd-rekey", gssapi_client.store.owner->pw_name, | ||
1401 | + &pamconv, &pamh); | ||
1402 | + if (ret) | ||
1403 | + return; | ||
1404 | + | ||
1405 | + xasprintf(&envstr, "%s=%s", gssapi_client.store.envvar, | ||
1406 | + gssapi_client.store.envval); | ||
1407 | + | ||
1408 | + ret = pam_putenv(pamh, envstr); | ||
1409 | + if (!ret) | ||
1410 | + pam_setcred(pamh, PAM_REINITIALIZE_CRED); | ||
1411 | + pam_end(pamh, PAM_SUCCESS); | ||
1412 | +#endif | ||
1413 | +} | ||
1414 | + | ||
1415 | +int | ||
1416 | +ssh_gssapi_update_creds(ssh_gssapi_ccache *store) { | ||
1417 | + int ok = 0; | ||
1418 | + | ||
1419 | + /* Check we've got credentials to store */ | ||
1420 | + if (!gssapi_client.updated) | ||
1421 | + return 0; | ||
1422 | + | ||
1423 | + gssapi_client.updated = 0; | ||
1424 | + | ||
1425 | + temporarily_use_uid(gssapi_client.store.owner); | ||
1426 | + if (gssapi_client.mech && gssapi_client.mech->updatecreds) | ||
1427 | + ok = (*gssapi_client.mech->updatecreds)(store, &gssapi_client); | ||
1428 | + else | ||
1429 | + debug("No update function for this mechanism"); | ||
1430 | + | ||
1431 | + restore_uid(); | ||
1432 | + | ||
1433 | + return ok; | ||
1434 | } | ||
1435 | |||
1436 | /* Privileged */ | ||
1437 | diff --git a/kex.c b/kex.c | ||
1438 | index d5d5a9da..bb1bd661 100644 | ||
1439 | --- a/kex.c | ||
1440 | +++ b/kex.c | ||
1441 | @@ -54,6 +54,10 @@ | ||
1442 | #include "sshbuf.h" | ||
1443 | #include "digest.h" | ||
1444 | |||
1445 | +#ifdef GSSAPI | ||
1446 | +#include "ssh-gss.h" | ||
1447 | +#endif | ||
1448 | + | ||
1449 | /* prototype */ | ||
1450 | static int kex_choose_conf(struct ssh *); | ||
1451 | static int kex_input_newkeys(int, u_int32_t, struct ssh *); | ||
1452 | @@ -105,6 +109,14 @@ static const struct kexalg kexalgs[] = { | ||
1453 | #endif /* HAVE_EVP_SHA256 || !WITH_OPENSSL */ | ||
1454 | { NULL, -1, -1, -1}, | ||
1455 | }; | ||
1456 | +static const struct kexalg kexalg_prefixes[] = { | ||
1457 | +#ifdef GSSAPI | ||
1458 | + { KEX_GSS_GEX_SHA1_ID, KEX_GSS_GEX_SHA1, 0, SSH_DIGEST_SHA1 }, | ||
1459 | + { KEX_GSS_GRP1_SHA1_ID, KEX_GSS_GRP1_SHA1, 0, SSH_DIGEST_SHA1 }, | ||
1460 | + { KEX_GSS_GRP14_SHA1_ID, KEX_GSS_GRP14_SHA1, 0, SSH_DIGEST_SHA1 }, | ||
1461 | +#endif | ||
1462 | + { NULL, -1, -1, -1 }, | ||
1463 | +}; | ||
1464 | |||
1465 | char * | ||
1466 | kex_alg_list(char sep) | ||
1467 | @@ -137,6 +149,10 @@ kex_alg_by_name(const char *name) | ||
1468 | if (strcmp(k->name, name) == 0) | ||
1469 | return k; | ||
1470 | } | ||
1471 | + for (k = kexalg_prefixes; k->name != NULL; k++) { | ||
1472 | + if (strncmp(k->name, name, strlen(k->name)) == 0) | ||
1473 | + return k; | ||
1474 | + } | ||
1475 | return NULL; | ||
1476 | } | ||
1477 | |||
1478 | @@ -601,6 +617,9 @@ kex_free(struct kex *kex) | ||
1479 | sshbuf_free(kex->peer); | ||
1480 | sshbuf_free(kex->my); | ||
1481 | free(kex->session_id); | ||
1482 | +#ifdef GSSAPI | ||
1483 | + free(kex->gss_host); | ||
1484 | +#endif /* GSSAPI */ | ||
1485 | free(kex->client_version_string); | ||
1486 | free(kex->server_version_string); | ||
1487 | free(kex->failed_choice); | ||
1488 | diff --git a/kex.h b/kex.h | ||
1489 | index 01bb3986..a708e486 100644 | ||
1490 | --- a/kex.h | ||
1491 | +++ b/kex.h | ||
1492 | @@ -99,6 +99,9 @@ enum kex_exchange { | ||
1493 | KEX_DH_GEX_SHA256, | ||
1494 | KEX_ECDH_SHA2, | ||
1495 | KEX_C25519_SHA256, | ||
1496 | + KEX_GSS_GRP1_SHA1, | ||
1497 | + KEX_GSS_GRP14_SHA1, | ||
1498 | + KEX_GSS_GEX_SHA1, | ||
1499 | KEX_MAX | ||
1500 | }; | ||
1501 | |||
1502 | @@ -147,6 +150,12 @@ struct kex { | ||
1503 | u_int flags; | ||
1504 | int hash_alg; | ||
1505 | int ec_nid; | ||
1506 | +#ifdef GSSAPI | ||
1507 | + int gss_deleg_creds; | ||
1508 | + int gss_trust_dns; | ||
1509 | + char *gss_host; | ||
1510 | + char *gss_client; | ||
1511 | +#endif | ||
1512 | char *client_version_string; | ||
1513 | char *server_version_string; | ||
1514 | char *failed_choice; | ||
1515 | @@ -197,6 +206,11 @@ int kexecdh_server(struct ssh *); | ||
1516 | int kexc25519_client(struct ssh *); | ||
1517 | int kexc25519_server(struct ssh *); | ||
1518 | |||
1519 | +#ifdef GSSAPI | ||
1520 | +int kexgss_client(struct ssh *); | ||
1521 | +int kexgss_server(struct ssh *); | ||
1522 | +#endif | ||
1523 | + | ||
1524 | int kex_dh_hash(int, const char *, const char *, | ||
1525 | const u_char *, size_t, const u_char *, size_t, const u_char *, size_t, | ||
1526 | const BIGNUM *, const BIGNUM *, const BIGNUM *, u_char *, size_t *); | ||
1527 | diff --git a/kexgssc.c b/kexgssc.c | ||
1528 | new file mode 100644 | ||
1529 | index 00000000..10447f2b | ||
1530 | --- /dev/null | ||
1531 | +++ b/kexgssc.c | ||
1532 | @@ -0,0 +1,338 @@ | ||
1533 | +/* | ||
1534 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
1535 | + * | ||
1536 | + * Redistribution and use in source and binary forms, with or without | ||
1537 | + * modification, are permitted provided that the following conditions | ||
1538 | + * are met: | ||
1539 | + * 1. Redistributions of source code must retain the above copyright | ||
1540 | + * notice, this list of conditions and the following disclaimer. | ||
1541 | + * 2. Redistributions in binary form must reproduce the above copyright | ||
1542 | + * notice, this list of conditions and the following disclaimer in the | ||
1543 | + * documentation and/or other materials provided with the distribution. | ||
1544 | + * | ||
1545 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR | ||
1546 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
1547 | + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
1548 | + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
1549 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
1550 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
1551 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
1552 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
1553 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
1554 | + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
1555 | + */ | ||
1556 | + | ||
1557 | +#include "includes.h" | ||
1558 | + | ||
1559 | +#ifdef GSSAPI | ||
1560 | + | ||
1561 | +#include "includes.h" | ||
1562 | + | ||
1563 | +#include <openssl/crypto.h> | ||
1564 | +#include <openssl/bn.h> | ||
1565 | + | ||
1566 | +#include <string.h> | ||
1567 | + | ||
1568 | +#include "xmalloc.h" | ||
1569 | +#include "buffer.h" | ||
1570 | +#include "ssh2.h" | ||
1571 | +#include "key.h" | ||
1572 | +#include "cipher.h" | ||
1573 | +#include "kex.h" | ||
1574 | +#include "log.h" | ||
1575 | +#include "packet.h" | ||
1576 | +#include "dh.h" | ||
1577 | +#include "digest.h" | ||
1578 | + | ||
1579 | +#include "ssh-gss.h" | ||
1580 | + | ||
1581 | +int | ||
1582 | +kexgss_client(struct ssh *ssh) { | ||
1583 | + gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER; | ||
1584 | + gss_buffer_desc recv_tok, gssbuf, msg_tok, *token_ptr; | ||
1585 | + Gssctxt *ctxt; | ||
1586 | + OM_uint32 maj_status, min_status, ret_flags; | ||
1587 | + u_int klen, kout, slen = 0, strlen; | ||
1588 | + DH *dh; | ||
1589 | + BIGNUM *dh_server_pub = NULL; | ||
1590 | + BIGNUM *shared_secret = NULL; | ||
1591 | + BIGNUM *p = NULL; | ||
1592 | + BIGNUM *g = NULL; | ||
1593 | + u_char *kbuf; | ||
1594 | + u_char *serverhostkey = NULL; | ||
1595 | + u_char *empty = ""; | ||
1596 | + char *msg; | ||
1597 | + int type = 0; | ||
1598 | + int first = 1; | ||
1599 | + int nbits = 0, min = DH_GRP_MIN, max = DH_GRP_MAX; | ||
1600 | + u_char hash[SSH_DIGEST_MAX_LENGTH]; | ||
1601 | + size_t hashlen; | ||
1602 | + | ||
1603 | + /* Initialise our GSSAPI world */ | ||
1604 | + ssh_gssapi_build_ctx(&ctxt); | ||
1605 | + if (ssh_gssapi_id_kex(ctxt, ssh->kex->name, ssh->kex->kex_type) | ||
1606 | + == GSS_C_NO_OID) | ||
1607 | + fatal("Couldn't identify host exchange"); | ||
1608 | + | ||
1609 | + if (ssh_gssapi_import_name(ctxt, ssh->kex->gss_host)) | ||
1610 | + fatal("Couldn't import hostname"); | ||
1611 | + | ||
1612 | + if (ssh->kex->gss_client && | ||
1613 | + ssh_gssapi_client_identity(ctxt, ssh->kex->gss_client)) | ||
1614 | + fatal("Couldn't acquire client credentials"); | ||
1615 | + | ||
1616 | + switch (ssh->kex->kex_type) { | ||
1617 | + case KEX_GSS_GRP1_SHA1: | ||
1618 | + dh = dh_new_group1(); | ||
1619 | + break; | ||
1620 | + case KEX_GSS_GRP14_SHA1: | ||
1621 | + dh = dh_new_group14(); | ||
1622 | + break; | ||
1623 | + case KEX_GSS_GEX_SHA1: | ||
1624 | + debug("Doing group exchange\n"); | ||
1625 | + nbits = dh_estimate(ssh->kex->we_need * 8); | ||
1626 | + packet_start(SSH2_MSG_KEXGSS_GROUPREQ); | ||
1627 | + packet_put_int(min); | ||
1628 | + packet_put_int(nbits); | ||
1629 | + packet_put_int(max); | ||
1630 | + | ||
1631 | + packet_send(); | ||
1632 | + | ||
1633 | + packet_read_expect(SSH2_MSG_KEXGSS_GROUP); | ||
1634 | + | ||
1635 | + if ((p = BN_new()) == NULL) | ||
1636 | + fatal("BN_new() failed"); | ||
1637 | + packet_get_bignum2(p); | ||
1638 | + if ((g = BN_new()) == NULL) | ||
1639 | + fatal("BN_new() failed"); | ||
1640 | + packet_get_bignum2(g); | ||
1641 | + packet_check_eom(); | ||
1642 | + | ||
1643 | + if (BN_num_bits(p) < min || BN_num_bits(p) > max) | ||
1644 | + fatal("GSSGRP_GEX group out of range: %d !< %d !< %d", | ||
1645 | + min, BN_num_bits(p), max); | ||
1646 | + | ||
1647 | + dh = dh_new_group(g, p); | ||
1648 | + break; | ||
1649 | + default: | ||
1650 | + fatal("%s: Unexpected KEX type %d", __func__, ssh->kex->kex_type); | ||
1651 | + } | ||
1652 | + | ||
1653 | + /* Step 1 - e is dh->pub_key */ | ||
1654 | + dh_gen_key(dh, ssh->kex->we_need * 8); | ||
1655 | + | ||
1656 | + /* This is f, we initialise it now to make life easier */ | ||
1657 | + dh_server_pub = BN_new(); | ||
1658 | + if (dh_server_pub == NULL) | ||
1659 | + fatal("dh_server_pub == NULL"); | ||
1660 | + | ||
1661 | + token_ptr = GSS_C_NO_BUFFER; | ||
1662 | + | ||
1663 | + do { | ||
1664 | + debug("Calling gss_init_sec_context"); | ||
1665 | + | ||
1666 | + maj_status = ssh_gssapi_init_ctx(ctxt, | ||
1667 | + ssh->kex->gss_deleg_creds, token_ptr, &send_tok, | ||
1668 | + &ret_flags); | ||
1669 | + | ||
1670 | + if (GSS_ERROR(maj_status)) { | ||
1671 | + if (send_tok.length != 0) { | ||
1672 | + packet_start(SSH2_MSG_KEXGSS_CONTINUE); | ||
1673 | + packet_put_string(send_tok.value, | ||
1674 | + send_tok.length); | ||
1675 | + } | ||
1676 | + fatal("gss_init_context failed"); | ||
1677 | + } | ||
1678 | + | ||
1679 | + /* If we've got an old receive buffer get rid of it */ | ||
1680 | + if (token_ptr != GSS_C_NO_BUFFER) | ||
1681 | + free(recv_tok.value); | ||
1682 | + | ||
1683 | + if (maj_status == GSS_S_COMPLETE) { | ||
1684 | + /* If mutual state flag is not true, kex fails */ | ||
1685 | + if (!(ret_flags & GSS_C_MUTUAL_FLAG)) | ||
1686 | + fatal("Mutual authentication failed"); | ||
1687 | + | ||
1688 | + /* If integ avail flag is not true kex fails */ | ||
1689 | + if (!(ret_flags & GSS_C_INTEG_FLAG)) | ||
1690 | + fatal("Integrity check failed"); | ||
1691 | + } | ||
1692 | + | ||
1693 | + /* | ||
1694 | + * If we have data to send, then the last message that we | ||
1695 | + * received cannot have been a 'complete'. | ||
1696 | + */ | ||
1697 | + if (send_tok.length != 0) { | ||
1698 | + if (first) { | ||
1699 | + packet_start(SSH2_MSG_KEXGSS_INIT); | ||
1700 | + packet_put_string(send_tok.value, | ||
1701 | + send_tok.length); | ||
1702 | + packet_put_bignum2(dh->pub_key); | ||
1703 | + first = 0; | ||
1704 | + } else { | ||
1705 | + packet_start(SSH2_MSG_KEXGSS_CONTINUE); | ||
1706 | + packet_put_string(send_tok.value, | ||
1707 | + send_tok.length); | ||
1708 | + } | ||
1709 | + packet_send(); | ||
1710 | + gss_release_buffer(&min_status, &send_tok); | ||
1711 | + | ||
1712 | + /* If we've sent them data, they should reply */ | ||
1713 | + do { | ||
1714 | + type = packet_read(); | ||
1715 | + if (type == SSH2_MSG_KEXGSS_HOSTKEY) { | ||
1716 | + debug("Received KEXGSS_HOSTKEY"); | ||
1717 | + if (serverhostkey) | ||
1718 | + fatal("Server host key received more than once"); | ||
1719 | + serverhostkey = | ||
1720 | + packet_get_string(&slen); | ||
1721 | + } | ||
1722 | + } while (type == SSH2_MSG_KEXGSS_HOSTKEY); | ||
1723 | + | ||
1724 | + switch (type) { | ||
1725 | + case SSH2_MSG_KEXGSS_CONTINUE: | ||
1726 | + debug("Received GSSAPI_CONTINUE"); | ||
1727 | + if (maj_status == GSS_S_COMPLETE) | ||
1728 | + fatal("GSSAPI Continue received from server when complete"); | ||
1729 | + recv_tok.value = packet_get_string(&strlen); | ||
1730 | + recv_tok.length = strlen; | ||
1731 | + break; | ||
1732 | + case SSH2_MSG_KEXGSS_COMPLETE: | ||
1733 | + debug("Received GSSAPI_COMPLETE"); | ||
1734 | + packet_get_bignum2(dh_server_pub); | ||
1735 | + msg_tok.value = packet_get_string(&strlen); | ||
1736 | + msg_tok.length = strlen; | ||
1737 | + | ||
1738 | + /* Is there a token included? */ | ||
1739 | + if (packet_get_char()) { | ||
1740 | + recv_tok.value= | ||
1741 | + packet_get_string(&strlen); | ||
1742 | + recv_tok.length = strlen; | ||
1743 | + /* If we're already complete - protocol error */ | ||
1744 | + if (maj_status == GSS_S_COMPLETE) | ||
1745 | + packet_disconnect("Protocol error: received token when complete"); | ||
1746 | + } else { | ||
1747 | + /* No token included */ | ||
1748 | + if (maj_status != GSS_S_COMPLETE) | ||
1749 | + packet_disconnect("Protocol error: did not receive final token"); | ||
1750 | + } | ||
1751 | + break; | ||
1752 | + case SSH2_MSG_KEXGSS_ERROR: | ||
1753 | + debug("Received Error"); | ||
1754 | + maj_status = packet_get_int(); | ||
1755 | + min_status = packet_get_int(); | ||
1756 | + msg = packet_get_string(NULL); | ||
1757 | + (void) packet_get_string_ptr(NULL); | ||
1758 | + fatal("GSSAPI Error: \n%.400s",msg); | ||
1759 | + default: | ||
1760 | + packet_disconnect("Protocol error: didn't expect packet type %d", | ||
1761 | + type); | ||
1762 | + } | ||
1763 | + token_ptr = &recv_tok; | ||
1764 | + } else { | ||
1765 | + /* No data, and not complete */ | ||
1766 | + if (maj_status != GSS_S_COMPLETE) | ||
1767 | + fatal("Not complete, and no token output"); | ||
1768 | + } | ||
1769 | + } while (maj_status & GSS_S_CONTINUE_NEEDED); | ||
1770 | + | ||
1771 | + /* | ||
1772 | + * We _must_ have received a COMPLETE message in reply from the | ||
1773 | + * server, which will have set dh_server_pub and msg_tok | ||
1774 | + */ | ||
1775 | + | ||
1776 | + if (type != SSH2_MSG_KEXGSS_COMPLETE) | ||
1777 | + fatal("Didn't receive a SSH2_MSG_KEXGSS_COMPLETE when I expected it"); | ||
1778 | + | ||
1779 | + /* Check f in range [1, p-1] */ | ||
1780 | + if (!dh_pub_is_valid(dh, dh_server_pub)) | ||
1781 | + packet_disconnect("bad server public DH value"); | ||
1782 | + | ||
1783 | + /* compute K=f^x mod p */ | ||
1784 | + klen = DH_size(dh); | ||
1785 | + kbuf = xmalloc(klen); | ||
1786 | + kout = DH_compute_key(kbuf, dh_server_pub, dh); | ||
1787 | + if (kout < 0) | ||
1788 | + fatal("DH_compute_key: failed"); | ||
1789 | + | ||
1790 | + shared_secret = BN_new(); | ||
1791 | + if (shared_secret == NULL) | ||
1792 | + fatal("kexgss_client: BN_new failed"); | ||
1793 | + | ||
1794 | + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) | ||
1795 | + fatal("kexdh_client: BN_bin2bn failed"); | ||
1796 | + | ||
1797 | + memset(kbuf, 0, klen); | ||
1798 | + free(kbuf); | ||
1799 | + | ||
1800 | + hashlen = sizeof(hash); | ||
1801 | + switch (ssh->kex->kex_type) { | ||
1802 | + case KEX_GSS_GRP1_SHA1: | ||
1803 | + case KEX_GSS_GRP14_SHA1: | ||
1804 | + kex_dh_hash( | ||
1805 | + ssh->kex->hash_alg, | ||
1806 | + ssh->kex->client_version_string, | ||
1807 | + ssh->kex->server_version_string, | ||
1808 | + buffer_ptr(ssh->kex->my), buffer_len(ssh->kex->my), | ||
1809 | + buffer_ptr(ssh->kex->peer), buffer_len(ssh->kex->peer), | ||
1810 | + (serverhostkey ? serverhostkey : empty), slen, | ||
1811 | + dh->pub_key, /* e */ | ||
1812 | + dh_server_pub, /* f */ | ||
1813 | + shared_secret, /* K */ | ||
1814 | + hash, &hashlen | ||
1815 | + ); | ||
1816 | + break; | ||
1817 | + case KEX_GSS_GEX_SHA1: | ||
1818 | + kexgex_hash( | ||
1819 | + ssh->kex->hash_alg, | ||
1820 | + ssh->kex->client_version_string, | ||
1821 | + ssh->kex->server_version_string, | ||
1822 | + buffer_ptr(ssh->kex->my), buffer_len(ssh->kex->my), | ||
1823 | + buffer_ptr(ssh->kex->peer), buffer_len(ssh->kex->peer), | ||
1824 | + (serverhostkey ? serverhostkey : empty), slen, | ||
1825 | + min, nbits, max, | ||
1826 | + dh->p, dh->g, | ||
1827 | + dh->pub_key, | ||
1828 | + dh_server_pub, | ||
1829 | + shared_secret, | ||
1830 | + hash, &hashlen | ||
1831 | + ); | ||
1832 | + break; | ||
1833 | + default: | ||
1834 | + fatal("%s: Unexpected KEX type %d", __func__, ssh->kex->kex_type); | ||
1835 | + } | ||
1836 | + | ||
1837 | + gssbuf.value = hash; | ||
1838 | + gssbuf.length = hashlen; | ||
1839 | + | ||
1840 | + /* Verify that the hash matches the MIC we just got. */ | ||
1841 | + if (GSS_ERROR(ssh_gssapi_checkmic(ctxt, &gssbuf, &msg_tok))) | ||
1842 | + packet_disconnect("Hash's MIC didn't verify"); | ||
1843 | + | ||
1844 | + free(msg_tok.value); | ||
1845 | + | ||
1846 | + DH_free(dh); | ||
1847 | + free(serverhostkey); | ||
1848 | + BN_clear_free(dh_server_pub); | ||
1849 | + | ||
1850 | + /* save session id */ | ||
1851 | + if (ssh->kex->session_id == NULL) { | ||
1852 | + ssh->kex->session_id_len = hashlen; | ||
1853 | + ssh->kex->session_id = xmalloc(ssh->kex->session_id_len); | ||
1854 | + memcpy(ssh->kex->session_id, hash, ssh->kex->session_id_len); | ||
1855 | + } | ||
1856 | + | ||
1857 | + if (ssh->kex->gss_deleg_creds) | ||
1858 | + ssh_gssapi_credentials_updated(ctxt); | ||
1859 | + | ||
1860 | + if (gss_kex_context == NULL) | ||
1861 | + gss_kex_context = ctxt; | ||
1862 | + else | ||
1863 | + ssh_gssapi_delete_ctx(&ctxt); | ||
1864 | + | ||
1865 | + kex_derive_keys_bn(ssh, hash, hashlen, shared_secret); | ||
1866 | + BN_clear_free(shared_secret); | ||
1867 | + return kex_send_newkeys(ssh); | ||
1868 | +} | ||
1869 | + | ||
1870 | +#endif /* GSSAPI */ | ||
1871 | diff --git a/kexgsss.c b/kexgsss.c | ||
1872 | new file mode 100644 | ||
1873 | index 00000000..38ca082b | ||
1874 | --- /dev/null | ||
1875 | +++ b/kexgsss.c | ||
1876 | @@ -0,0 +1,295 @@ | ||
1877 | +/* | ||
1878 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
1879 | + * | ||
1880 | + * Redistribution and use in source and binary forms, with or without | ||
1881 | + * modification, are permitted provided that the following conditions | ||
1882 | + * are met: | ||
1883 | + * 1. Redistributions of source code must retain the above copyright | ||
1884 | + * notice, this list of conditions and the following disclaimer. | ||
1885 | + * 2. Redistributions in binary form must reproduce the above copyright | ||
1886 | + * notice, this list of conditions and the following disclaimer in the | ||
1887 | + * documentation and/or other materials provided with the distribution. | ||
1888 | + * | ||
1889 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR | ||
1890 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
1891 | + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
1892 | + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
1893 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
1894 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
1895 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
1896 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
1897 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
1898 | + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
1899 | + */ | ||
1900 | + | ||
1901 | +#include "includes.h" | ||
1902 | + | ||
1903 | +#ifdef GSSAPI | ||
1904 | + | ||
1905 | +#include <string.h> | ||
1906 | + | ||
1907 | +#include <openssl/crypto.h> | ||
1908 | +#include <openssl/bn.h> | ||
1909 | + | ||
1910 | +#include "xmalloc.h" | ||
1911 | +#include "buffer.h" | ||
1912 | +#include "ssh2.h" | ||
1913 | +#include "key.h" | ||
1914 | +#include "cipher.h" | ||
1915 | +#include "kex.h" | ||
1916 | +#include "log.h" | ||
1917 | +#include "packet.h" | ||
1918 | +#include "dh.h" | ||
1919 | +#include "ssh-gss.h" | ||
1920 | +#include "monitor_wrap.h" | ||
1921 | +#include "misc.h" | ||
1922 | +#include "servconf.h" | ||
1923 | +#include "digest.h" | ||
1924 | + | ||
1925 | +extern ServerOptions options; | ||
1926 | + | ||
1927 | +int | ||
1928 | +kexgss_server(struct ssh *ssh) | ||
1929 | +{ | ||
1930 | + OM_uint32 maj_status, min_status; | ||
1931 | + | ||
1932 | + /* | ||
1933 | + * Some GSSAPI implementations use the input value of ret_flags (an | ||
1934 | + * output variable) as a means of triggering mechanism specific | ||
1935 | + * features. Initializing it to zero avoids inadvertently | ||
1936 | + * activating this non-standard behaviour. | ||
1937 | + */ | ||
1938 | + | ||
1939 | + OM_uint32 ret_flags = 0; | ||
1940 | + gss_buffer_desc gssbuf, recv_tok, msg_tok; | ||
1941 | + gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER; | ||
1942 | + Gssctxt *ctxt = NULL; | ||
1943 | + u_int slen, klen, kout; | ||
1944 | + u_char *kbuf; | ||
1945 | + DH *dh; | ||
1946 | + int min = -1, max = -1, nbits = -1; | ||
1947 | + BIGNUM *shared_secret = NULL; | ||
1948 | + BIGNUM *dh_client_pub = NULL; | ||
1949 | + int type = 0; | ||
1950 | + gss_OID oid; | ||
1951 | + char *mechs; | ||
1952 | + u_char hash[SSH_DIGEST_MAX_LENGTH]; | ||
1953 | + size_t hashlen; | ||
1954 | + | ||
1955 | + /* Initialise GSSAPI */ | ||
1956 | + | ||
1957 | + /* If we're rekeying, privsep means that some of the private structures | ||
1958 | + * in the GSSAPI code are no longer available. This kludges them back | ||
1959 | + * into life | ||
1960 | + */ | ||
1961 | + if (!ssh_gssapi_oid_table_ok()) { | ||
1962 | + mechs = ssh_gssapi_server_mechanisms(); | ||
1963 | + free(mechs); | ||
1964 | + } | ||
1965 | + | ||
1966 | + debug2("%s: Identifying %s", __func__, ssh->kex->name); | ||
1967 | + oid = ssh_gssapi_id_kex(NULL, ssh->kex->name, ssh->kex->kex_type); | ||
1968 | + if (oid == GSS_C_NO_OID) | ||
1969 | + fatal("Unknown gssapi mechanism"); | ||
1970 | + | ||
1971 | + debug2("%s: Acquiring credentials", __func__); | ||
1972 | + | ||
1973 | + if (GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctxt, oid)))) | ||
1974 | + fatal("Unable to acquire credentials for the server"); | ||
1975 | + | ||
1976 | + switch (ssh->kex->kex_type) { | ||
1977 | + case KEX_GSS_GRP1_SHA1: | ||
1978 | + dh = dh_new_group1(); | ||
1979 | + break; | ||
1980 | + case KEX_GSS_GRP14_SHA1: | ||
1981 | + dh = dh_new_group14(); | ||
1982 | + break; | ||
1983 | + case KEX_GSS_GEX_SHA1: | ||
1984 | + debug("Doing group exchange"); | ||
1985 | + packet_read_expect(SSH2_MSG_KEXGSS_GROUPREQ); | ||
1986 | + min = packet_get_int(); | ||
1987 | + nbits = packet_get_int(); | ||
1988 | + max = packet_get_int(); | ||
1989 | + packet_check_eom(); | ||
1990 | + if (max < min || nbits < min || max < nbits) | ||
1991 | + fatal("GSS_GEX, bad parameters: %d !< %d !< %d", | ||
1992 | + min, nbits, max); | ||
1993 | + dh = PRIVSEP(choose_dh(MAX(DH_GRP_MIN, min), | ||
1994 | + nbits, MIN(DH_GRP_MAX, max))); | ||
1995 | + if (dh == NULL) | ||
1996 | + packet_disconnect("Protocol error: no matching group found"); | ||
1997 | + | ||
1998 | + packet_start(SSH2_MSG_KEXGSS_GROUP); | ||
1999 | + packet_put_bignum2(dh->p); | ||
2000 | + packet_put_bignum2(dh->g); | ||
2001 | + packet_send(); | ||
2002 | + | ||
2003 | + packet_write_wait(); | ||
2004 | + break; | ||
2005 | + default: | ||
2006 | + fatal("%s: Unexpected KEX type %d", __func__, ssh->kex->kex_type); | ||
2007 | + } | ||
2008 | + | ||
2009 | + dh_gen_key(dh, ssh->kex->we_need * 8); | ||
2010 | + | ||
2011 | + do { | ||
2012 | + debug("Wait SSH2_MSG_GSSAPI_INIT"); | ||
2013 | + type = packet_read(); | ||
2014 | + switch(type) { | ||
2015 | + case SSH2_MSG_KEXGSS_INIT: | ||
2016 | + if (dh_client_pub != NULL) | ||
2017 | + fatal("Received KEXGSS_INIT after initialising"); | ||
2018 | + recv_tok.value = packet_get_string(&slen); | ||
2019 | + recv_tok.length = slen; | ||
2020 | + | ||
2021 | + if ((dh_client_pub = BN_new()) == NULL) | ||
2022 | + fatal("dh_client_pub == NULL"); | ||
2023 | + | ||
2024 | + packet_get_bignum2(dh_client_pub); | ||
2025 | + | ||
2026 | + /* Send SSH_MSG_KEXGSS_HOSTKEY here, if we want */ | ||
2027 | + break; | ||
2028 | + case SSH2_MSG_KEXGSS_CONTINUE: | ||
2029 | + recv_tok.value = packet_get_string(&slen); | ||
2030 | + recv_tok.length = slen; | ||
2031 | + break; | ||
2032 | + default: | ||
2033 | + packet_disconnect( | ||
2034 | + "Protocol error: didn't expect packet type %d", | ||
2035 | + type); | ||
2036 | + } | ||
2037 | + | ||
2038 | + maj_status = PRIVSEP(ssh_gssapi_accept_ctx(ctxt, &recv_tok, | ||
2039 | + &send_tok, &ret_flags)); | ||
2040 | + | ||
2041 | + free(recv_tok.value); | ||
2042 | + | ||
2043 | + if (maj_status != GSS_S_COMPLETE && send_tok.length == 0) | ||
2044 | + fatal("Zero length token output when incomplete"); | ||
2045 | + | ||
2046 | + if (dh_client_pub == NULL) | ||
2047 | + fatal("No client public key"); | ||
2048 | + | ||
2049 | + if (maj_status & GSS_S_CONTINUE_NEEDED) { | ||
2050 | + debug("Sending GSSAPI_CONTINUE"); | ||
2051 | + packet_start(SSH2_MSG_KEXGSS_CONTINUE); | ||
2052 | + packet_put_string(send_tok.value, send_tok.length); | ||
2053 | + packet_send(); | ||
2054 | + gss_release_buffer(&min_status, &send_tok); | ||
2055 | + } | ||
2056 | + } while (maj_status & GSS_S_CONTINUE_NEEDED); | ||
2057 | + | ||
2058 | + if (GSS_ERROR(maj_status)) { | ||
2059 | + if (send_tok.length > 0) { | ||
2060 | + packet_start(SSH2_MSG_KEXGSS_CONTINUE); | ||
2061 | + packet_put_string(send_tok.value, send_tok.length); | ||
2062 | + packet_send(); | ||
2063 | + } | ||
2064 | + fatal("accept_ctx died"); | ||
2065 | + } | ||
2066 | + | ||
2067 | + if (!(ret_flags & GSS_C_MUTUAL_FLAG)) | ||
2068 | + fatal("Mutual Authentication flag wasn't set"); | ||
2069 | + | ||
2070 | + if (!(ret_flags & GSS_C_INTEG_FLAG)) | ||
2071 | + fatal("Integrity flag wasn't set"); | ||
2072 | + | ||
2073 | + if (!dh_pub_is_valid(dh, dh_client_pub)) | ||
2074 | + packet_disconnect("bad client public DH value"); | ||
2075 | + | ||
2076 | + klen = DH_size(dh); | ||
2077 | + kbuf = xmalloc(klen); | ||
2078 | + kout = DH_compute_key(kbuf, dh_client_pub, dh); | ||
2079 | + if (kout < 0) | ||
2080 | + fatal("DH_compute_key: failed"); | ||
2081 | + | ||
2082 | + shared_secret = BN_new(); | ||
2083 | + if (shared_secret == NULL) | ||
2084 | + fatal("kexgss_server: BN_new failed"); | ||
2085 | + | ||
2086 | + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) | ||
2087 | + fatal("kexgss_server: BN_bin2bn failed"); | ||
2088 | + | ||
2089 | + memset(kbuf, 0, klen); | ||
2090 | + free(kbuf); | ||
2091 | + | ||
2092 | + hashlen = sizeof(hash); | ||
2093 | + switch (ssh->kex->kex_type) { | ||
2094 | + case KEX_GSS_GRP1_SHA1: | ||
2095 | + case KEX_GSS_GRP14_SHA1: | ||
2096 | + kex_dh_hash( | ||
2097 | + ssh->kex->hash_alg, | ||
2098 | + ssh->kex->client_version_string, ssh->kex->server_version_string, | ||
2099 | + buffer_ptr(ssh->kex->peer), buffer_len(ssh->kex->peer), | ||
2100 | + buffer_ptr(ssh->kex->my), buffer_len(ssh->kex->my), | ||
2101 | + NULL, 0, /* Change this if we start sending host keys */ | ||
2102 | + dh_client_pub, dh->pub_key, shared_secret, | ||
2103 | + hash, &hashlen | ||
2104 | + ); | ||
2105 | + break; | ||
2106 | + case KEX_GSS_GEX_SHA1: | ||
2107 | + kexgex_hash( | ||
2108 | + ssh->kex->hash_alg, | ||
2109 | + ssh->kex->client_version_string, ssh->kex->server_version_string, | ||
2110 | + buffer_ptr(ssh->kex->peer), buffer_len(ssh->kex->peer), | ||
2111 | + buffer_ptr(ssh->kex->my), buffer_len(ssh->kex->my), | ||
2112 | + NULL, 0, | ||
2113 | + min, nbits, max, | ||
2114 | + dh->p, dh->g, | ||
2115 | + dh_client_pub, | ||
2116 | + dh->pub_key, | ||
2117 | + shared_secret, | ||
2118 | + hash, &hashlen | ||
2119 | + ); | ||
2120 | + break; | ||
2121 | + default: | ||
2122 | + fatal("%s: Unexpected KEX type %d", __func__, ssh->kex->kex_type); | ||
2123 | + } | ||
2124 | + | ||
2125 | + BN_clear_free(dh_client_pub); | ||
2126 | + | ||
2127 | + if (ssh->kex->session_id == NULL) { | ||
2128 | + ssh->kex->session_id_len = hashlen; | ||
2129 | + ssh->kex->session_id = xmalloc(ssh->kex->session_id_len); | ||
2130 | + memcpy(ssh->kex->session_id, hash, ssh->kex->session_id_len); | ||
2131 | + } | ||
2132 | + | ||
2133 | + gssbuf.value = hash; | ||
2134 | + gssbuf.length = hashlen; | ||
2135 | + | ||
2136 | + if (GSS_ERROR(PRIVSEP(ssh_gssapi_sign(ctxt,&gssbuf,&msg_tok)))) | ||
2137 | + fatal("Couldn't get MIC"); | ||
2138 | + | ||
2139 | + packet_start(SSH2_MSG_KEXGSS_COMPLETE); | ||
2140 | + packet_put_bignum2(dh->pub_key); | ||
2141 | + packet_put_string(msg_tok.value,msg_tok.length); | ||
2142 | + | ||
2143 | + if (send_tok.length != 0) { | ||
2144 | + packet_put_char(1); /* true */ | ||
2145 | + packet_put_string(send_tok.value, send_tok.length); | ||
2146 | + } else { | ||
2147 | + packet_put_char(0); /* false */ | ||
2148 | + } | ||
2149 | + packet_send(); | ||
2150 | + | ||
2151 | + gss_release_buffer(&min_status, &send_tok); | ||
2152 | + gss_release_buffer(&min_status, &msg_tok); | ||
2153 | + | ||
2154 | + if (gss_kex_context == NULL) | ||
2155 | + gss_kex_context = ctxt; | ||
2156 | + else | ||
2157 | + ssh_gssapi_delete_ctx(&ctxt); | ||
2158 | + | ||
2159 | + DH_free(dh); | ||
2160 | + | ||
2161 | + kex_derive_keys_bn(ssh, hash, hashlen, shared_secret); | ||
2162 | + BN_clear_free(shared_secret); | ||
2163 | + kex_send_newkeys(ssh); | ||
2164 | + | ||
2165 | + /* If this was a rekey, then save out any delegated credentials we | ||
2166 | + * just exchanged. */ | ||
2167 | + if (options.gss_store_rekey) | ||
2168 | + ssh_gssapi_rekey_creds(); | ||
2169 | + return 0; | ||
2170 | +} | ||
2171 | +#endif /* GSSAPI */ | ||
2172 | diff --git a/monitor.c b/monitor.c | ||
2173 | index f517da48..cabfeb8a 100644 | ||
2174 | --- a/monitor.c | ||
2175 | +++ b/monitor.c | ||
2176 | @@ -157,6 +157,8 @@ int mm_answer_gss_setup_ctx(int, Buffer *); | ||
2177 | int mm_answer_gss_accept_ctx(int, Buffer *); | ||
2178 | int mm_answer_gss_userok(int, Buffer *); | ||
2179 | int mm_answer_gss_checkmic(int, Buffer *); | ||
2180 | +int mm_answer_gss_sign(int, Buffer *); | ||
2181 | +int mm_answer_gss_updatecreds(int, Buffer *); | ||
2182 | #endif | ||
2183 | |||
2184 | #ifdef SSH_AUDIT_EVENTS | ||
2185 | @@ -230,11 +232,18 @@ struct mon_table mon_dispatch_proto20[] = { | ||
2186 | {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx}, | ||
2187 | {MONITOR_REQ_GSSUSEROK, MON_ONCE|MON_AUTHDECIDE, mm_answer_gss_userok}, | ||
2188 | {MONITOR_REQ_GSSCHECKMIC, MON_ONCE, mm_answer_gss_checkmic}, | ||
2189 | + {MONITOR_REQ_GSSSIGN, MON_ONCE, mm_answer_gss_sign}, | ||
2190 | #endif | ||
2191 | {0, 0, NULL} | ||
2192 | }; | ||
2193 | |||
2194 | struct mon_table mon_dispatch_postauth20[] = { | ||
2195 | +#ifdef GSSAPI | ||
2196 | + {MONITOR_REQ_GSSSETUP, 0, mm_answer_gss_setup_ctx}, | ||
2197 | + {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx}, | ||
2198 | + {MONITOR_REQ_GSSSIGN, 0, mm_answer_gss_sign}, | ||
2199 | + {MONITOR_REQ_GSSUPCREDS, 0, mm_answer_gss_updatecreds}, | ||
2200 | +#endif | ||
2201 | #ifdef WITH_OPENSSL | ||
2202 | {MONITOR_REQ_MODULI, 0, mm_answer_moduli}, | ||
2203 | #endif | ||
2204 | @@ -302,6 +311,10 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor) | ||
2205 | /* Permit requests for moduli and signatures */ | ||
2206 | monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); | ||
2207 | monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); | ||
2208 | +#ifdef GSSAPI | ||
2209 | + /* and for the GSSAPI key exchange */ | ||
2210 | + monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1); | ||
2211 | +#endif | ||
2212 | |||
2213 | /* The first few requests do not require asynchronous access */ | ||
2214 | while (!authenticated) { | ||
2215 | @@ -408,6 +421,10 @@ monitor_child_postauth(struct monitor *pmonitor) | ||
2216 | monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); | ||
2217 | monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); | ||
2218 | monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); | ||
2219 | +#ifdef GSSAPI | ||
2220 | + /* and for the GSSAPI key exchange */ | ||
2221 | + monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1); | ||
2222 | +#endif | ||
2223 | |||
2224 | if (!no_pty_flag) { | ||
2225 | monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); | ||
2226 | @@ -1626,6 +1643,13 @@ monitor_apply_keystate(struct monitor *pmonitor) | ||
2227 | # endif | ||
2228 | #endif /* WITH_OPENSSL */ | ||
2229 | kex->kex[KEX_C25519_SHA256] = kexc25519_server; | ||
2230 | +#ifdef GSSAPI | ||
2231 | + if (options.gss_keyex) { | ||
2232 | + kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; | ||
2233 | + kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server; | ||
2234 | + kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server; | ||
2235 | + } | ||
2236 | +#endif | ||
2237 | kex->load_host_public_key=&get_hostkey_public_by_type; | ||
2238 | kex->load_host_private_key=&get_hostkey_private_by_type; | ||
2239 | kex->host_key_index=&get_hostkey_index; | ||
2240 | @@ -1714,8 +1738,8 @@ mm_answer_gss_setup_ctx(int sock, Buffer *m) | ||
2241 | OM_uint32 major; | ||
2242 | u_int len; | ||
2243 | |||
2244 | - if (!options.gss_authentication) | ||
2245 | - fatal("%s: GSSAPI authentication not enabled", __func__); | ||
2246 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2247 | + fatal("%s: GSSAPI not enabled", __func__); | ||
2248 | |||
2249 | goid.elements = buffer_get_string(m, &len); | ||
2250 | goid.length = len; | ||
2251 | @@ -1744,8 +1768,8 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m) | ||
2252 | OM_uint32 flags = 0; /* GSI needs this */ | ||
2253 | u_int len; | ||
2254 | |||
2255 | - if (!options.gss_authentication) | ||
2256 | - fatal("%s: GSSAPI authentication not enabled", __func__); | ||
2257 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2258 | + fatal("%s: GSSAPI not enabled", __func__); | ||
2259 | |||
2260 | in.value = buffer_get_string(m, &len); | ||
2261 | in.length = len; | ||
2262 | @@ -1764,6 +1788,7 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m) | ||
2263 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0); | ||
2264 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1); | ||
2265 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1); | ||
2266 | + monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1); | ||
2267 | } | ||
2268 | return (0); | ||
2269 | } | ||
2270 | @@ -1775,8 +1800,8 @@ mm_answer_gss_checkmic(int sock, Buffer *m) | ||
2271 | OM_uint32 ret; | ||
2272 | u_int len; | ||
2273 | |||
2274 | - if (!options.gss_authentication) | ||
2275 | - fatal("%s: GSSAPI authentication not enabled", __func__); | ||
2276 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2277 | + fatal("%s: GSSAPI not enabled", __func__); | ||
2278 | |||
2279 | gssbuf.value = buffer_get_string(m, &len); | ||
2280 | gssbuf.length = len; | ||
2281 | @@ -1805,10 +1830,11 @@ mm_answer_gss_userok(int sock, Buffer *m) | ||
2282 | int authenticated; | ||
2283 | const char *displayname; | ||
2284 | |||
2285 | - if (!options.gss_authentication) | ||
2286 | - fatal("%s: GSSAPI authentication not enabled", __func__); | ||
2287 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2288 | + fatal("%s: GSSAPI not enabled", __func__); | ||
2289 | |||
2290 | - authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user); | ||
2291 | + authenticated = authctxt->valid && | ||
2292 | + ssh_gssapi_userok(authctxt->user, authctxt->pw); | ||
2293 | |||
2294 | buffer_clear(m); | ||
2295 | buffer_put_int(m, authenticated); | ||
2296 | @@ -1824,5 +1850,76 @@ mm_answer_gss_userok(int sock, Buffer *m) | ||
2297 | /* Monitor loop will terminate if authenticated */ | ||
2298 | return (authenticated); | ||
2299 | } | ||
2300 | + | ||
2301 | +int | ||
2302 | +mm_answer_gss_sign(int socket, Buffer *m) | ||
2303 | +{ | ||
2304 | + gss_buffer_desc data; | ||
2305 | + gss_buffer_desc hash = GSS_C_EMPTY_BUFFER; | ||
2306 | + OM_uint32 major, minor; | ||
2307 | + u_int len; | ||
2308 | + | ||
2309 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2310 | + fatal("%s: GSSAPI not enabled", __func__); | ||
2311 | + | ||
2312 | + data.value = buffer_get_string(m, &len); | ||
2313 | + data.length = len; | ||
2314 | + if (data.length != 20) | ||
2315 | + fatal("%s: data length incorrect: %d", __func__, | ||
2316 | + (int) data.length); | ||
2317 | + | ||
2318 | + /* Save the session ID on the first time around */ | ||
2319 | + if (session_id2_len == 0) { | ||
2320 | + session_id2_len = data.length; | ||
2321 | + session_id2 = xmalloc(session_id2_len); | ||
2322 | + memcpy(session_id2, data.value, session_id2_len); | ||
2323 | + } | ||
2324 | + major = ssh_gssapi_sign(gsscontext, &data, &hash); | ||
2325 | + | ||
2326 | + free(data.value); | ||
2327 | + | ||
2328 | + buffer_clear(m); | ||
2329 | + buffer_put_int(m, major); | ||
2330 | + buffer_put_string(m, hash.value, hash.length); | ||
2331 | + | ||
2332 | + mm_request_send(socket, MONITOR_ANS_GSSSIGN, m); | ||
2333 | + | ||
2334 | + gss_release_buffer(&minor, &hash); | ||
2335 | + | ||
2336 | + /* Turn on getpwnam permissions */ | ||
2337 | + monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1); | ||
2338 | + | ||
2339 | + /* And credential updating, for when rekeying */ | ||
2340 | + monitor_permit(mon_dispatch, MONITOR_REQ_GSSUPCREDS, 1); | ||
2341 | + | ||
2342 | + return (0); | ||
2343 | +} | ||
2344 | + | ||
2345 | +int | ||
2346 | +mm_answer_gss_updatecreds(int socket, Buffer *m) { | ||
2347 | + ssh_gssapi_ccache store; | ||
2348 | + int ok; | ||
2349 | + | ||
2350 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2351 | + fatal("%s: GSSAPI not enabled", __func__); | ||
2352 | + | ||
2353 | + store.filename = buffer_get_string(m, NULL); | ||
2354 | + store.envvar = buffer_get_string(m, NULL); | ||
2355 | + store.envval = buffer_get_string(m, NULL); | ||
2356 | + | ||
2357 | + ok = ssh_gssapi_update_creds(&store); | ||
2358 | + | ||
2359 | + free(store.filename); | ||
2360 | + free(store.envvar); | ||
2361 | + free(store.envval); | ||
2362 | + | ||
2363 | + buffer_clear(m); | ||
2364 | + buffer_put_int(m, ok); | ||
2365 | + | ||
2366 | + mm_request_send(socket, MONITOR_ANS_GSSUPCREDS, m); | ||
2367 | + | ||
2368 | + return(0); | ||
2369 | +} | ||
2370 | + | ||
2371 | #endif /* GSSAPI */ | ||
2372 | |||
2373 | diff --git a/monitor.h b/monitor.h | ||
2374 | index d68f6745..ec41404c 100644 | ||
2375 | --- a/monitor.h | ||
2376 | +++ b/monitor.h | ||
2377 | @@ -65,6 +65,9 @@ enum monitor_reqtype { | ||
2378 | MONITOR_REQ_PAM_FREE_CTX = 110, MONITOR_ANS_PAM_FREE_CTX = 111, | ||
2379 | MONITOR_REQ_AUDIT_EVENT = 112, MONITOR_REQ_AUDIT_COMMAND = 113, | ||
2380 | |||
2381 | + MONITOR_REQ_GSSSIGN = 150, MONITOR_ANS_GSSSIGN = 151, | ||
2382 | + MONITOR_REQ_GSSUPCREDS = 152, MONITOR_ANS_GSSUPCREDS = 153, | ||
2383 | + | ||
2384 | }; | ||
2385 | |||
2386 | struct monitor { | ||
2387 | diff --git a/monitor_wrap.c b/monitor_wrap.c | ||
2388 | index 69212aaf..0e171a6a 100644 | ||
2389 | --- a/monitor_wrap.c | ||
2390 | +++ b/monitor_wrap.c | ||
2391 | @@ -937,7 +937,7 @@ mm_ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic) | ||
2392 | } | ||
2393 | |||
2394 | int | ||
2395 | -mm_ssh_gssapi_userok(char *user) | ||
2396 | +mm_ssh_gssapi_userok(char *user, struct passwd *pw) | ||
2397 | { | ||
2398 | Buffer m; | ||
2399 | int authenticated = 0; | ||
2400 | @@ -954,5 +954,50 @@ mm_ssh_gssapi_userok(char *user) | ||
2401 | debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not "); | ||
2402 | return (authenticated); | ||
2403 | } | ||
2404 | + | ||
2405 | +OM_uint32 | ||
2406 | +mm_ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_desc *data, gss_buffer_desc *hash) | ||
2407 | +{ | ||
2408 | + Buffer m; | ||
2409 | + OM_uint32 major; | ||
2410 | + u_int len; | ||
2411 | + | ||
2412 | + buffer_init(&m); | ||
2413 | + buffer_put_string(&m, data->value, data->length); | ||
2414 | + | ||
2415 | + mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSIGN, &m); | ||
2416 | + mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSIGN, &m); | ||
2417 | + | ||
2418 | + major = buffer_get_int(&m); | ||
2419 | + hash->value = buffer_get_string(&m, &len); | ||
2420 | + hash->length = len; | ||
2421 | + | ||
2422 | + buffer_free(&m); | ||
2423 | + | ||
2424 | + return(major); | ||
2425 | +} | ||
2426 | + | ||
2427 | +int | ||
2428 | +mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *store) | ||
2429 | +{ | ||
2430 | + Buffer m; | ||
2431 | + int ok; | ||
2432 | + | ||
2433 | + buffer_init(&m); | ||
2434 | + | ||
2435 | + buffer_put_cstring(&m, store->filename ? store->filename : ""); | ||
2436 | + buffer_put_cstring(&m, store->envvar ? store->envvar : ""); | ||
2437 | + buffer_put_cstring(&m, store->envval ? store->envval : ""); | ||
2438 | + | ||
2439 | + mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSUPCREDS, &m); | ||
2440 | + mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSUPCREDS, &m); | ||
2441 | + | ||
2442 | + ok = buffer_get_int(&m); | ||
2443 | + | ||
2444 | + buffer_free(&m); | ||
2445 | + | ||
2446 | + return (ok); | ||
2447 | +} | ||
2448 | + | ||
2449 | #endif /* GSSAPI */ | ||
2450 | |||
2451 | diff --git a/monitor_wrap.h b/monitor_wrap.h | ||
2452 | index 9e032d20..7b2e8945 100644 | ||
2453 | --- a/monitor_wrap.h | ||
2454 | +++ b/monitor_wrap.h | ||
2455 | @@ -57,8 +57,10 @@ int mm_sshkey_verify(const struct sshkey *, const u_char *, size_t, | ||
2456 | OM_uint32 mm_ssh_gssapi_server_ctx(Gssctxt **, gss_OID); | ||
2457 | OM_uint32 mm_ssh_gssapi_accept_ctx(Gssctxt *, | ||
2458 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | ||
2459 | -int mm_ssh_gssapi_userok(char *user); | ||
2460 | +int mm_ssh_gssapi_userok(char *user, struct passwd *); | ||
2461 | OM_uint32 mm_ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); | ||
2462 | +OM_uint32 mm_ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); | ||
2463 | +int mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *); | ||
2464 | #endif | ||
2465 | |||
2466 | #ifdef USE_PAM | ||
2467 | diff --git a/readconf.c b/readconf.c | ||
2468 | index f63894f9..99e03ee1 100644 | ||
2469 | --- a/readconf.c | ||
2470 | +++ b/readconf.c | ||
2471 | @@ -160,6 +160,8 @@ typedef enum { | ||
2472 | oClearAllForwardings, oNoHostAuthenticationForLocalhost, | ||
2473 | oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout, | ||
2474 | oAddressFamily, oGssAuthentication, oGssDelegateCreds, | ||
2475 | + oGssTrustDns, oGssKeyEx, oGssClientIdentity, oGssRenewalRekey, | ||
2476 | + oGssServerIdentity, | ||
2477 | oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, | ||
2478 | oSendEnv, oControlPath, oControlMaster, oControlPersist, | ||
2479 | oHashKnownHosts, | ||
2480 | @@ -199,10 +201,20 @@ static struct { | ||
2481 | /* Sometimes-unsupported options */ | ||
2482 | #if defined(GSSAPI) | ||
2483 | { "gssapiauthentication", oGssAuthentication }, | ||
2484 | + { "gssapikeyexchange", oGssKeyEx }, | ||
2485 | { "gssapidelegatecredentials", oGssDelegateCreds }, | ||
2486 | + { "gssapitrustdns", oGssTrustDns }, | ||
2487 | + { "gssapiclientidentity", oGssClientIdentity }, | ||
2488 | + { "gssapiserveridentity", oGssServerIdentity }, | ||
2489 | + { "gssapirenewalforcesrekey", oGssRenewalRekey }, | ||
2490 | # else | ||
2491 | { "gssapiauthentication", oUnsupported }, | ||
2492 | + { "gssapikeyexchange", oUnsupported }, | ||
2493 | { "gssapidelegatecredentials", oUnsupported }, | ||
2494 | + { "gssapitrustdns", oUnsupported }, | ||
2495 | + { "gssapiclientidentity", oUnsupported }, | ||
2496 | + { "gssapiserveridentity", oUnsupported }, | ||
2497 | + { "gssapirenewalforcesrekey", oUnsupported }, | ||
2498 | #endif | ||
2499 | #ifdef ENABLE_PKCS11 | ||
2500 | { "smartcarddevice", oPKCS11Provider }, | ||
2501 | @@ -976,10 +988,30 @@ parse_time: | ||
2502 | intptr = &options->gss_authentication; | ||
2503 | goto parse_flag; | ||
2504 | |||
2505 | + case oGssKeyEx: | ||
2506 | + intptr = &options->gss_keyex; | ||
2507 | + goto parse_flag; | ||
2508 | + | ||
2509 | case oGssDelegateCreds: | ||
2510 | intptr = &options->gss_deleg_creds; | ||
2511 | goto parse_flag; | ||
2512 | |||
2513 | + case oGssTrustDns: | ||
2514 | + intptr = &options->gss_trust_dns; | ||
2515 | + goto parse_flag; | ||
2516 | + | ||
2517 | + case oGssClientIdentity: | ||
2518 | + charptr = &options->gss_client_identity; | ||
2519 | + goto parse_string; | ||
2520 | + | ||
2521 | + case oGssServerIdentity: | ||
2522 | + charptr = &options->gss_server_identity; | ||
2523 | + goto parse_string; | ||
2524 | + | ||
2525 | + case oGssRenewalRekey: | ||
2526 | + intptr = &options->gss_renewal_rekey; | ||
2527 | + goto parse_flag; | ||
2528 | + | ||
2529 | case oBatchMode: | ||
2530 | intptr = &options->batch_mode; | ||
2531 | goto parse_flag; | ||
2532 | @@ -1790,7 +1822,12 @@ initialize_options(Options * options) | ||
2533 | options->pubkey_authentication = -1; | ||
2534 | options->challenge_response_authentication = -1; | ||
2535 | options->gss_authentication = -1; | ||
2536 | + options->gss_keyex = -1; | ||
2537 | options->gss_deleg_creds = -1; | ||
2538 | + options->gss_trust_dns = -1; | ||
2539 | + options->gss_renewal_rekey = -1; | ||
2540 | + options->gss_client_identity = NULL; | ||
2541 | + options->gss_server_identity = NULL; | ||
2542 | options->password_authentication = -1; | ||
2543 | options->kbd_interactive_authentication = -1; | ||
2544 | options->kbd_interactive_devices = NULL; | ||
2545 | @@ -1930,8 +1967,14 @@ fill_default_options(Options * options) | ||
2546 | options->challenge_response_authentication = 1; | ||
2547 | if (options->gss_authentication == -1) | ||
2548 | options->gss_authentication = 0; | ||
2549 | + if (options->gss_keyex == -1) | ||
2550 | + options->gss_keyex = 0; | ||
2551 | if (options->gss_deleg_creds == -1) | ||
2552 | options->gss_deleg_creds = 0; | ||
2553 | + if (options->gss_trust_dns == -1) | ||
2554 | + options->gss_trust_dns = 0; | ||
2555 | + if (options->gss_renewal_rekey == -1) | ||
2556 | + options->gss_renewal_rekey = 0; | ||
2557 | if (options->password_authentication == -1) | ||
2558 | options->password_authentication = 1; | ||
2559 | if (options->kbd_interactive_authentication == -1) | ||
2560 | diff --git a/readconf.h b/readconf.h | ||
2561 | index 22fe5c18..d61161a8 100644 | ||
2562 | --- a/readconf.h | ||
2563 | +++ b/readconf.h | ||
2564 | @@ -42,7 +42,12 @@ typedef struct { | ||
2565 | int challenge_response_authentication; | ||
2566 | /* Try S/Key or TIS, authentication. */ | ||
2567 | int gss_authentication; /* Try GSS authentication */ | ||
2568 | + int gss_keyex; /* Try GSS key exchange */ | ||
2569 | int gss_deleg_creds; /* Delegate GSS credentials */ | ||
2570 | + int gss_trust_dns; /* Trust DNS for GSS canonicalization */ | ||
2571 | + int gss_renewal_rekey; /* Credential renewal forces rekey */ | ||
2572 | + char *gss_client_identity; /* Principal to initiate GSSAPI with */ | ||
2573 | + char *gss_server_identity; /* GSSAPI target principal */ | ||
2574 | int password_authentication; /* Try password | ||
2575 | * authentication. */ | ||
2576 | int kbd_interactive_authentication; /* Try keyboard-interactive auth. */ | ||
2577 | diff --git a/servconf.c b/servconf.c | ||
2578 | index 2c321a4a..8ba74517 100644 | ||
2579 | --- a/servconf.c | ||
2580 | +++ b/servconf.c | ||
2581 | @@ -113,8 +113,10 @@ initialize_server_options(ServerOptions *options) | ||
2582 | options->kerberos_ticket_cleanup = -1; | ||
2583 | options->kerberos_get_afs_token = -1; | ||
2584 | options->gss_authentication=-1; | ||
2585 | + options->gss_keyex = -1; | ||
2586 | options->gss_cleanup_creds = -1; | ||
2587 | options->gss_strict_acceptor = -1; | ||
2588 | + options->gss_store_rekey = -1; | ||
2589 | options->password_authentication = -1; | ||
2590 | options->kbd_interactive_authentication = -1; | ||
2591 | options->challenge_response_authentication = -1; | ||
2592 | @@ -268,10 +270,14 @@ fill_default_server_options(ServerOptions *options) | ||
2593 | options->kerberos_get_afs_token = 0; | ||
2594 | if (options->gss_authentication == -1) | ||
2595 | options->gss_authentication = 0; | ||
2596 | + if (options->gss_keyex == -1) | ||
2597 | + options->gss_keyex = 0; | ||
2598 | if (options->gss_cleanup_creds == -1) | ||
2599 | options->gss_cleanup_creds = 1; | ||
2600 | if (options->gss_strict_acceptor == -1) | ||
2601 | options->gss_strict_acceptor = 1; | ||
2602 | + if (options->gss_store_rekey == -1) | ||
2603 | + options->gss_store_rekey = 0; | ||
2604 | if (options->password_authentication == -1) | ||
2605 | options->password_authentication = 1; | ||
2606 | if (options->kbd_interactive_authentication == -1) | ||
2607 | @@ -410,6 +416,7 @@ typedef enum { | ||
2608 | sHostKeyAlgorithms, | ||
2609 | sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile, | ||
2610 | sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor, | ||
2611 | + sGssKeyEx, sGssStoreRekey, | ||
2612 | sAcceptEnv, sPermitTunnel, | ||
2613 | sMatch, sPermitOpen, sForceCommand, sChrootDirectory, | ||
2614 | sUsePrivilegeSeparation, sAllowAgentForwarding, | ||
2615 | @@ -484,12 +491,20 @@ static struct { | ||
2616 | #ifdef GSSAPI | ||
2617 | { "gssapiauthentication", sGssAuthentication, SSHCFG_ALL }, | ||
2618 | { "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL }, | ||
2619 | + { "gssapicleanupcreds", sGssCleanupCreds, SSHCFG_GLOBAL }, | ||
2620 | { "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL }, | ||
2621 | + { "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL }, | ||
2622 | + { "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL }, | ||
2623 | #else | ||
2624 | { "gssapiauthentication", sUnsupported, SSHCFG_ALL }, | ||
2625 | { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL }, | ||
2626 | + { "gssapicleanupcreds", sUnsupported, SSHCFG_GLOBAL }, | ||
2627 | { "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL }, | ||
2628 | + { "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL }, | ||
2629 | + { "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL }, | ||
2630 | #endif | ||
2631 | + { "gssusesessionccache", sUnsupported, SSHCFG_GLOBAL }, | ||
2632 | + { "gssapiusesessioncredcache", sUnsupported, SSHCFG_GLOBAL }, | ||
2633 | { "passwordauthentication", sPasswordAuthentication, SSHCFG_ALL }, | ||
2634 | { "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_ALL }, | ||
2635 | { "challengeresponseauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, | ||
2636 | @@ -1253,6 +1268,10 @@ process_server_config_line(ServerOptions *options, char *line, | ||
2637 | intptr = &options->gss_authentication; | ||
2638 | goto parse_flag; | ||
2639 | |||
2640 | + case sGssKeyEx: | ||
2641 | + intptr = &options->gss_keyex; | ||
2642 | + goto parse_flag; | ||
2643 | + | ||
2644 | case sGssCleanupCreds: | ||
2645 | intptr = &options->gss_cleanup_creds; | ||
2646 | goto parse_flag; | ||
2647 | @@ -1261,6 +1280,10 @@ process_server_config_line(ServerOptions *options, char *line, | ||
2648 | intptr = &options->gss_strict_acceptor; | ||
2649 | goto parse_flag; | ||
2650 | |||
2651 | + case sGssStoreRekey: | ||
2652 | + intptr = &options->gss_store_rekey; | ||
2653 | + goto parse_flag; | ||
2654 | + | ||
2655 | case sPasswordAuthentication: | ||
2656 | intptr = &options->password_authentication; | ||
2657 | goto parse_flag; | ||
2658 | @@ -2301,7 +2324,10 @@ dump_config(ServerOptions *o) | ||
2659 | #endif | ||
2660 | #ifdef GSSAPI | ||
2661 | dump_cfg_fmtint(sGssAuthentication, o->gss_authentication); | ||
2662 | + dump_cfg_fmtint(sGssKeyEx, o->gss_keyex); | ||
2663 | dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds); | ||
2664 | + dump_cfg_fmtint(sGssStrictAcceptor, o->gss_strict_acceptor); | ||
2665 | + dump_cfg_fmtint(sGssStoreRekey, o->gss_store_rekey); | ||
2666 | #endif | ||
2667 | dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication); | ||
2668 | dump_cfg_fmtint(sKbdInteractiveAuthentication, | ||
2669 | diff --git a/servconf.h b/servconf.h | ||
2670 | index 1dca702e..641e93c8 100644 | ||
2671 | --- a/servconf.h | ||
2672 | +++ b/servconf.h | ||
2673 | @@ -119,8 +119,10 @@ typedef struct { | ||
2674 | int kerberos_get_afs_token; /* If true, try to get AFS token if | ||
2675 | * authenticated with Kerberos. */ | ||
2676 | int gss_authentication; /* If true, permit GSSAPI authentication */ | ||
2677 | + int gss_keyex; /* If true, permit GSSAPI key exchange */ | ||
2678 | int gss_cleanup_creds; /* If true, destroy cred cache on logout */ | ||
2679 | int gss_strict_acceptor; /* If true, restrict the GSSAPI acceptor name */ | ||
2680 | + int gss_store_rekey; | ||
2681 | int password_authentication; /* If true, permit password | ||
2682 | * authentication. */ | ||
2683 | int kbd_interactive_authentication; /* If true, permit */ | ||
2684 | diff --git a/ssh-gss.h b/ssh-gss.h | ||
2685 | index 6593e422..919660a0 100644 | ||
2686 | --- a/ssh-gss.h | ||
2687 | +++ b/ssh-gss.h | ||
2688 | @@ -1,6 +1,6 @@ | ||
2689 | /* $OpenBSD: ssh-gss.h,v 1.12 2017/06/24 06:34:38 djm Exp $ */ | ||
2690 | /* | ||
2691 | - * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | ||
2692 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
2693 | * | ||
2694 | * Redistribution and use in source and binary forms, with or without | ||
2695 | * modification, are permitted provided that the following conditions | ||
2696 | @@ -61,10 +61,22 @@ | ||
2697 | |||
2698 | #define SSH_GSS_OIDTYPE 0x06 | ||
2699 | |||
2700 | +#define SSH2_MSG_KEXGSS_INIT 30 | ||
2701 | +#define SSH2_MSG_KEXGSS_CONTINUE 31 | ||
2702 | +#define SSH2_MSG_KEXGSS_COMPLETE 32 | ||
2703 | +#define SSH2_MSG_KEXGSS_HOSTKEY 33 | ||
2704 | +#define SSH2_MSG_KEXGSS_ERROR 34 | ||
2705 | +#define SSH2_MSG_KEXGSS_GROUPREQ 40 | ||
2706 | +#define SSH2_MSG_KEXGSS_GROUP 41 | ||
2707 | +#define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-" | ||
2708 | +#define KEX_GSS_GRP14_SHA1_ID "gss-group14-sha1-" | ||
2709 | +#define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-" | ||
2710 | + | ||
2711 | typedef struct { | ||
2712 | char *filename; | ||
2713 | char *envvar; | ||
2714 | char *envval; | ||
2715 | + struct passwd *owner; | ||
2716 | void *data; | ||
2717 | } ssh_gssapi_ccache; | ||
2718 | |||
2719 | @@ -72,8 +84,11 @@ typedef struct { | ||
2720 | gss_buffer_desc displayname; | ||
2721 | gss_buffer_desc exportedname; | ||
2722 | gss_cred_id_t creds; | ||
2723 | + gss_name_t name; | ||
2724 | struct ssh_gssapi_mech_struct *mech; | ||
2725 | ssh_gssapi_ccache store; | ||
2726 | + int used; | ||
2727 | + int updated; | ||
2728 | } ssh_gssapi_client; | ||
2729 | |||
2730 | typedef struct ssh_gssapi_mech_struct { | ||
2731 | @@ -84,6 +99,7 @@ typedef struct ssh_gssapi_mech_struct { | ||
2732 | int (*userok) (ssh_gssapi_client *, char *); | ||
2733 | int (*localname) (ssh_gssapi_client *, char **); | ||
2734 | void (*storecreds) (ssh_gssapi_client *); | ||
2735 | + int (*updatecreds) (ssh_gssapi_ccache *, ssh_gssapi_client *); | ||
2736 | } ssh_gssapi_mech; | ||
2737 | |||
2738 | typedef struct { | ||
2739 | @@ -94,10 +110,11 @@ typedef struct { | ||
2740 | gss_OID oid; /* client */ | ||
2741 | gss_cred_id_t creds; /* server */ | ||
2742 | gss_name_t client; /* server */ | ||
2743 | - gss_cred_id_t client_creds; /* server */ | ||
2744 | + gss_cred_id_t client_creds; /* both */ | ||
2745 | } Gssctxt; | ||
2746 | |||
2747 | extern ssh_gssapi_mech *supported_mechs[]; | ||
2748 | +extern Gssctxt *gss_kex_context; | ||
2749 | |||
2750 | int ssh_gssapi_check_oid(Gssctxt *, void *, size_t); | ||
2751 | void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); | ||
2752 | @@ -119,17 +136,33 @@ void ssh_gssapi_build_ctx(Gssctxt **); | ||
2753 | void ssh_gssapi_delete_ctx(Gssctxt **); | ||
2754 | OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); | ||
2755 | void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); | ||
2756 | -int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *); | ||
2757 | +int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *, const char *); | ||
2758 | +OM_uint32 ssh_gssapi_client_identity(Gssctxt *, const char *); | ||
2759 | +int ssh_gssapi_credentials_updated(Gssctxt *); | ||
2760 | |||
2761 | /* In the server */ | ||
2762 | +typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *, | ||
2763 | + const char *); | ||
2764 | +char *ssh_gssapi_client_mechanisms(const char *, const char *); | ||
2765 | +char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *, | ||
2766 | + const char *); | ||
2767 | +gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int); | ||
2768 | +int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *, | ||
2769 | + const char *); | ||
2770 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); | ||
2771 | -int ssh_gssapi_userok(char *name); | ||
2772 | +int ssh_gssapi_userok(char *name, struct passwd *); | ||
2773 | OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); | ||
2774 | void ssh_gssapi_do_child(char ***, u_int *); | ||
2775 | void ssh_gssapi_cleanup_creds(void); | ||
2776 | void ssh_gssapi_storecreds(void); | ||
2777 | const char *ssh_gssapi_displayname(void); | ||
2778 | |||
2779 | +char *ssh_gssapi_server_mechanisms(void); | ||
2780 | +int ssh_gssapi_oid_table_ok(void); | ||
2781 | + | ||
2782 | +int ssh_gssapi_update_creds(ssh_gssapi_ccache *store); | ||
2783 | +void ssh_gssapi_rekey_creds(void); | ||
2784 | + | ||
2785 | #endif /* GSSAPI */ | ||
2786 | |||
2787 | #endif /* _SSH_GSS_H */ | ||
2788 | diff --git a/ssh_config b/ssh_config | ||
2789 | index c12f5ef5..bcb9f153 100644 | ||
2790 | --- a/ssh_config | ||
2791 | +++ b/ssh_config | ||
2792 | @@ -24,6 +24,8 @@ | ||
2793 | # HostbasedAuthentication no | ||
2794 | # GSSAPIAuthentication no | ||
2795 | # GSSAPIDelegateCredentials no | ||
2796 | +# GSSAPIKeyExchange no | ||
2797 | +# GSSAPITrustDNS no | ||
2798 | # BatchMode no | ||
2799 | # CheckHostIP yes | ||
2800 | # AddressFamily any | ||
2801 | diff --git a/ssh_config.5 b/ssh_config.5 | ||
2802 | index eab8dd01..9a06a757 100644 | ||
2803 | --- a/ssh_config.5 | ||
2804 | +++ b/ssh_config.5 | ||
2805 | @@ -720,10 +720,42 @@ The default is | ||
2806 | Specifies whether user authentication based on GSSAPI is allowed. | ||
2807 | The default is | ||
2808 | .Cm no . | ||
2809 | +.It Cm GSSAPIKeyExchange | ||
2810 | +Specifies whether key exchange based on GSSAPI may be used. When using | ||
2811 | +GSSAPI key exchange the server need not have a host key. | ||
2812 | +The default is | ||
2813 | +.Cm no . | ||
2814 | +.It Cm GSSAPIClientIdentity | ||
2815 | +If set, specifies the GSSAPI client identity that ssh should use when | ||
2816 | +connecting to the server. The default is unset, which means that the default | ||
2817 | +identity will be used. | ||
2818 | +.It Cm GSSAPIServerIdentity | ||
2819 | +If set, specifies the GSSAPI server identity that ssh should expect when | ||
2820 | +connecting to the server. The default is unset, which means that the | ||
2821 | +expected GSSAPI server identity will be determined from the target | ||
2822 | +hostname. | ||
2823 | .It Cm GSSAPIDelegateCredentials | ||
2824 | Forward (delegate) credentials to the server. | ||
2825 | The default is | ||
2826 | .Cm no . | ||
2827 | +.It Cm GSSAPIRenewalForcesRekey | ||
2828 | +If set to | ||
2829 | +.Cm yes | ||
2830 | +then renewal of the client's GSSAPI credentials will force the rekeying of the | ||
2831 | +ssh connection. With a compatible server, this can delegate the renewed | ||
2832 | +credentials to a session on the server. | ||
2833 | +The default is | ||
2834 | +.Cm no . | ||
2835 | +.It Cm GSSAPITrustDns | ||
2836 | +Set to | ||
2837 | +.Cm yes | ||
2838 | +to indicate that the DNS is trusted to securely canonicalize | ||
2839 | +the name of the host being connected to. If | ||
2840 | +.Cm no , | ||
2841 | +the hostname entered on the | ||
2842 | +command line will be passed untouched to the GSSAPI library. | ||
2843 | +The default is | ||
2844 | +.Cm no . | ||
2845 | .It Cm HashKnownHosts | ||
2846 | Indicates that | ||
2847 | .Xr ssh 1 | ||
2848 | diff --git a/sshconnect2.c b/sshconnect2.c | ||
2849 | index be9397e4..c22477f5 100644 | ||
2850 | --- a/sshconnect2.c | ||
2851 | +++ b/sshconnect2.c | ||
2852 | @@ -162,6 +162,11 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port) | ||
2853 | struct kex *kex; | ||
2854 | int r; | ||
2855 | |||
2856 | +#ifdef GSSAPI | ||
2857 | + char *orig = NULL, *gss = NULL; | ||
2858 | + char *gss_host = NULL; | ||
2859 | +#endif | ||
2860 | + | ||
2861 | xxx_host = host; | ||
2862 | xxx_hostaddr = hostaddr; | ||
2863 | |||
2864 | @@ -192,6 +197,35 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port) | ||
2865 | order_hostkeyalgs(host, hostaddr, port)); | ||
2866 | } | ||
2867 | |||
2868 | +#ifdef GSSAPI | ||
2869 | + if (options.gss_keyex) { | ||
2870 | + /* Add the GSSAPI mechanisms currently supported on this | ||
2871 | + * client to the key exchange algorithm proposal */ | ||
2872 | + orig = myproposal[PROPOSAL_KEX_ALGS]; | ||
2873 | + | ||
2874 | + if (options.gss_server_identity) | ||
2875 | + gss_host = xstrdup(options.gss_server_identity); | ||
2876 | + else if (options.gss_trust_dns) | ||
2877 | + gss_host = remote_hostname(active_state); | ||
2878 | + else | ||
2879 | + gss_host = xstrdup(host); | ||
2880 | + | ||
2881 | + gss = ssh_gssapi_client_mechanisms(gss_host, | ||
2882 | + options.gss_client_identity); | ||
2883 | + if (gss) { | ||
2884 | + debug("Offering GSSAPI proposal: %s", gss); | ||
2885 | + xasprintf(&myproposal[PROPOSAL_KEX_ALGS], | ||
2886 | + "%s,%s", gss, orig); | ||
2887 | + | ||
2888 | + /* If we've got GSSAPI algorithms, then we also | ||
2889 | + * support the 'null' hostkey, as a last resort */ | ||
2890 | + orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]; | ||
2891 | + xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS], | ||
2892 | + "%s,null", orig); | ||
2893 | + } | ||
2894 | + } | ||
2895 | +#endif | ||
2896 | + | ||
2897 | if (options.rekey_limit || options.rekey_interval) | ||
2898 | packet_set_rekey_limits(options.rekey_limit, | ||
2899 | options.rekey_interval); | ||
2900 | @@ -213,15 +247,41 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port) | ||
2901 | # endif | ||
2902 | #endif | ||
2903 | kex->kex[KEX_C25519_SHA256] = kexc25519_client; | ||
2904 | +#ifdef GSSAPI | ||
2905 | + if (options.gss_keyex) { | ||
2906 | + kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_client; | ||
2907 | + kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_client; | ||
2908 | + kex->kex[KEX_GSS_GEX_SHA1] = kexgss_client; | ||
2909 | + } | ||
2910 | +#endif | ||
2911 | kex->client_version_string=client_version_string; | ||
2912 | kex->server_version_string=server_version_string; | ||
2913 | kex->verify_host_key=&verify_host_key_callback; | ||
2914 | |||
2915 | +#ifdef GSSAPI | ||
2916 | + if (options.gss_keyex) { | ||
2917 | + kex->gss_deleg_creds = options.gss_deleg_creds; | ||
2918 | + kex->gss_trust_dns = options.gss_trust_dns; | ||
2919 | + kex->gss_client = options.gss_client_identity; | ||
2920 | + kex->gss_host = gss_host; | ||
2921 | + } | ||
2922 | +#endif | ||
2923 | + | ||
2924 | ssh_dispatch_run_fatal(active_state, DISPATCH_BLOCK, &kex->done); | ||
2925 | |||
2926 | /* remove ext-info from the KEX proposals for rekeying */ | ||
2927 | myproposal[PROPOSAL_KEX_ALGS] = | ||
2928 | compat_kex_proposal(options.kex_algorithms); | ||
2929 | +#ifdef GSSAPI | ||
2930 | + /* repair myproposal after it was crumpled by the */ | ||
2931 | + /* ext-info removal above */ | ||
2932 | + if (gss) { | ||
2933 | + orig = myproposal[PROPOSAL_KEX_ALGS]; | ||
2934 | + xasprintf(&myproposal[PROPOSAL_KEX_ALGS], | ||
2935 | + "%s,%s", gss, orig); | ||
2936 | + free(gss); | ||
2937 | + } | ||
2938 | +#endif | ||
2939 | if ((r = kex_prop2buf(kex->my, myproposal)) != 0) | ||
2940 | fatal("kex_prop2buf: %s", ssh_err(r)); | ||
2941 | |||
2942 | @@ -311,6 +371,7 @@ int input_gssapi_token(int type, u_int32_t, struct ssh *); | ||
2943 | int input_gssapi_hash(int type, u_int32_t, struct ssh *); | ||
2944 | int input_gssapi_error(int, u_int32_t, struct ssh *); | ||
2945 | int input_gssapi_errtok(int, u_int32_t, struct ssh *); | ||
2946 | +int userauth_gsskeyex(Authctxt *authctxt); | ||
2947 | #endif | ||
2948 | |||
2949 | void userauth(Authctxt *, char *); | ||
2950 | @@ -327,6 +388,11 @@ static char *authmethods_get(void); | ||
2951 | |||
2952 | Authmethod authmethods[] = { | ||
2953 | #ifdef GSSAPI | ||
2954 | + {"gssapi-keyex", | ||
2955 | + userauth_gsskeyex, | ||
2956 | + NULL, | ||
2957 | + &options.gss_authentication, | ||
2958 | + NULL}, | ||
2959 | {"gssapi-with-mic", | ||
2960 | userauth_gssapi, | ||
2961 | NULL, | ||
2962 | @@ -654,25 +720,40 @@ userauth_gssapi(Authctxt *authctxt) | ||
2963 | static u_int mech = 0; | ||
2964 | OM_uint32 min; | ||
2965 | int ok = 0; | ||
2966 | + char *gss_host; | ||
2967 | + | ||
2968 | + if (options.gss_server_identity) | ||
2969 | + gss_host = xstrdup(options.gss_server_identity); | ||
2970 | + else if (options.gss_trust_dns) | ||
2971 | + gss_host = remote_hostname(active_state); | ||
2972 | + else | ||
2973 | + gss_host = xstrdup(authctxt->host); | ||
2974 | |||
2975 | /* Try one GSSAPI method at a time, rather than sending them all at | ||
2976 | * once. */ | ||
2977 | |||
2978 | if (gss_supported == NULL) | ||
2979 | - gss_indicate_mechs(&min, &gss_supported); | ||
2980 | + if (GSS_ERROR(gss_indicate_mechs(&min, &gss_supported))) { | ||
2981 | + gss_supported = NULL; | ||
2982 | + free(gss_host); | ||
2983 | + return 0; | ||
2984 | + } | ||
2985 | |||
2986 | /* Check to see if the mechanism is usable before we offer it */ | ||
2987 | while (mech < gss_supported->count && !ok) { | ||
2988 | /* My DER encoding requires length<128 */ | ||
2989 | if (gss_supported->elements[mech].length < 128 && | ||
2990 | ssh_gssapi_check_mechanism(&gssctxt, | ||
2991 | - &gss_supported->elements[mech], authctxt->host)) { | ||
2992 | + &gss_supported->elements[mech], gss_host, | ||
2993 | + options.gss_client_identity)) { | ||
2994 | ok = 1; /* Mechanism works */ | ||
2995 | } else { | ||
2996 | mech++; | ||
2997 | } | ||
2998 | } | ||
2999 | |||
3000 | + free(gss_host); | ||
3001 | + | ||
3002 | if (!ok) | ||
3003 | return 0; | ||
3004 | |||
3005 | @@ -763,8 +844,8 @@ input_gssapi_response(int type, u_int32_t plen, struct ssh *ssh) | ||
3006 | { | ||
3007 | Authctxt *authctxt = ssh->authctxt; | ||
3008 | Gssctxt *gssctxt; | ||
3009 | - int oidlen; | ||
3010 | - char *oidv; | ||
3011 | + u_int oidlen; | ||
3012 | + u_char *oidv; | ||
3013 | |||
3014 | if (authctxt == NULL) | ||
3015 | fatal("input_gssapi_response: no authentication context"); | ||
3016 | @@ -877,6 +958,48 @@ input_gssapi_error(int type, u_int32_t plen, struct ssh *ssh) | ||
3017 | free(lang); | ||
3018 | return 0; | ||
3019 | } | ||
3020 | + | ||
3021 | +int | ||
3022 | +userauth_gsskeyex(Authctxt *authctxt) | ||
3023 | +{ | ||
3024 | + Buffer b; | ||
3025 | + gss_buffer_desc gssbuf; | ||
3026 | + gss_buffer_desc mic = GSS_C_EMPTY_BUFFER; | ||
3027 | + OM_uint32 ms; | ||
3028 | + | ||
3029 | + static int attempt = 0; | ||
3030 | + if (attempt++ >= 1) | ||
3031 | + return (0); | ||
3032 | + | ||
3033 | + if (gss_kex_context == NULL) { | ||
3034 | + debug("No valid Key exchange context"); | ||
3035 | + return (0); | ||
3036 | + } | ||
3037 | + | ||
3038 | + ssh_gssapi_buildmic(&b, authctxt->server_user, authctxt->service, | ||
3039 | + "gssapi-keyex"); | ||
3040 | + | ||
3041 | + gssbuf.value = buffer_ptr(&b); | ||
3042 | + gssbuf.length = buffer_len(&b); | ||
3043 | + | ||
3044 | + if (GSS_ERROR(ssh_gssapi_sign(gss_kex_context, &gssbuf, &mic))) { | ||
3045 | + buffer_free(&b); | ||
3046 | + return (0); | ||
3047 | + } | ||
3048 | + | ||
3049 | + packet_start(SSH2_MSG_USERAUTH_REQUEST); | ||
3050 | + packet_put_cstring(authctxt->server_user); | ||
3051 | + packet_put_cstring(authctxt->service); | ||
3052 | + packet_put_cstring(authctxt->method->name); | ||
3053 | + packet_put_string(mic.value, mic.length); | ||
3054 | + packet_send(); | ||
3055 | + | ||
3056 | + buffer_free(&b); | ||
3057 | + gss_release_buffer(&ms, &mic); | ||
3058 | + | ||
3059 | + return (1); | ||
3060 | +} | ||
3061 | + | ||
3062 | #endif /* GSSAPI */ | ||
3063 | |||
3064 | int | ||
3065 | diff --git a/sshd.c b/sshd.c | ||
3066 | index 51a1aaf6..45e50fac 100644 | ||
3067 | --- a/sshd.c | ||
3068 | +++ b/sshd.c | ||
3069 | @@ -122,6 +122,10 @@ | ||
3070 | #include "version.h" | ||
3071 | #include "ssherr.h" | ||
3072 | |||
3073 | +#ifdef USE_SECURITY_SESSION_API | ||
3074 | +#include <Security/AuthSession.h> | ||
3075 | +#endif | ||
3076 | + | ||
3077 | /* Re-exec fds */ | ||
3078 | #define REEXEC_DEVCRYPTO_RESERVED_FD (STDERR_FILENO + 1) | ||
3079 | #define REEXEC_STARTUP_PIPE_FD (STDERR_FILENO + 2) | ||
3080 | @@ -529,7 +533,7 @@ privsep_preauth_child(void) | ||
3081 | |||
3082 | #ifdef GSSAPI | ||
3083 | /* Cache supported mechanism OIDs for later use */ | ||
3084 | - if (options.gss_authentication) | ||
3085 | + if (options.gss_authentication || options.gss_keyex) | ||
3086 | ssh_gssapi_prepare_supported_oids(); | ||
3087 | #endif | ||
3088 | |||
3089 | @@ -1708,10 +1712,13 @@ main(int ac, char **av) | ||
3090 | key ? "private" : "agent", i, sshkey_ssh_name(pubkey), fp); | ||
3091 | free(fp); | ||
3092 | } | ||
3093 | +#ifndef GSSAPI | ||
3094 | + /* The GSSAPI key exchange can run without a host key */ | ||
3095 | if (!sensitive_data.have_ssh2_key) { | ||
3096 | logit("sshd: no hostkeys available -- exiting."); | ||
3097 | exit(1); | ||
3098 | } | ||
3099 | +#endif | ||
3100 | |||
3101 | /* | ||
3102 | * Load certificates. They are stored in an array at identical | ||
3103 | @@ -1987,6 +1994,60 @@ main(int ac, char **av) | ||
3104 | remote_ip, remote_port, laddr, ssh_local_port(ssh)); | ||
3105 | free(laddr); | ||
3106 | |||
3107 | +#ifdef USE_SECURITY_SESSION_API | ||
3108 | + /* | ||
3109 | + * Create a new security session for use by the new user login if | ||
3110 | + * the current session is the root session or we are not launched | ||
3111 | + * by inetd (eg: debugging mode or server mode). We do not | ||
3112 | + * necessarily need to create a session if we are launched from | ||
3113 | + * inetd because Panther xinetd will create a session for us. | ||
3114 | + * | ||
3115 | + * The only case where this logic will fail is if there is an | ||
3116 | + * inetd running in a non-root session which is not creating | ||
3117 | + * new sessions for us. Then all the users will end up in the | ||
3118 | + * same session (bad). | ||
3119 | + * | ||
3120 | + * When the client exits, the session will be destroyed for us | ||
3121 | + * automatically. | ||
3122 | + * | ||
3123 | + * We must create the session before any credentials are stored | ||
3124 | + * (including AFS pags, which happens a few lines below). | ||
3125 | + */ | ||
3126 | + { | ||
3127 | + OSStatus err = 0; | ||
3128 | + SecuritySessionId sid = 0; | ||
3129 | + SessionAttributeBits sattrs = 0; | ||
3130 | + | ||
3131 | + err = SessionGetInfo(callerSecuritySession, &sid, &sattrs); | ||
3132 | + if (err) | ||
3133 | + error("SessionGetInfo() failed with error %.8X", | ||
3134 | + (unsigned) err); | ||
3135 | + else | ||
3136 | + debug("Current Session ID is %.8X / Session Attributes are %.8X", | ||
3137 | + (unsigned) sid, (unsigned) sattrs); | ||
3138 | + | ||
3139 | + if (inetd_flag && !(sattrs & sessionIsRoot)) | ||
3140 | + debug("Running in inetd mode in a non-root session... " | ||
3141 | + "assuming inetd created the session for us."); | ||
3142 | + else { | ||
3143 | + debug("Creating new security session..."); | ||
3144 | + err = SessionCreate(0, sessionHasTTY | sessionIsRemote); | ||
3145 | + if (err) | ||
3146 | + error("SessionCreate() failed with error %.8X", | ||
3147 | + (unsigned) err); | ||
3148 | + | ||
3149 | + err = SessionGetInfo(callerSecuritySession, &sid, | ||
3150 | + &sattrs); | ||
3151 | + if (err) | ||
3152 | + error("SessionGetInfo() failed with error %.8X", | ||
3153 | + (unsigned) err); | ||
3154 | + else | ||
3155 | + debug("New Session ID is %.8X / Session Attributes are %.8X", | ||
3156 | + (unsigned) sid, (unsigned) sattrs); | ||
3157 | + } | ||
3158 | + } | ||
3159 | +#endif | ||
3160 | + | ||
3161 | /* | ||
3162 | * We don't want to listen forever unless the other side | ||
3163 | * successfully authenticates itself. So we set up an alarm which is | ||
3164 | @@ -2170,6 +2231,48 @@ do_ssh2_kex(void) | ||
3165 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal( | ||
3166 | list_hostkey_types()); | ||
3167 | |||
3168 | +#ifdef GSSAPI | ||
3169 | + { | ||
3170 | + char *orig; | ||
3171 | + char *gss = NULL; | ||
3172 | + char *newstr = NULL; | ||
3173 | + orig = myproposal[PROPOSAL_KEX_ALGS]; | ||
3174 | + | ||
3175 | + /* | ||
3176 | + * If we don't have a host key, then there's no point advertising | ||
3177 | + * the other key exchange algorithms | ||
3178 | + */ | ||
3179 | + | ||
3180 | + if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0) | ||
3181 | + orig = NULL; | ||
3182 | + | ||
3183 | + if (options.gss_keyex) | ||
3184 | + gss = ssh_gssapi_server_mechanisms(); | ||
3185 | + else | ||
3186 | + gss = NULL; | ||
3187 | + | ||
3188 | + if (gss && orig) | ||
3189 | + xasprintf(&newstr, "%s,%s", gss, orig); | ||
3190 | + else if (gss) | ||
3191 | + newstr = gss; | ||
3192 | + else if (orig) | ||
3193 | + newstr = orig; | ||
3194 | + | ||
3195 | + /* | ||
3196 | + * If we've got GSSAPI mechanisms, then we've got the 'null' host | ||
3197 | + * key alg, but we can't tell people about it unless its the only | ||
3198 | + * host key algorithm we support | ||
3199 | + */ | ||
3200 | + if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0) | ||
3201 | + myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null"; | ||
3202 | + | ||
3203 | + if (newstr) | ||
3204 | + myproposal[PROPOSAL_KEX_ALGS] = newstr; | ||
3205 | + else | ||
3206 | + fatal("No supported key exchange algorithms"); | ||
3207 | + } | ||
3208 | +#endif | ||
3209 | + | ||
3210 | /* start key exchange */ | ||
3211 | if ((r = kex_setup(active_state, myproposal)) != 0) | ||
3212 | fatal("kex_setup: %s", ssh_err(r)); | ||
3213 | @@ -2187,6 +2290,13 @@ do_ssh2_kex(void) | ||
3214 | # endif | ||
3215 | #endif | ||
3216 | kex->kex[KEX_C25519_SHA256] = kexc25519_server; | ||
3217 | +#ifdef GSSAPI | ||
3218 | + if (options.gss_keyex) { | ||
3219 | + kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; | ||
3220 | + kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server; | ||
3221 | + kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server; | ||
3222 | + } | ||
3223 | +#endif | ||
3224 | kex->server = 1; | ||
3225 | kex->client_version_string=client_version_string; | ||
3226 | kex->server_version_string=server_version_string; | ||
3227 | diff --git a/sshd_config b/sshd_config | ||
3228 | index 4eb2e02e..c01dd656 100644 | ||
3229 | --- a/sshd_config | ||
3230 | +++ b/sshd_config | ||
3231 | @@ -70,6 +70,8 @@ AuthorizedKeysFile .ssh/authorized_keys | ||
3232 | # GSSAPI options | ||
3233 | #GSSAPIAuthentication no | ||
3234 | #GSSAPICleanupCredentials yes | ||
3235 | +#GSSAPIStrictAcceptorCheck yes | ||
3236 | +#GSSAPIKeyExchange no | ||
3237 | |||
3238 | # Set this to 'yes' to enable PAM authentication, account processing, | ||
3239 | # and session processing. If this is enabled, PAM authentication will | ||
3240 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
3241 | index 251b7467..0dbcb8da 100644 | ||
3242 | --- a/sshd_config.5 | ||
3243 | +++ b/sshd_config.5 | ||
3244 | @@ -635,6 +635,11 @@ The default is | ||
3245 | Specifies whether user authentication based on GSSAPI is allowed. | ||
3246 | The default is | ||
3247 | .Cm no . | ||
3248 | +.It Cm GSSAPIKeyExchange | ||
3249 | +Specifies whether key exchange based on GSSAPI is allowed. GSSAPI key exchange | ||
3250 | +doesn't rely on ssh keys to verify host identity. | ||
3251 | +The default is | ||
3252 | +.Cm no . | ||
3253 | .It Cm GSSAPICleanupCredentials | ||
3254 | Specifies whether to automatically destroy the user's credentials cache | ||
3255 | on logout. | ||
3256 | @@ -654,6 +659,11 @@ machine's default store. | ||
3257 | This facility is provided to assist with operation on multi homed machines. | ||
3258 | The default is | ||
3259 | .Cm yes . | ||
3260 | +.It Cm GSSAPIStoreCredentialsOnRekey | ||
3261 | +Controls whether the user's GSSAPI credentials should be updated following a | ||
3262 | +successful connection rekeying. This option can be used to accepted renewed | ||
3263 | +or updated credentials from a compatible client. The default is | ||
3264 | +.Cm no . | ||
3265 | .It Cm HostbasedAcceptedKeyTypes | ||
3266 | Specifies the key types that will be accepted for hostbased authentication | ||
3267 | as a comma-separated pattern list. | ||
3268 | diff --git a/sshkey.c b/sshkey.c | ||
3269 | index e91c54f5..c2cf0e03 100644 | ||
3270 | --- a/sshkey.c | ||
3271 | +++ b/sshkey.c | ||
3272 | @@ -112,6 +112,7 @@ static const struct keytype keytypes[] = { | ||
3273 | # endif /* OPENSSL_HAS_NISTP521 */ | ||
3274 | # endif /* OPENSSL_HAS_ECC */ | ||
3275 | #endif /* WITH_OPENSSL */ | ||
3276 | + { "null", "null", KEY_NULL, 0, 0, 0 }, | ||
3277 | { NULL, NULL, -1, -1, 0, 0 } | ||
3278 | }; | ||
3279 | |||
3280 | @@ -200,7 +201,7 @@ sshkey_alg_list(int certs_only, int plain_only, int include_sigonly, char sep) | ||
3281 | const struct keytype *kt; | ||
3282 | |||
3283 | for (kt = keytypes; kt->type != -1; kt++) { | ||
3284 | - if (kt->name == NULL) | ||
3285 | + if (kt->name == NULL || kt->type == KEY_NULL) | ||
3286 | continue; | ||
3287 | if (!include_sigonly && kt->sigonly) | ||
3288 | continue; | ||
3289 | diff --git a/sshkey.h b/sshkey.h | ||
3290 | index 9093eac5..b5d020cb 100644 | ||
3291 | --- a/sshkey.h | ||
3292 | +++ b/sshkey.h | ||
3293 | @@ -61,6 +61,7 @@ enum sshkey_types { | ||
3294 | KEY_DSA_CERT, | ||
3295 | KEY_ECDSA_CERT, | ||
3296 | KEY_ED25519_CERT, | ||
3297 | + KEY_NULL, | ||
3298 | KEY_UNSPEC | ||
3299 | }; | ||
3300 | |||
diff --git a/debian/patches/keepalive-extensions.patch b/debian/patches/keepalive-extensions.patch new file mode 100644 index 000000000..d3eca5924 --- /dev/null +++ b/debian/patches/keepalive-extensions.patch | |||
@@ -0,0 +1,134 @@ | |||
1 | From c147d4dbab74e0dbf738beb9d9f4220534ae9da6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Richard Kettlewell <rjk@greenend.org.uk> | ||
3 | Date: Sun, 9 Feb 2014 16:09:52 +0000 | ||
4 | Subject: Various keepalive extensions | ||
5 | |||
6 | Add compatibility aliases for ProtocolKeepAlives and SetupTimeOut, supported | ||
7 | in previous versions of Debian's OpenSSH package but since superseded by | ||
8 | ServerAliveInterval. (We're probably stuck with this bit for | ||
9 | compatibility.) | ||
10 | |||
11 | In batch mode, default ServerAliveInterval to five minutes. | ||
12 | |||
13 | Adjust documentation to match and to give some more advice on use of | ||
14 | keepalives. | ||
15 | |||
16 | Author: Ian Jackson <ian@chiark.greenend.org.uk> | ||
17 | Author: Matthew Vernon <matthew@debian.org> | ||
18 | Author: Colin Watson <cjwatson@debian.org> | ||
19 | Last-Update: 2017-10-04 | ||
20 | |||
21 | Patch-Name: keepalive-extensions.patch | ||
22 | --- | ||
23 | readconf.c | 14 ++++++++++++-- | ||
24 | ssh_config.5 | 21 +++++++++++++++++++-- | ||
25 | sshd_config.5 | 3 +++ | ||
26 | 3 files changed, 34 insertions(+), 4 deletions(-) | ||
27 | |||
28 | diff --git a/readconf.c b/readconf.c | ||
29 | index d2b28a41..45caa095 100644 | ||
30 | --- a/readconf.c | ||
31 | +++ b/readconf.c | ||
32 | @@ -174,6 +174,7 @@ typedef enum { | ||
33 | oStreamLocalBindMask, oStreamLocalBindUnlink, oRevokedHostKeys, | ||
34 | oFingerprintHash, oUpdateHostkeys, oHostbasedKeyTypes, | ||
35 | oPubkeyAcceptedKeyTypes, oProxyJump, | ||
36 | + oProtocolKeepAlives, oSetupTimeOut, | ||
37 | oIgnore, oIgnoredUnknownOption, oDeprecated, oUnsupported | ||
38 | } OpCodes; | ||
39 | |||
40 | @@ -318,6 +319,8 @@ static struct { | ||
41 | { "pubkeyacceptedkeytypes", oPubkeyAcceptedKeyTypes }, | ||
42 | { "ignoreunknown", oIgnoreUnknown }, | ||
43 | { "proxyjump", oProxyJump }, | ||
44 | + { "protocolkeepalives", oProtocolKeepAlives }, | ||
45 | + { "setuptimeout", oSetupTimeOut }, | ||
46 | |||
47 | { NULL, oBadOption } | ||
48 | }; | ||
49 | @@ -1406,6 +1409,8 @@ parse_keytypes: | ||
50 | goto parse_flag; | ||
51 | |||
52 | case oServerAliveInterval: | ||
53 | + case oProtocolKeepAlives: /* Debian-specific compatibility alias */ | ||
54 | + case oSetupTimeOut: /* Debian-specific compatibility alias */ | ||
55 | intptr = &options->server_alive_interval; | ||
56 | goto parse_time; | ||
57 | |||
58 | @@ -2042,8 +2047,13 @@ fill_default_options(Options * options) | ||
59 | options->rekey_interval = 0; | ||
60 | if (options->verify_host_key_dns == -1) | ||
61 | options->verify_host_key_dns = 0; | ||
62 | - if (options->server_alive_interval == -1) | ||
63 | - options->server_alive_interval = 0; | ||
64 | + if (options->server_alive_interval == -1) { | ||
65 | + /* in batch mode, default is 5mins */ | ||
66 | + if (options->batch_mode == 1) | ||
67 | + options->server_alive_interval = 300; | ||
68 | + else | ||
69 | + options->server_alive_interval = 0; | ||
70 | + } | ||
71 | if (options->server_alive_count_max == -1) | ||
72 | options->server_alive_count_max = 3; | ||
73 | if (options->control_master == -1) | ||
74 | diff --git a/ssh_config.5 b/ssh_config.5 | ||
75 | index 9a06a757..d6f43c2d 100644 | ||
76 | --- a/ssh_config.5 | ||
77 | +++ b/ssh_config.5 | ||
78 | @@ -247,8 +247,12 @@ Valid arguments are | ||
79 | If set to | ||
80 | .Cm yes , | ||
81 | passphrase/password querying will be disabled. | ||
82 | +In addition, the | ||
83 | +.Cm ServerAliveInterval | ||
84 | +option will be set to 300 seconds by default (Debian-specific). | ||
85 | This option is useful in scripts and other batch jobs where no user | ||
86 | -is present to supply the password. | ||
87 | +is present to supply the password, | ||
88 | +and where it is desirable to detect a broken network swiftly. | ||
89 | The argument must be | ||
90 | .Cm yes | ||
91 | or | ||
92 | @@ -1455,7 +1459,14 @@ from the server, | ||
93 | will send a message through the encrypted | ||
94 | channel to request a response from the server. | ||
95 | The default | ||
96 | -is 0, indicating that these messages will not be sent to the server. | ||
97 | +is 0, indicating that these messages will not be sent to the server, | ||
98 | +or 300 if the | ||
99 | +.Cm BatchMode | ||
100 | +option is set (Debian-specific). | ||
101 | +.Cm ProtocolKeepAlives | ||
102 | +and | ||
103 | +.Cm SetupTimeOut | ||
104 | +are Debian-specific compatibility aliases for this option. | ||
105 | .It Cm StreamLocalBindMask | ||
106 | Sets the octal file creation mode mask | ||
107 | .Pq umask | ||
108 | @@ -1529,6 +1540,12 @@ Specifies whether the system should send TCP keepalive messages to the | ||
109 | other side. | ||
110 | If they are sent, death of the connection or crash of one | ||
111 | of the machines will be properly noticed. | ||
112 | +This option only uses TCP keepalives (as opposed to using ssh level | ||
113 | +keepalives), so takes a long time to notice when the connection dies. | ||
114 | +As such, you probably want | ||
115 | +the | ||
116 | +.Cm ServerAliveInterval | ||
117 | +option as well. | ||
118 | However, this means that | ||
119 | connections will die if the route is down temporarily, and some people | ||
120 | find it annoying. | ||
121 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
122 | index 0dbcb8da..7db25552 100644 | ||
123 | --- a/sshd_config.5 | ||
124 | +++ b/sshd_config.5 | ||
125 | @@ -1454,6 +1454,9 @@ This avoids infinitely hanging sessions. | ||
126 | .Pp | ||
127 | To disable TCP keepalive messages, the value should be set to | ||
128 | .Cm no . | ||
129 | +.Pp | ||
130 | +This option was formerly called | ||
131 | +.Cm KeepAlive . | ||
132 | .It Cm TrustedUserCAKeys | ||
133 | Specifies a file containing public keys of certificate authorities that are | ||
134 | trusted to sign user certificates for authentication, or | ||
diff --git a/debian/patches/mention-ssh-keygen-on-keychange.patch b/debian/patches/mention-ssh-keygen-on-keychange.patch new file mode 100644 index 000000000..3edb37705 --- /dev/null +++ b/debian/patches/mention-ssh-keygen-on-keychange.patch | |||
@@ -0,0 +1,44 @@ | |||
1 | From 19be4218cdb262f7b584b0104ee430de0e24eeb8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Scott Moser <smoser@ubuntu.com> | ||
3 | Date: Sun, 9 Feb 2014 16:10:03 +0000 | ||
4 | Subject: Mention ssh-keygen in ssh fingerprint changed warning | ||
5 | |||
6 | Author: Chris Lamb <lamby@debian.org> | ||
7 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1843 | ||
8 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/686607 | ||
9 | Last-Update: 2017-08-22 | ||
10 | |||
11 | Patch-Name: mention-ssh-keygen-on-keychange.patch | ||
12 | --- | ||
13 | sshconnect.c | 9 ++++++++- | ||
14 | 1 file changed, 8 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/sshconnect.c b/sshconnect.c | ||
17 | index 5eed5880..7ce2716c 100644 | ||
18 | --- a/sshconnect.c | ||
19 | +++ b/sshconnect.c | ||
20 | @@ -1022,9 +1022,13 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port, | ||
21 | error("%s. This could either mean that", key_msg); | ||
22 | error("DNS SPOOFING is happening or the IP address for the host"); | ||
23 | error("and its host key have changed at the same time."); | ||
24 | - if (ip_status != HOST_NEW) | ||
25 | + if (ip_status != HOST_NEW) { | ||
26 | error("Offending key for IP in %s:%lu", | ||
27 | ip_found->file, ip_found->line); | ||
28 | + error(" remove with:"); | ||
29 | + error(" ssh-keygen -f \"%s\" -R \"%s\"", | ||
30 | + ip_found->file, ip); | ||
31 | + } | ||
32 | } | ||
33 | /* The host key has changed. */ | ||
34 | warn_changed_key(host_key); | ||
35 | @@ -1033,6 +1037,9 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port, | ||
36 | error("Offending %s key in %s:%lu", | ||
37 | sshkey_type(host_found->key), | ||
38 | host_found->file, host_found->line); | ||
39 | + error(" remove with:"); | ||
40 | + error(" ssh-keygen -f \"%s\" -R \"%s\"", | ||
41 | + host_found->file, host); | ||
42 | |||
43 | /* | ||
44 | * If strict host key checking is in use, the user will have | ||
diff --git a/debian/patches/no-dsa-host-key-by-default.patch b/debian/patches/no-dsa-host-key-by-default.patch new file mode 100644 index 000000000..c24ff4e3f --- /dev/null +++ b/debian/patches/no-dsa-host-key-by-default.patch | |||
@@ -0,0 +1,83 @@ | |||
1 | From 922f3a7599d03234b6bb2ffb22a33624e7cf1953 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Mon, 16 Jan 2017 13:53:04 +0000 | ||
4 | Subject: Remove ssh_host_dsa_key from HostKey default | ||
5 | |||
6 | The client no longer accepts DSA host keys, and servers using the | ||
7 | default HostKey setting should have better host keys available. | ||
8 | |||
9 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=2662 | ||
10 | Bug-Debian: https://bugs.debian.org/850614 | ||
11 | Last-Update: 2017-01-16 | ||
12 | |||
13 | Patch-Name: no-dsa-host-key-by-default.patch | ||
14 | --- | ||
15 | servconf.c | 2 -- | ||
16 | sshd.8 | 7 +++---- | ||
17 | sshd_config | 1 - | ||
18 | sshd_config.5 | 7 +++---- | ||
19 | 4 files changed, 6 insertions(+), 11 deletions(-) | ||
20 | |||
21 | diff --git a/servconf.c b/servconf.c | ||
22 | index b0146405..5e996cf8 100644 | ||
23 | --- a/servconf.c | ||
24 | +++ b/servconf.c | ||
25 | @@ -205,8 +205,6 @@ fill_default_server_options(ServerOptions *options) | ||
26 | /* fill default hostkeys for protocols */ | ||
27 | options->host_key_files[options->num_host_key_files++] = | ||
28 | _PATH_HOST_RSA_KEY_FILE; | ||
29 | - options->host_key_files[options->num_host_key_files++] = | ||
30 | - _PATH_HOST_DSA_KEY_FILE; | ||
31 | #ifdef OPENSSL_HAS_ECC | ||
32 | options->host_key_files[options->num_host_key_files++] = | ||
33 | _PATH_HOST_ECDSA_KEY_FILE; | ||
34 | diff --git a/sshd.8 b/sshd.8 | ||
35 | index 02c5e1df..8c230657 100644 | ||
36 | --- a/sshd.8 | ||
37 | +++ b/sshd.8 | ||
38 | @@ -164,11 +164,10 @@ This option must be given if | ||
39 | is not run as root (as the normal | ||
40 | host key files are normally not readable by anyone but root). | ||
41 | The default is | ||
42 | -.Pa /etc/ssh/ssh_host_dsa_key , | ||
43 | -.Pa /etc/ssh/ssh_host_ecdsa_key , | ||
44 | -.Pa /etc/ssh/ssh_host_ed25519_key | ||
45 | +.Pa /etc/ssh/ssh_host_rsa_key , | ||
46 | +.Pa /etc/ssh/ssh_host_ecdsa_key | ||
47 | and | ||
48 | -.Pa /etc/ssh/ssh_host_rsa_key . | ||
49 | +.Pa /etc/ssh/ssh_host_ed25519_key . | ||
50 | It is possible to have multiple host key files for | ||
51 | the different host key algorithms. | ||
52 | .It Fl i | ||
53 | diff --git a/sshd_config b/sshd_config | ||
54 | index f68edf36..92822959 100644 | ||
55 | --- a/sshd_config | ||
56 | +++ b/sshd_config | ||
57 | @@ -16,7 +16,6 @@ | ||
58 | #ListenAddress :: | ||
59 | |||
60 | #HostKey /etc/ssh/ssh_host_rsa_key | ||
61 | -#HostKey /etc/ssh/ssh_host_dsa_key | ||
62 | #HostKey /etc/ssh/ssh_host_ecdsa_key | ||
63 | #HostKey /etc/ssh/ssh_host_ed25519_key | ||
64 | |||
65 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
66 | index 16be4f62..ef520680 100644 | ||
67 | --- a/sshd_config.5 | ||
68 | +++ b/sshd_config.5 | ||
69 | @@ -749,11 +749,10 @@ is not to load any certificates. | ||
70 | Specifies a file containing a private host key | ||
71 | used by SSH. | ||
72 | The defaults are | ||
73 | -.Pa /etc/ssh/ssh_host_dsa_key , | ||
74 | -.Pa /etc/ssh/ssh_host_ecdsa_key , | ||
75 | -.Pa /etc/ssh/ssh_host_ed25519_key | ||
76 | +.Pa /etc/ssh/ssh_host_rsa_key , | ||
77 | +.Pa /etc/ssh/ssh_host_ecdsa_key | ||
78 | and | ||
79 | -.Pa /etc/ssh/ssh_host_rsa_key . | ||
80 | +.Pa /etc/ssh/ssh_host_ed25519_key . | ||
81 | .Pp | ||
82 | Note that | ||
83 | .Xr sshd 8 | ||
diff --git a/debian/patches/no-openssl-version-status.patch b/debian/patches/no-openssl-version-status.patch new file mode 100644 index 000000000..cbfaebfe0 --- /dev/null +++ b/debian/patches/no-openssl-version-status.patch | |||
@@ -0,0 +1,62 @@ | |||
1 | From b614a7f9148af821919165be47c6c29f59dc6b44 Mon Sep 17 00:00:00 2001 | ||
2 | From: Kurt Roeckx <kurt@roeckx.be> | ||
3 | Date: Sun, 9 Feb 2014 16:10:14 +0000 | ||
4 | Subject: Don't check the status field of the OpenSSL version | ||
5 | |||
6 | There is no reason to check the version of OpenSSL (in Debian). If it's | ||
7 | not compatible the soname will change. OpenSSH seems to want to do a | ||
8 | check for the soname based on the version number, but wants to keep the | ||
9 | status of the release the same. Remove that check on the status since | ||
10 | it doesn't tell you anything about how compatible that version is. | ||
11 | |||
12 | Author: Colin Watson <cjwatson@debian.org> | ||
13 | Bug-Debian: https://bugs.debian.org/93581 | ||
14 | Bug-Debian: https://bugs.debian.org/664383 | ||
15 | Bug-Debian: https://bugs.debian.org/732940 | ||
16 | Forwarded: not-needed | ||
17 | Last-Update: 2014-10-07 | ||
18 | |||
19 | Patch-Name: no-openssl-version-status.patch | ||
20 | --- | ||
21 | openbsd-compat/openssl-compat.c | 6 +++--- | ||
22 | openbsd-compat/regress/opensslvertest.c | 1 + | ||
23 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
24 | |||
25 | diff --git a/openbsd-compat/openssl-compat.c b/openbsd-compat/openssl-compat.c | ||
26 | index 259fccbe..aaa953f2 100644 | ||
27 | --- a/openbsd-compat/openssl-compat.c | ||
28 | +++ b/openbsd-compat/openssl-compat.c | ||
29 | @@ -34,7 +34,7 @@ | ||
30 | /* | ||
31 | * OpenSSL version numbers: MNNFFPPS: major minor fix patch status | ||
32 | * We match major, minor, fix and status (not patch) for <1.0.0. | ||
33 | - * After that, we acceptable compatible fix versions (so we | ||
34 | + * After that, we accept compatible fix and status versions (so we | ||
35 | * allow 1.0.1 to work with 1.0.0). Going backwards is only allowed | ||
36 | * within a patch series. | ||
37 | */ | ||
38 | @@ -55,10 +55,10 @@ ssh_compatible_openssl(long headerver, long libver) | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | - * For versions >= 1.0.0, major,minor,status must match and library | ||
43 | + * For versions >= 1.0.0, major,minor must match and library | ||
44 | * fix version must be equal to or newer than the header. | ||
45 | */ | ||
46 | - mask = 0xfff0000fL; /* major,minor,status */ | ||
47 | + mask = 0xfff00000L; /* major,minor */ | ||
48 | hfix = (headerver & 0x000ff000) >> 12; | ||
49 | lfix = (libver & 0x000ff000) >> 12; | ||
50 | if ( (headerver & mask) == (libver & mask) && lfix >= hfix) | ||
51 | diff --git a/openbsd-compat/regress/opensslvertest.c b/openbsd-compat/regress/opensslvertest.c | ||
52 | index 5d019b59..58474873 100644 | ||
53 | --- a/openbsd-compat/regress/opensslvertest.c | ||
54 | +++ b/openbsd-compat/regress/opensslvertest.c | ||
55 | @@ -35,6 +35,7 @@ struct version_test { | ||
56 | |||
57 | /* built with 1.0.1b release headers */ | ||
58 | { 0x1000101fL, 0x1000101fL, 1},/* exact match */ | ||
59 | + { 0x1000101fL, 0x10001010L, 1}, /* different status: ok */ | ||
60 | { 0x1000101fL, 0x1000102fL, 1}, /* newer library patch version: ok */ | ||
61 | { 0x1000101fL, 0x1000100fL, 1}, /* older library patch version: ok */ | ||
62 | { 0x1000101fL, 0x1000201fL, 1}, /* newer library fix version: ok */ | ||
diff --git a/debian/patches/openbsd-docs.patch b/debian/patches/openbsd-docs.patch new file mode 100644 index 000000000..9297decd6 --- /dev/null +++ b/debian/patches/openbsd-docs.patch | |||
@@ -0,0 +1,148 @@ | |||
1 | From 7e53354725eeb002e6126a73fd5f294ed9f9b03e Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:09 +0000 | ||
4 | Subject: Adjust various OpenBSD-specific references in manual pages | ||
5 | |||
6 | No single bug reference for this patch, but history includes: | ||
7 | http://bugs.debian.org/154434 (login.conf(5)) | ||
8 | http://bugs.debian.org/513417 (/etc/rc) | ||
9 | http://bugs.debian.org/530692 (ssl(8)) | ||
10 | https://bugs.launchpad.net/bugs/456660 (ssl(8)) | ||
11 | |||
12 | Forwarded: not-needed | ||
13 | Last-Update: 2017-10-04 | ||
14 | |||
15 | Patch-Name: openbsd-docs.patch | ||
16 | --- | ||
17 | moduli.5 | 4 ++-- | ||
18 | ssh-keygen.1 | 12 ++++-------- | ||
19 | ssh.1 | 4 ++++ | ||
20 | sshd.8 | 5 ++--- | ||
21 | sshd_config.5 | 3 +-- | ||
22 | 5 files changed, 13 insertions(+), 15 deletions(-) | ||
23 | |||
24 | diff --git a/moduli.5 b/moduli.5 | ||
25 | index ef0de085..149846c8 100644 | ||
26 | --- a/moduli.5 | ||
27 | +++ b/moduli.5 | ||
28 | @@ -21,7 +21,7 @@ | ||
29 | .Nd Diffie-Hellman moduli | ||
30 | .Sh DESCRIPTION | ||
31 | The | ||
32 | -.Pa /etc/moduli | ||
33 | +.Pa /etc/ssh/moduli | ||
34 | file contains prime numbers and generators for use by | ||
35 | .Xr sshd 8 | ||
36 | in the Diffie-Hellman Group Exchange key exchange method. | ||
37 | @@ -110,7 +110,7 @@ first estimates the size of the modulus required to produce enough | ||
38 | Diffie-Hellman output to sufficiently key the selected symmetric cipher. | ||
39 | .Xr sshd 8 | ||
40 | then randomly selects a modulus from | ||
41 | -.Fa /etc/moduli | ||
42 | +.Fa /etc/ssh/moduli | ||
43 | that best meets the size requirement. | ||
44 | .Sh SEE ALSO | ||
45 | .Xr ssh-keygen 1 , | ||
46 | diff --git a/ssh-keygen.1 b/ssh-keygen.1 | ||
47 | index 5f1ec09b..dfbc65dd 100644 | ||
48 | --- a/ssh-keygen.1 | ||
49 | +++ b/ssh-keygen.1 | ||
50 | @@ -176,9 +176,7 @@ key in | ||
51 | .Pa ~/.ssh/id_ed25519 | ||
52 | or | ||
53 | .Pa ~/.ssh/id_rsa . | ||
54 | -Additionally, the system administrator may use this to generate host keys, | ||
55 | -as seen in | ||
56 | -.Pa /etc/rc . | ||
57 | +Additionally, the system administrator may use this to generate host keys. | ||
58 | .Pp | ||
59 | Normally this program generates the key and asks for a file in which | ||
60 | to store the private key. | ||
61 | @@ -229,9 +227,7 @@ If | ||
62 | .Fl f | ||
63 | has also been specified, its argument is used as a prefix to the | ||
64 | default path for the resulting host key files. | ||
65 | -This is used by | ||
66 | -.Pa /etc/rc | ||
67 | -to generate new host keys. | ||
68 | +This is used by system administration scripts to generate new host keys. | ||
69 | .It Fl a Ar rounds | ||
70 | When saving a new-format private key (i.e. an ed25519 key or when the | ||
71 | .Fl o | ||
72 | @@ -676,7 +672,7 @@ option. | ||
73 | Valid generator values are 2, 3, and 5. | ||
74 | .Pp | ||
75 | Screened DH groups may be installed in | ||
76 | -.Pa /etc/moduli . | ||
77 | +.Pa /etc/ssh/moduli . | ||
78 | It is important that this file contains moduli of a range of bit lengths and | ||
79 | that both ends of a connection share common moduli. | ||
80 | .Sh CERTIFICATES | ||
81 | @@ -863,7 +859,7 @@ on all machines | ||
82 | where the user wishes to log in using public key authentication. | ||
83 | There is no need to keep the contents of this file secret. | ||
84 | .Pp | ||
85 | -.It Pa /etc/moduli | ||
86 | +.It Pa /etc/ssh/moduli | ||
87 | Contains Diffie-Hellman groups used for DH-GEX. | ||
88 | The file format is described in | ||
89 | .Xr moduli 5 . | ||
90 | diff --git a/ssh.1 b/ssh.1 | ||
91 | index 3cc94688..2a2aab30 100644 | ||
92 | --- a/ssh.1 | ||
93 | +++ b/ssh.1 | ||
94 | @@ -842,6 +842,10 @@ implements public key authentication protocol automatically, | ||
95 | using one of the DSA, ECDSA, Ed25519 or RSA algorithms. | ||
96 | The HISTORY section of | ||
97 | .Xr ssl 8 | ||
98 | +(on non-OpenBSD systems, see | ||
99 | +.nh | ||
100 | +http://www.openbsd.org/cgi\-bin/man.cgi?query=ssl&sektion=8#HISTORY) | ||
101 | +.hy | ||
102 | contains a brief discussion of the DSA and RSA algorithms. | ||
103 | .Pp | ||
104 | The file | ||
105 | diff --git a/sshd.8 b/sshd.8 | ||
106 | index 2ed523a2..02c5e1df 100644 | ||
107 | --- a/sshd.8 | ||
108 | +++ b/sshd.8 | ||
109 | @@ -65,7 +65,7 @@ over an insecure network. | ||
110 | .Nm | ||
111 | listens for connections from clients. | ||
112 | It is normally started at boot from | ||
113 | -.Pa /etc/rc . | ||
114 | +.Pa /etc/init.d/ssh . | ||
115 | It forks a new | ||
116 | daemon for each incoming connection. | ||
117 | The forked daemons handle | ||
118 | @@ -850,7 +850,7 @@ This file is for host-based authentication (see | ||
119 | .Xr ssh 1 ) . | ||
120 | It should only be writable by root. | ||
121 | .Pp | ||
122 | -.It Pa /etc/moduli | ||
123 | +.It Pa /etc/ssh/moduli | ||
124 | Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange" | ||
125 | key exchange method. | ||
126 | The file format is described in | ||
127 | @@ -950,7 +950,6 @@ The content of this file is not sensitive; it can be world-readable. | ||
128 | .Xr ssh-keyscan 1 , | ||
129 | .Xr chroot 2 , | ||
130 | .Xr hosts_access 5 , | ||
131 | -.Xr login.conf 5 , | ||
132 | .Xr moduli 5 , | ||
133 | .Xr sshd_config 5 , | ||
134 | .Xr inetd 8 , | ||
135 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
136 | index 41e8c939..79676a95 100644 | ||
137 | --- a/sshd_config.5 | ||
138 | +++ b/sshd_config.5 | ||
139 | @@ -382,8 +382,7 @@ then no banner is displayed. | ||
140 | By default, no banner is displayed. | ||
141 | .It Cm ChallengeResponseAuthentication | ||
142 | Specifies whether challenge-response authentication is allowed (e.g. via | ||
143 | -PAM or through authentication styles supported in | ||
144 | -.Xr login.conf 5 ) | ||
145 | +PAM). | ||
146 | The default is | ||
147 | .Cm yes . | ||
148 | .It Cm ChrootDirectory | ||
diff --git a/debian/patches/package-versioning.patch b/debian/patches/package-versioning.patch new file mode 100644 index 000000000..0d851e68c --- /dev/null +++ b/debian/patches/package-versioning.patch | |||
@@ -0,0 +1,61 @@ | |||
1 | From 326b09bce8058629980cc92f289fd7912269eb98 Mon Sep 17 00:00:00 2001 | ||
2 | From: Matthew Vernon <matthew@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:05 +0000 | ||
4 | Subject: Include the Debian version in our identification | ||
5 | |||
6 | This makes it easier to audit networks for versions patched against security | ||
7 | vulnerabilities. It has little detrimental effect, as attackers will | ||
8 | generally just try attacks rather than bothering to scan for | ||
9 | vulnerable-looking version strings. (However, see debian-banner.patch.) | ||
10 | |||
11 | Forwarded: not-needed | ||
12 | Last-Update: 2017-10-04 | ||
13 | |||
14 | Patch-Name: package-versioning.patch | ||
15 | --- | ||
16 | sshconnect.c | 2 +- | ||
17 | sshd.c | 2 +- | ||
18 | version.h | 7 ++++++- | ||
19 | 3 files changed, 8 insertions(+), 3 deletions(-) | ||
20 | |||
21 | diff --git a/sshconnect.c b/sshconnect.c | ||
22 | index 7ce2716c..3280b310 100644 | ||
23 | --- a/sshconnect.c | ||
24 | +++ b/sshconnect.c | ||
25 | @@ -517,7 +517,7 @@ send_client_banner(int connection_out, int minor1) | ||
26 | { | ||
27 | /* Send our own protocol version identification. */ | ||
28 | xasprintf(&client_version_string, "SSH-%d.%d-%.100s\r\n", | ||
29 | - PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_VERSION); | ||
30 | + PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_RELEASE); | ||
31 | if (atomicio(vwrite, connection_out, client_version_string, | ||
32 | strlen(client_version_string)) != strlen(client_version_string)) | ||
33 | fatal("write: %.100s", strerror(errno)); | ||
34 | diff --git a/sshd.c b/sshd.c | ||
35 | index af1ec337..eccf81bb 100644 | ||
36 | --- a/sshd.c | ||
37 | +++ b/sshd.c | ||
38 | @@ -378,7 +378,7 @@ sshd_exchange_identification(struct ssh *ssh, int sock_in, int sock_out) | ||
39 | char remote_version[256]; /* Must be at least as big as buf. */ | ||
40 | |||
41 | xasprintf(&server_version_string, "SSH-%d.%d-%.100s%s%s\r\n", | ||
42 | - PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_VERSION, | ||
43 | + PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_RELEASE, | ||
44 | *options.version_addendum == '\0' ? "" : " ", | ||
45 | options.version_addendum); | ||
46 | |||
47 | diff --git a/version.h b/version.h | ||
48 | index e093f623..b7c5ad2a 100644 | ||
49 | --- a/version.h | ||
50 | +++ b/version.h | ||
51 | @@ -3,4 +3,9 @@ | ||
52 | #define SSH_VERSION "OpenSSH_7.6" | ||
53 | |||
54 | #define SSH_PORTABLE "p1" | ||
55 | -#define SSH_RELEASE SSH_VERSION SSH_PORTABLE | ||
56 | +#define SSH_RELEASE_MINIMUM SSH_VERSION SSH_PORTABLE | ||
57 | +#ifdef SSH_EXTRAVERSION | ||
58 | +#define SSH_RELEASE SSH_RELEASE_MINIMUM " " SSH_EXTRAVERSION | ||
59 | +#else | ||
60 | +#define SSH_RELEASE SSH_RELEASE_MINIMUM | ||
61 | +#endif | ||
diff --git a/debian/patches/permitopen-argument-handling.patch b/debian/patches/permitopen-argument-handling.patch new file mode 100644 index 000000000..6369c395c --- /dev/null +++ b/debian/patches/permitopen-argument-handling.patch | |||
@@ -0,0 +1,51 @@ | |||
1 | From e293f21da513a7db59fe1997c9e90e2e9cdbceda Mon Sep 17 00:00:00 2001 | ||
2 | From: "djm@openbsd.org" <djm@openbsd.org> | ||
3 | Date: Wed, 4 Oct 2017 18:49:30 +0000 | ||
4 | Subject: Fix PermitOpen argument handling | ||
5 | |||
6 | fix (another) problem in PermitOpen introduced during the | ||
7 | channels.c refactor: the third and subsequent arguments to PermitOpen were | ||
8 | being silently ignored; ok markus@ | ||
9 | |||
10 | Upstream-ID: 067c89f1f53cbc381628012ba776d6861e6782fd | ||
11 | |||
12 | Origin: https://anongit.mindrot.org/openssh.git/commit/?id=7c9613fac3371cf65fb07739212cdd1ebf6575da | ||
13 | Last-Update: 2017-10-07 | ||
14 | |||
15 | Patch-Name: permitopen-argument-handling.patch | ||
16 | --- | ||
17 | servconf.c | 8 ++++---- | ||
18 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
19 | |||
20 | diff --git a/servconf.c b/servconf.c | ||
21 | index 5e996cf8..9daa182c 100644 | ||
22 | --- a/servconf.c | ||
23 | +++ b/servconf.c | ||
24 | @@ -1,5 +1,5 @@ | ||
25 | |||
26 | -/* $OpenBSD: servconf.c,v 1.312 2017/10/02 19:33:20 djm Exp $ */ | ||
27 | +/* $OpenBSD: servconf.c,v 1.313 2017/10/04 18:49:30 djm Exp $ */ | ||
28 | /* | ||
29 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | ||
30 | * All rights reserved | ||
31 | @@ -1690,9 +1690,9 @@ process_server_config_line(ServerOptions *options, char *line, | ||
32 | if (!arg || *arg == '\0') | ||
33 | fatal("%s line %d: missing PermitOpen specification", | ||
34 | filename, linenum); | ||
35 | - i = options->num_permitted_opens; /* modified later */ | ||
36 | + value = options->num_permitted_opens; /* modified later */ | ||
37 | if (strcmp(arg, "any") == 0 || strcmp(arg, "none") == 0) { | ||
38 | - if (*activep && i == 0) { | ||
39 | + if (*activep && value == 0) { | ||
40 | options->num_permitted_opens = 1; | ||
41 | options->permitted_opens = xcalloc(1, | ||
42 | sizeof(*options->permitted_opens)); | ||
43 | @@ -1710,7 +1710,7 @@ process_server_config_line(ServerOptions *options, char *line, | ||
44 | if (arg == NULL || ((port = permitopen_port(arg)) < 0)) | ||
45 | fatal("%s line %d: bad port number in " | ||
46 | "PermitOpen", filename, linenum); | ||
47 | - if (*activep && i == 0) { | ||
48 | + if (*activep && value == 0) { | ||
49 | options->permitted_opens = xrecallocarray( | ||
50 | options->permitted_opens, | ||
51 | options->num_permitted_opens, | ||
diff --git a/debian/patches/restore-authorized_keys2.patch b/debian/patches/restore-authorized_keys2.patch new file mode 100644 index 000000000..098f9d681 --- /dev/null +++ b/debian/patches/restore-authorized_keys2.patch | |||
@@ -0,0 +1,35 @@ | |||
1 | From 6c2e9847f608cc9c36236eecc58241cd3358dd5b Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 5 Mar 2017 02:02:11 +0000 | ||
4 | Subject: Restore reading authorized_keys2 by default | ||
5 | |||
6 | Upstream seems to intend to gradually phase this out, so don't assume | ||
7 | that this will remain the default forever. However, we were late in | ||
8 | adopting the upstream sshd_config changes, so it makes sense to extend | ||
9 | the grace period. | ||
10 | |||
11 | Bug-Debian: https://bugs.debian.org/852320 | ||
12 | Forwarded: not-needed | ||
13 | Last-Update: 2017-03-05 | ||
14 | |||
15 | Patch-Name: restore-authorized_keys2.patch | ||
16 | --- | ||
17 | sshd_config | 5 ++--- | ||
18 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
19 | |||
20 | diff --git a/sshd_config b/sshd_config | ||
21 | index 92822959..a32dc1d4 100644 | ||
22 | --- a/sshd_config | ||
23 | +++ b/sshd_config | ||
24 | @@ -36,9 +36,8 @@ | ||
25 | |||
26 | #PubkeyAuthentication yes | ||
27 | |||
28 | -# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 | ||
29 | -# but this is overridden so installations will only check .ssh/authorized_keys | ||
30 | -AuthorizedKeysFile .ssh/authorized_keys | ||
31 | +# Expect .ssh/authorized_keys2 to be disregarded by default in future. | ||
32 | +#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 | ||
33 | |||
34 | #AuthorizedPrincipalsFile none | ||
35 | |||
diff --git a/debian/patches/restore-tcp-wrappers.patch b/debian/patches/restore-tcp-wrappers.patch new file mode 100644 index 000000000..5832897d2 --- /dev/null +++ b/debian/patches/restore-tcp-wrappers.patch | |||
@@ -0,0 +1,172 @@ | |||
1 | From cdd9076a145a95c21538eedb3f728a897480c5de Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Tue, 7 Oct 2014 13:22:41 +0100 | ||
4 | Subject: Restore TCP wrappers support | ||
5 | |||
6 | Support for TCP wrappers was dropped in OpenSSH 6.7. See this message | ||
7 | and thread: | ||
8 | |||
9 | https://lists.mindrot.org/pipermail/openssh-unix-dev/2014-April/032497.html | ||
10 | |||
11 | It is true that this reduces preauth attack surface in sshd. On the | ||
12 | other hand, this support seems to be quite widely used, and abruptly | ||
13 | dropping it (from the perspective of users who don't read | ||
14 | openssh-unix-dev) could easily cause more serious problems in practice. | ||
15 | |||
16 | It's not entirely clear what the right long-term answer for Debian is, | ||
17 | but it at least probably doesn't involve dropping this feature shortly | ||
18 | before a freeze. | ||
19 | |||
20 | Forwarded: not-needed | ||
21 | Last-Update: 2014-10-07 | ||
22 | |||
23 | Patch-Name: restore-tcp-wrappers.patch | ||
24 | --- | ||
25 | configure.ac | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
26 | sshd.8 | 7 +++++++ | ||
27 | sshd.c | 25 +++++++++++++++++++++++++ | ||
28 | 3 files changed, 89 insertions(+) | ||
29 | |||
30 | diff --git a/configure.ac b/configure.ac | ||
31 | index 84bfad8c..3b30736b 100644 | ||
32 | --- a/configure.ac | ||
33 | +++ b/configure.ac | ||
34 | @@ -1503,6 +1503,62 @@ AC_ARG_WITH([skey], | ||
35 | ] | ||
36 | ) | ||
37 | |||
38 | +# Check whether user wants TCP wrappers support | ||
39 | +TCPW_MSG="no" | ||
40 | +AC_ARG_WITH([tcp-wrappers], | ||
41 | + [ --with-tcp-wrappers[[=PATH]] Enable tcpwrappers support (optionally in PATH)], | ||
42 | + [ | ||
43 | + if test "x$withval" != "xno" ; then | ||
44 | + saved_LIBS="$LIBS" | ||
45 | + saved_LDFLAGS="$LDFLAGS" | ||
46 | + saved_CPPFLAGS="$CPPFLAGS" | ||
47 | + if test -n "${withval}" && \ | ||
48 | + test "x${withval}" != "xyes"; then | ||
49 | + if test -d "${withval}/lib"; then | ||
50 | + if test -n "${need_dash_r}"; then | ||
51 | + LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}" | ||
52 | + else | ||
53 | + LDFLAGS="-L${withval}/lib ${LDFLAGS}" | ||
54 | + fi | ||
55 | + else | ||
56 | + if test -n "${need_dash_r}"; then | ||
57 | + LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}" | ||
58 | + else | ||
59 | + LDFLAGS="-L${withval} ${LDFLAGS}" | ||
60 | + fi | ||
61 | + fi | ||
62 | + if test -d "${withval}/include"; then | ||
63 | + CPPFLAGS="-I${withval}/include ${CPPFLAGS}" | ||
64 | + else | ||
65 | + CPPFLAGS="-I${withval} ${CPPFLAGS}" | ||
66 | + fi | ||
67 | + fi | ||
68 | + LIBS="-lwrap $LIBS" | ||
69 | + AC_MSG_CHECKING([for libwrap]) | ||
70 | + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | ||
71 | +#include <sys/types.h> | ||
72 | +#include <sys/socket.h> | ||
73 | +#include <netinet/in.h> | ||
74 | +#include <tcpd.h> | ||
75 | +int deny_severity = 0, allow_severity = 0; | ||
76 | + ]], [[ | ||
77 | + hosts_access(0); | ||
78 | + ]])], [ | ||
79 | + AC_MSG_RESULT([yes]) | ||
80 | + AC_DEFINE([LIBWRAP], [1], | ||
81 | + [Define if you want | ||
82 | + TCP Wrappers support]) | ||
83 | + SSHDLIBS="$SSHDLIBS -lwrap" | ||
84 | + TCPW_MSG="yes" | ||
85 | + ], [ | ||
86 | + AC_MSG_ERROR([*** libwrap missing]) | ||
87 | + | ||
88 | + ]) | ||
89 | + LIBS="$saved_LIBS" | ||
90 | + fi | ||
91 | + ] | ||
92 | +) | ||
93 | + | ||
94 | # Check whether user wants to use ldns | ||
95 | LDNS_MSG="no" | ||
96 | AC_ARG_WITH(ldns, | ||
97 | @@ -5133,6 +5189,7 @@ echo " KerberosV support: $KRB5_MSG" | ||
98 | echo " SELinux support: $SELINUX_MSG" | ||
99 | echo " Smartcard support: $SCARD_MSG" | ||
100 | echo " S/KEY support: $SKEY_MSG" | ||
101 | +echo " TCP Wrappers support: $TCPW_MSG" | ||
102 | echo " MD5 password support: $MD5_MSG" | ||
103 | echo " libedit support: $LIBEDIT_MSG" | ||
104 | echo " libldns support: $LDNS_MSG" | ||
105 | diff --git a/sshd.8 b/sshd.8 | ||
106 | index a4201146..2ed523a2 100644 | ||
107 | --- a/sshd.8 | ||
108 | +++ b/sshd.8 | ||
109 | @@ -839,6 +839,12 @@ the user's home directory becomes accessible. | ||
110 | This file should be writable only by the user, and need not be | ||
111 | readable by anyone else. | ||
112 | .Pp | ||
113 | +.It Pa /etc/hosts.allow | ||
114 | +.It Pa /etc/hosts.deny | ||
115 | +Access controls that should be enforced by tcp-wrappers are defined here. | ||
116 | +Further details are described in | ||
117 | +.Xr hosts_access 5 . | ||
118 | +.Pp | ||
119 | .It Pa /etc/hosts.equiv | ||
120 | This file is for host-based authentication (see | ||
121 | .Xr ssh 1 ) . | ||
122 | @@ -943,6 +949,7 @@ The content of this file is not sensitive; it can be world-readable. | ||
123 | .Xr ssh-keygen 1 , | ||
124 | .Xr ssh-keyscan 1 , | ||
125 | .Xr chroot 2 , | ||
126 | +.Xr hosts_access 5 , | ||
127 | .Xr login.conf 5 , | ||
128 | .Xr moduli 5 , | ||
129 | .Xr sshd_config 5 , | ||
130 | diff --git a/sshd.c b/sshd.c | ||
131 | index 45e50fac..a66e9ca6 100644 | ||
132 | --- a/sshd.c | ||
133 | +++ b/sshd.c | ||
134 | @@ -126,6 +126,13 @@ | ||
135 | #include <Security/AuthSession.h> | ||
136 | #endif | ||
137 | |||
138 | +#ifdef LIBWRAP | ||
139 | +#include <tcpd.h> | ||
140 | +#include <syslog.h> | ||
141 | +int allow_severity; | ||
142 | +int deny_severity; | ||
143 | +#endif /* LIBWRAP */ | ||
144 | + | ||
145 | /* Re-exec fds */ | ||
146 | #define REEXEC_DEVCRYPTO_RESERVED_FD (STDERR_FILENO + 1) | ||
147 | #define REEXEC_STARTUP_PIPE_FD (STDERR_FILENO + 2) | ||
148 | @@ -1987,6 +1994,24 @@ main(int ac, char **av) | ||
149 | #ifdef SSH_AUDIT_EVENTS | ||
150 | audit_connection_from(remote_ip, remote_port); | ||
151 | #endif | ||
152 | +#ifdef LIBWRAP | ||
153 | + allow_severity = options.log_facility|LOG_INFO; | ||
154 | + deny_severity = options.log_facility|LOG_WARNING; | ||
155 | + /* Check whether logins are denied from this host. */ | ||
156 | + if (packet_connection_is_on_socket()) { | ||
157 | + struct request_info req; | ||
158 | + | ||
159 | + request_init(&req, RQ_DAEMON, __progname, RQ_FILE, sock_in, 0); | ||
160 | + fromhost(&req); | ||
161 | + | ||
162 | + if (!hosts_access(&req)) { | ||
163 | + debug("Connection refused by tcp wrapper"); | ||
164 | + refuse(&req); | ||
165 | + /* NOTREACHED */ | ||
166 | + fatal("libwrap refuse returns"); | ||
167 | + } | ||
168 | + } | ||
169 | +#endif /* LIBWRAP */ | ||
170 | |||
171 | /* Log the connection. */ | ||
172 | laddr = get_local_ipaddr(sock_in); | ||
diff --git a/debian/patches/scp-quoting.patch b/debian/patches/scp-quoting.patch new file mode 100644 index 000000000..43153ec04 --- /dev/null +++ b/debian/patches/scp-quoting.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | From ef7aa8189491e0b43f14f7f15fb5e66903f7e185 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Nicolas=20Valc=C3=A1rcel?= <nvalcarcel@ubuntu.com> | ||
3 | Date: Sun, 9 Feb 2014 16:09:59 +0000 | ||
4 | Subject: Adjust scp quoting in verbose mode | ||
5 | |||
6 | Tweak scp's reporting of filenames in verbose mode to be a bit less | ||
7 | confusing with spaces. | ||
8 | |||
9 | This should be revised to mimic real shell quoting. | ||
10 | |||
11 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/89945 | ||
12 | Last-Update: 2010-02-27 | ||
13 | |||
14 | Patch-Name: scp-quoting.patch | ||
15 | --- | ||
16 | scp.c | 12 ++++++++++-- | ||
17 | 1 file changed, 10 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/scp.c b/scp.c | ||
20 | index a533eb09..12e3199d 100644 | ||
21 | --- a/scp.c | ||
22 | +++ b/scp.c | ||
23 | @@ -194,8 +194,16 @@ do_local_cmd(arglist *a) | ||
24 | |||
25 | if (verbose_mode) { | ||
26 | fprintf(stderr, "Executing:"); | ||
27 | - for (i = 0; i < a->num; i++) | ||
28 | - fmprintf(stderr, " %s", a->list[i]); | ||
29 | + for (i = 0; i < a->num; i++) { | ||
30 | + if (i == 0) | ||
31 | + fmprintf(stderr, " %s", a->list[i]); | ||
32 | + else | ||
33 | + /* | ||
34 | + * TODO: misbehaves if a->list[i] contains a | ||
35 | + * single quote | ||
36 | + */ | ||
37 | + fmprintf(stderr, " '%s'", a->list[i]); | ||
38 | + } | ||
39 | fprintf(stderr, "\n"); | ||
40 | } | ||
41 | if ((pid = fork()) == -1) | ||
diff --git a/debian/patches/seccomp-getuid-geteuid.patch b/debian/patches/seccomp-getuid-geteuid.patch new file mode 100644 index 000000000..41455aa83 --- /dev/null +++ b/debian/patches/seccomp-getuid-geteuid.patch | |||
@@ -0,0 +1,44 @@ | |||
1 | From 8165600205696cca8a080a5cb6746070512174e9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Eduardo Barretto <ebarretto@linux.vnet.ibm.com> | ||
3 | Date: Tue, 9 May 2017 13:31:05 -0300 | ||
4 | Subject: Allow getuid and geteuid calls | ||
5 | |||
6 | getuid and geteuid are needed when using an openssl engine that calls a | ||
7 | crypto card, e.g. ICA (libica). | ||
8 | Those syscalls are also needed by the distros for audit code. | ||
9 | |||
10 | Signed-off-by: Eduardo Barretto <ebarretto@linux.vnet.ibm.com> | ||
11 | |||
12 | Origin: other, https://bugzilla.mindrot.org/show_bug.cgi?id=2752 | ||
13 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=2752 | ||
14 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/1686618 | ||
15 | Last-Update: 2017-08-28 | ||
16 | |||
17 | Patch-Name: seccomp-getuid-geteuid.patch | ||
18 | --- | ||
19 | sandbox-seccomp-filter.c | 12 ++++++++++++ | ||
20 | 1 file changed, 12 insertions(+) | ||
21 | |||
22 | diff --git a/sandbox-seccomp-filter.c b/sandbox-seccomp-filter.c | ||
23 | index 6e7de311..e86aa2c9 100644 | ||
24 | --- a/sandbox-seccomp-filter.c | ||
25 | +++ b/sandbox-seccomp-filter.c | ||
26 | @@ -175,6 +175,18 @@ static const struct sock_filter preauth_insns[] = { | ||
27 | #ifdef __NR_getpid | ||
28 | SC_ALLOW(__NR_getpid), | ||
29 | #endif | ||
30 | +#ifdef __NR_getuid | ||
31 | + SC_ALLOW(__NR_getuid), | ||
32 | +#endif | ||
33 | +#ifdef __NR_getuid32 | ||
34 | + SC_ALLOW(__NR_getuid32), | ||
35 | +#endif | ||
36 | +#ifdef __NR_geteuid | ||
37 | + SC_ALLOW(__NR_geteuid), | ||
38 | +#endif | ||
39 | +#ifdef __NR_geteuid32 | ||
40 | + SC_ALLOW(__NR_geteuid32), | ||
41 | +#endif | ||
42 | #ifdef __NR_getrandom | ||
43 | SC_ALLOW(__NR_getrandom), | ||
44 | #endif | ||
diff --git a/debian/patches/seccomp-s390-flock-ipc.patch b/debian/patches/seccomp-s390-flock-ipc.patch new file mode 100644 index 000000000..5fb94137d --- /dev/null +++ b/debian/patches/seccomp-s390-flock-ipc.patch | |||
@@ -0,0 +1,47 @@ | |||
1 | From a5a99443e190a90eb511215aa7c1fa940f79b901 Mon Sep 17 00:00:00 2001 | ||
2 | From: Eduardo Barretto <ebarretto@linux.vnet.ibm.com> | ||
3 | Date: Tue, 9 May 2017 10:53:04 -0300 | ||
4 | Subject: Allow flock and ipc syscall for s390 architecture | ||
5 | |||
6 | In order to use the OpenSSL-ibmpkcs11 engine it is needed to allow flock | ||
7 | and ipc calls, because this engine calls OpenCryptoki (a PKCS#11 | ||
8 | implementation) which calls the libraries that will communicate with the | ||
9 | crypto cards. OpenCryptoki makes use of flock and ipc and, as of now, | ||
10 | this is only need on s390 architecture. | ||
11 | |||
12 | Signed-off-by: Eduardo Barretto <ebarretto@linux.vnet.ibm.com> | ||
13 | |||
14 | Origin: other, https://bugzilla.mindrot.org/show_bug.cgi?id=2752 | ||
15 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=2752 | ||
16 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/1686618 | ||
17 | Last-Update: 2017-08-28 | ||
18 | |||
19 | Patch-Name: seccomp-s390-flock-ipc.patch | ||
20 | --- | ||
21 | sandbox-seccomp-filter.c | 6 ++++++ | ||
22 | 1 file changed, 6 insertions(+) | ||
23 | |||
24 | diff --git a/sandbox-seccomp-filter.c b/sandbox-seccomp-filter.c | ||
25 | index ca75cc71..6e7de311 100644 | ||
26 | --- a/sandbox-seccomp-filter.c | ||
27 | +++ b/sandbox-seccomp-filter.c | ||
28 | @@ -166,6 +166,9 @@ static const struct sock_filter preauth_insns[] = { | ||
29 | #ifdef __NR_exit_group | ||
30 | SC_ALLOW(__NR_exit_group), | ||
31 | #endif | ||
32 | +#if defined(__NR_flock) && defined(__s390__) | ||
33 | + SC_ALLOW(__NR_flock), | ||
34 | +#endif | ||
35 | #ifdef __NR_getpgid | ||
36 | SC_ALLOW(__NR_getpgid), | ||
37 | #endif | ||
38 | @@ -178,6 +181,9 @@ static const struct sock_filter preauth_insns[] = { | ||
39 | #ifdef __NR_gettimeofday | ||
40 | SC_ALLOW(__NR_gettimeofday), | ||
41 | #endif | ||
42 | +#if defined(__NR_ipc) && defined(__s390__) | ||
43 | + SC_ALLOW(__NR_ipc), | ||
44 | +#endif | ||
45 | #ifdef __NR_madvise | ||
46 | SC_ALLOW(__NR_madvise), | ||
47 | #endif | ||
diff --git a/debian/patches/seccomp-s390-ioctl-ep11-crypto.patch b/debian/patches/seccomp-s390-ioctl-ep11-crypto.patch new file mode 100644 index 000000000..595b3d6ec --- /dev/null +++ b/debian/patches/seccomp-s390-ioctl-ep11-crypto.patch | |||
@@ -0,0 +1,33 @@ | |||
1 | From 801a62eedaaf47b20dbf4b426dc3e084bf0c8d49 Mon Sep 17 00:00:00 2001 | ||
2 | From: Eduardo Barretto <ebarretto@linux.vnet.ibm.com> | ||
3 | Date: Tue, 9 May 2017 13:33:30 -0300 | ||
4 | Subject: Enable specific ioctl call for EP11 crypto card (s390) | ||
5 | |||
6 | The EP11 crypto card needs to make an ioctl call, which receives an | ||
7 | specific argument. This crypto card is for s390 only. | ||
8 | |||
9 | Signed-off-by: Eduardo Barretto <ebarretto@linux.vnet.ibm.com> | ||
10 | |||
11 | Origin: other, https://bugzilla.mindrot.org/show_bug.cgi?id=2752 | ||
12 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=2752 | ||
13 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/1686618 | ||
14 | Last-Update: 2017-08-28 | ||
15 | |||
16 | Patch-Name: seccomp-s390-ioctl-ep11-crypto.patch | ||
17 | --- | ||
18 | sandbox-seccomp-filter.c | 2 ++ | ||
19 | 1 file changed, 2 insertions(+) | ||
20 | |||
21 | diff --git a/sandbox-seccomp-filter.c b/sandbox-seccomp-filter.c | ||
22 | index e86aa2c9..98062f15 100644 | ||
23 | --- a/sandbox-seccomp-filter.c | ||
24 | +++ b/sandbox-seccomp-filter.c | ||
25 | @@ -250,6 +250,8 @@ static const struct sock_filter preauth_insns[] = { | ||
26 | SC_ALLOW_ARG(__NR_ioctl, 1, Z90STAT_STATUS_MASK), | ||
27 | SC_ALLOW_ARG(__NR_ioctl, 1, ICARSAMODEXPO), | ||
28 | SC_ALLOW_ARG(__NR_ioctl, 1, ICARSACRT), | ||
29 | + /* Allow ioctls for EP11 crypto card on s390 */ | ||
30 | + SC_ALLOW_ARG(__NR_ioctl, 1, ZSENDEP11CPRB), | ||
31 | #endif | ||
32 | #if defined(__x86_64__) && defined(__ILP32__) && defined(__X32_SYSCALL_BIT) | ||
33 | /* | ||
diff --git a/debian/patches/selinux-role.patch b/debian/patches/selinux-role.patch new file mode 100644 index 000000000..1402b9025 --- /dev/null +++ b/debian/patches/selinux-role.patch | |||
@@ -0,0 +1,473 @@ | |||
1 | From 4b276122c04aed0726803a92c8ca955e614a4d3a Mon Sep 17 00:00:00 2001 | ||
2 | From: Manoj Srivastava <srivasta@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:09:49 +0000 | ||
4 | Subject: Handle SELinux authorisation roles | ||
5 | |||
6 | Rejected upstream due to discomfort with magic usernames; a better approach | ||
7 | will need an SSH protocol change. In the meantime, this came from Debian's | ||
8 | SELinux maintainer, so we'll keep it until we have something better. | ||
9 | |||
10 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1641 | ||
11 | Bug-Debian: http://bugs.debian.org/394795 | ||
12 | Last-Update: 2017-10-04 | ||
13 | |||
14 | Patch-Name: selinux-role.patch | ||
15 | --- | ||
16 | auth.h | 1 + | ||
17 | auth2.c | 10 ++++++++-- | ||
18 | monitor.c | 32 +++++++++++++++++++++++++++++--- | ||
19 | monitor.h | 2 ++ | ||
20 | monitor_wrap.c | 22 ++++++++++++++++++++-- | ||
21 | monitor_wrap.h | 3 ++- | ||
22 | openbsd-compat/port-linux.c | 27 ++++++++++++++++++++------- | ||
23 | openbsd-compat/port-linux.h | 4 ++-- | ||
24 | platform.c | 4 ++-- | ||
25 | platform.h | 2 +- | ||
26 | session.c | 10 +++++----- | ||
27 | session.h | 2 +- | ||
28 | sshd.c | 2 +- | ||
29 | sshpty.c | 4 ++-- | ||
30 | sshpty.h | 2 +- | ||
31 | 15 files changed, 97 insertions(+), 30 deletions(-) | ||
32 | |||
33 | diff --git a/auth.h b/auth.h | ||
34 | index 29835ae9..27a1a88e 100644 | ||
35 | --- a/auth.h | ||
36 | +++ b/auth.h | ||
37 | @@ -63,6 +63,7 @@ struct Authctxt { | ||
38 | char *service; | ||
39 | struct passwd *pw; /* set if 'valid' */ | ||
40 | char *style; | ||
41 | + char *role; | ||
42 | |||
43 | /* Method lists for multiple authentication */ | ||
44 | char **auth_methods; /* modified from server config */ | ||
45 | diff --git a/auth2.c b/auth2.c | ||
46 | index 54070e3a..1f9ec632 100644 | ||
47 | --- a/auth2.c | ||
48 | +++ b/auth2.c | ||
49 | @@ -221,7 +221,7 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh) | ||
50 | { | ||
51 | Authctxt *authctxt = ssh->authctxt; | ||
52 | Authmethod *m = NULL; | ||
53 | - char *user, *service, *method, *style = NULL; | ||
54 | + char *user, *service, *method, *style = NULL, *role = NULL; | ||
55 | int authenticated = 0; | ||
56 | |||
57 | if (authctxt == NULL) | ||
58 | @@ -233,8 +233,13 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh) | ||
59 | debug("userauth-request for user %s service %s method %s", user, service, method); | ||
60 | debug("attempt %d failures %d", authctxt->attempt, authctxt->failures); | ||
61 | |||
62 | + if ((role = strchr(user, '/')) != NULL) | ||
63 | + *role++ = 0; | ||
64 | + | ||
65 | if ((style = strchr(user, ':')) != NULL) | ||
66 | *style++ = 0; | ||
67 | + else if (role && (style = strchr(role, ':')) != NULL) | ||
68 | + *style++ = '\0'; | ||
69 | |||
70 | if (authctxt->attempt++ == 0) { | ||
71 | /* setup auth context */ | ||
72 | @@ -261,8 +266,9 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh) | ||
73 | use_privsep ? " [net]" : ""); | ||
74 | authctxt->service = xstrdup(service); | ||
75 | authctxt->style = style ? xstrdup(style) : NULL; | ||
76 | + authctxt->role = role ? xstrdup(role) : NULL; | ||
77 | if (use_privsep) | ||
78 | - mm_inform_authserv(service, style); | ||
79 | + mm_inform_authserv(service, style, role); | ||
80 | userauth_banner(); | ||
81 | if (auth2_setup_methods_lists(authctxt) != 0) | ||
82 | packet_disconnect("no authentication methods enabled"); | ||
83 | diff --git a/monitor.c b/monitor.c | ||
84 | index cabfeb8a..510e3496 100644 | ||
85 | --- a/monitor.c | ||
86 | +++ b/monitor.c | ||
87 | @@ -127,6 +127,7 @@ int mm_answer_sign(int, Buffer *); | ||
88 | int mm_answer_pwnamallow(int, Buffer *); | ||
89 | int mm_answer_auth2_read_banner(int, Buffer *); | ||
90 | int mm_answer_authserv(int, Buffer *); | ||
91 | +int mm_answer_authrole(int, Buffer *); | ||
92 | int mm_answer_authpassword(int, Buffer *); | ||
93 | int mm_answer_bsdauthquery(int, Buffer *); | ||
94 | int mm_answer_bsdauthrespond(int, Buffer *); | ||
95 | @@ -204,6 +205,7 @@ struct mon_table mon_dispatch_proto20[] = { | ||
96 | {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, | ||
97 | {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, | ||
98 | {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, | ||
99 | + {MONITOR_REQ_AUTHROLE, MON_ONCE, mm_answer_authrole}, | ||
100 | {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, | ||
101 | {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, | ||
102 | #ifdef USE_PAM | ||
103 | @@ -799,6 +801,7 @@ mm_answer_pwnamallow(int sock, Buffer *m) | ||
104 | |||
105 | /* Allow service/style information on the auth context */ | ||
106 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); | ||
107 | + monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1); | ||
108 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); | ||
109 | |||
110 | #ifdef USE_PAM | ||
111 | @@ -829,14 +832,37 @@ mm_answer_authserv(int sock, Buffer *m) | ||
112 | |||
113 | authctxt->service = buffer_get_string(m, NULL); | ||
114 | authctxt->style = buffer_get_string(m, NULL); | ||
115 | - debug3("%s: service=%s, style=%s", | ||
116 | - __func__, authctxt->service, authctxt->style); | ||
117 | + authctxt->role = buffer_get_string(m, NULL); | ||
118 | + debug3("%s: service=%s, style=%s, role=%s", | ||
119 | + __func__, authctxt->service, authctxt->style, authctxt->role); | ||
120 | |||
121 | if (strlen(authctxt->style) == 0) { | ||
122 | free(authctxt->style); | ||
123 | authctxt->style = NULL; | ||
124 | } | ||
125 | |||
126 | + if (strlen(authctxt->role) == 0) { | ||
127 | + free(authctxt->role); | ||
128 | + authctxt->role = NULL; | ||
129 | + } | ||
130 | + | ||
131 | + return (0); | ||
132 | +} | ||
133 | + | ||
134 | +int | ||
135 | +mm_answer_authrole(int sock, Buffer *m) | ||
136 | +{ | ||
137 | + monitor_permit_authentications(1); | ||
138 | + | ||
139 | + authctxt->role = buffer_get_string(m, NULL); | ||
140 | + debug3("%s: role=%s", | ||
141 | + __func__, authctxt->role); | ||
142 | + | ||
143 | + if (strlen(authctxt->role) == 0) { | ||
144 | + free(authctxt->role); | ||
145 | + authctxt->role = NULL; | ||
146 | + } | ||
147 | + | ||
148 | return (0); | ||
149 | } | ||
150 | |||
151 | @@ -1471,7 +1497,7 @@ mm_answer_pty(int sock, Buffer *m) | ||
152 | res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty)); | ||
153 | if (res == 0) | ||
154 | goto error; | ||
155 | - pty_setowner(authctxt->pw, s->tty); | ||
156 | + pty_setowner(authctxt->pw, s->tty, authctxt->role); | ||
157 | |||
158 | buffer_put_int(m, 1); | ||
159 | buffer_put_cstring(m, s->tty); | ||
160 | diff --git a/monitor.h b/monitor.h | ||
161 | index ec41404c..4c7955d7 100644 | ||
162 | --- a/monitor.h | ||
163 | +++ b/monitor.h | ||
164 | @@ -68,6 +68,8 @@ enum monitor_reqtype { | ||
165 | MONITOR_REQ_GSSSIGN = 150, MONITOR_ANS_GSSSIGN = 151, | ||
166 | MONITOR_REQ_GSSUPCREDS = 152, MONITOR_ANS_GSSUPCREDS = 153, | ||
167 | |||
168 | + MONITOR_REQ_AUTHROLE = 154, | ||
169 | + | ||
170 | }; | ||
171 | |||
172 | struct monitor { | ||
173 | diff --git a/monitor_wrap.c b/monitor_wrap.c | ||
174 | index 0e171a6a..d806bb2e 100644 | ||
175 | --- a/monitor_wrap.c | ||
176 | +++ b/monitor_wrap.c | ||
177 | @@ -336,10 +336,10 @@ mm_auth2_read_banner(void) | ||
178 | return (banner); | ||
179 | } | ||
180 | |||
181 | -/* Inform the privileged process about service and style */ | ||
182 | +/* Inform the privileged process about service, style, and role */ | ||
183 | |||
184 | void | ||
185 | -mm_inform_authserv(char *service, char *style) | ||
186 | +mm_inform_authserv(char *service, char *style, char *role) | ||
187 | { | ||
188 | Buffer m; | ||
189 | |||
190 | @@ -348,12 +348,30 @@ mm_inform_authserv(char *service, char *style) | ||
191 | buffer_init(&m); | ||
192 | buffer_put_cstring(&m, service); | ||
193 | buffer_put_cstring(&m, style ? style : ""); | ||
194 | + buffer_put_cstring(&m, role ? role : ""); | ||
195 | |||
196 | mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHSERV, &m); | ||
197 | |||
198 | buffer_free(&m); | ||
199 | } | ||
200 | |||
201 | +/* Inform the privileged process about role */ | ||
202 | + | ||
203 | +void | ||
204 | +mm_inform_authrole(char *role) | ||
205 | +{ | ||
206 | + Buffer m; | ||
207 | + | ||
208 | + debug3("%s entering", __func__); | ||
209 | + | ||
210 | + buffer_init(&m); | ||
211 | + buffer_put_cstring(&m, role ? role : ""); | ||
212 | + | ||
213 | + mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHROLE, &m); | ||
214 | + | ||
215 | + buffer_free(&m); | ||
216 | +} | ||
217 | + | ||
218 | /* Do the password authentication */ | ||
219 | int | ||
220 | mm_auth_password(Authctxt *authctxt, char *password) | ||
221 | diff --git a/monitor_wrap.h b/monitor_wrap.h | ||
222 | index 7b2e8945..a9ccb243 100644 | ||
223 | --- a/monitor_wrap.h | ||
224 | +++ b/monitor_wrap.h | ||
225 | @@ -41,7 +41,8 @@ int mm_is_monitor(void); | ||
226 | DH *mm_choose_dh(int, int, int); | ||
227 | int mm_key_sign(struct sshkey *, u_char **, u_int *, const u_char *, u_int, | ||
228 | const char *); | ||
229 | -void mm_inform_authserv(char *, char *); | ||
230 | +void mm_inform_authserv(char *, char *, char *); | ||
231 | +void mm_inform_authrole(char *); | ||
232 | struct passwd *mm_getpwnamallow(const char *); | ||
233 | char *mm_auth2_read_banner(void); | ||
234 | int mm_auth_password(struct Authctxt *, char *); | ||
235 | diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c | ||
236 | index e4c5d1b7..e26faf08 100644 | ||
237 | --- a/openbsd-compat/port-linux.c | ||
238 | +++ b/openbsd-compat/port-linux.c | ||
239 | @@ -27,6 +27,12 @@ | ||
240 | #include <string.h> | ||
241 | #include <stdio.h> | ||
242 | |||
243 | +#ifdef WITH_SELINUX | ||
244 | +#include "key.h" | ||
245 | +#include "hostfile.h" | ||
246 | +#include "auth.h" | ||
247 | +#endif | ||
248 | + | ||
249 | #include "log.h" | ||
250 | #include "xmalloc.h" | ||
251 | #include "port-linux.h" | ||
252 | @@ -56,7 +62,7 @@ ssh_selinux_enabled(void) | ||
253 | |||
254 | /* Return the default security context for the given username */ | ||
255 | static security_context_t | ||
256 | -ssh_selinux_getctxbyname(char *pwname) | ||
257 | +ssh_selinux_getctxbyname(char *pwname, const char *role) | ||
258 | { | ||
259 | security_context_t sc = NULL; | ||
260 | char *sename = NULL, *lvl = NULL; | ||
261 | @@ -71,9 +77,16 @@ ssh_selinux_getctxbyname(char *pwname) | ||
262 | #endif | ||
263 | |||
264 | #ifdef HAVE_GET_DEFAULT_CONTEXT_WITH_LEVEL | ||
265 | - r = get_default_context_with_level(sename, lvl, NULL, &sc); | ||
266 | + if (role != NULL && role[0]) | ||
267 | + r = get_default_context_with_rolelevel(sename, role, lvl, NULL, | ||
268 | + &sc); | ||
269 | + else | ||
270 | + r = get_default_context_with_level(sename, lvl, NULL, &sc); | ||
271 | #else | ||
272 | - r = get_default_context(sename, NULL, &sc); | ||
273 | + if (role != NULL && role[0]) | ||
274 | + r = get_default_context_with_role(sename, role, NULL, &sc); | ||
275 | + else | ||
276 | + r = get_default_context(sename, NULL, &sc); | ||
277 | #endif | ||
278 | |||
279 | if (r != 0) { | ||
280 | @@ -103,7 +116,7 @@ ssh_selinux_getctxbyname(char *pwname) | ||
281 | |||
282 | /* Set the execution context to the default for the specified user */ | ||
283 | void | ||
284 | -ssh_selinux_setup_exec_context(char *pwname) | ||
285 | +ssh_selinux_setup_exec_context(char *pwname, const char *role) | ||
286 | { | ||
287 | security_context_t user_ctx = NULL; | ||
288 | |||
289 | @@ -112,7 +125,7 @@ ssh_selinux_setup_exec_context(char *pwname) | ||
290 | |||
291 | debug3("%s: setting execution context", __func__); | ||
292 | |||
293 | - user_ctx = ssh_selinux_getctxbyname(pwname); | ||
294 | + user_ctx = ssh_selinux_getctxbyname(pwname, role); | ||
295 | if (setexeccon(user_ctx) != 0) { | ||
296 | switch (security_getenforce()) { | ||
297 | case -1: | ||
298 | @@ -134,7 +147,7 @@ ssh_selinux_setup_exec_context(char *pwname) | ||
299 | |||
300 | /* Set the TTY context for the specified user */ | ||
301 | void | ||
302 | -ssh_selinux_setup_pty(char *pwname, const char *tty) | ||
303 | +ssh_selinux_setup_pty(char *pwname, const char *tty, const char *role) | ||
304 | { | ||
305 | security_context_t new_tty_ctx = NULL; | ||
306 | security_context_t user_ctx = NULL; | ||
307 | @@ -145,7 +158,7 @@ ssh_selinux_setup_pty(char *pwname, const char *tty) | ||
308 | |||
309 | debug3("%s: setting TTY context on %s", __func__, tty); | ||
310 | |||
311 | - user_ctx = ssh_selinux_getctxbyname(pwname); | ||
312 | + user_ctx = ssh_selinux_getctxbyname(pwname, role); | ||
313 | |||
314 | /* XXX: should these calls fatal() upon failure in enforcing mode? */ | ||
315 | |||
316 | diff --git a/openbsd-compat/port-linux.h b/openbsd-compat/port-linux.h | ||
317 | index 3c22a854..c8812942 100644 | ||
318 | --- a/openbsd-compat/port-linux.h | ||
319 | +++ b/openbsd-compat/port-linux.h | ||
320 | @@ -19,8 +19,8 @@ | ||
321 | |||
322 | #ifdef WITH_SELINUX | ||
323 | int ssh_selinux_enabled(void); | ||
324 | -void ssh_selinux_setup_pty(char *, const char *); | ||
325 | -void ssh_selinux_setup_exec_context(char *); | ||
326 | +void ssh_selinux_setup_pty(char *, const char *, const char *); | ||
327 | +void ssh_selinux_setup_exec_context(char *, const char *); | ||
328 | void ssh_selinux_change_context(const char *); | ||
329 | void ssh_selinux_setfscreatecon(const char *); | ||
330 | #endif | ||
331 | diff --git a/platform.c b/platform.c | ||
332 | index 18c7751d..380ee3a4 100644 | ||
333 | --- a/platform.c | ||
334 | +++ b/platform.c | ||
335 | @@ -143,7 +143,7 @@ platform_setusercontext(struct passwd *pw) | ||
336 | * called if sshd is running as root. | ||
337 | */ | ||
338 | void | ||
339 | -platform_setusercontext_post_groups(struct passwd *pw) | ||
340 | +platform_setusercontext_post_groups(struct passwd *pw, const char *role) | ||
341 | { | ||
342 | #if !defined(HAVE_LOGIN_CAP) && defined(USE_PAM) | ||
343 | /* | ||
344 | @@ -184,7 +184,7 @@ platform_setusercontext_post_groups(struct passwd *pw) | ||
345 | } | ||
346 | #endif /* HAVE_SETPCRED */ | ||
347 | #ifdef WITH_SELINUX | ||
348 | - ssh_selinux_setup_exec_context(pw->pw_name); | ||
349 | + ssh_selinux_setup_exec_context(pw->pw_name, role); | ||
350 | #endif | ||
351 | } | ||
352 | |||
353 | diff --git a/platform.h b/platform.h | ||
354 | index ea4f9c58..60d72ffe 100644 | ||
355 | --- a/platform.h | ||
356 | +++ b/platform.h | ||
357 | @@ -25,7 +25,7 @@ void platform_post_fork_parent(pid_t child_pid); | ||
358 | void platform_post_fork_child(void); | ||
359 | int platform_privileged_uidswap(void); | ||
360 | void platform_setusercontext(struct passwd *); | ||
361 | -void platform_setusercontext_post_groups(struct passwd *); | ||
362 | +void platform_setusercontext_post_groups(struct passwd *, const char *); | ||
363 | char *platform_get_krb5_client(const char *); | ||
364 | char *platform_krb5_get_principal_name(const char *); | ||
365 | int platform_sys_dir_uid(uid_t); | ||
366 | diff --git a/session.c b/session.c | ||
367 | index 4bccb62d..d40afe4f 100644 | ||
368 | --- a/session.c | ||
369 | +++ b/session.c | ||
370 | @@ -1312,7 +1312,7 @@ safely_chroot(const char *path, uid_t uid) | ||
371 | |||
372 | /* Set login name, uid, gid, and groups. */ | ||
373 | void | ||
374 | -do_setusercontext(struct passwd *pw) | ||
375 | +do_setusercontext(struct passwd *pw, const char *role) | ||
376 | { | ||
377 | char *chroot_path, *tmp; | ||
378 | |||
379 | @@ -1340,7 +1340,7 @@ do_setusercontext(struct passwd *pw) | ||
380 | endgrent(); | ||
381 | #endif | ||
382 | |||
383 | - platform_setusercontext_post_groups(pw); | ||
384 | + platform_setusercontext_post_groups(pw, role); | ||
385 | |||
386 | if (!in_chroot && options.chroot_directory != NULL && | ||
387 | strcasecmp(options.chroot_directory, "none") != 0) { | ||
388 | @@ -1477,7 +1477,7 @@ do_child(struct ssh *ssh, Session *s, const char *command) | ||
389 | |||
390 | /* Force a password change */ | ||
391 | if (s->authctxt->force_pwchange) { | ||
392 | - do_setusercontext(pw); | ||
393 | + do_setusercontext(pw, s->authctxt->role); | ||
394 | child_close_fds(ssh); | ||
395 | do_pwchange(s); | ||
396 | exit(1); | ||
397 | @@ -1499,7 +1499,7 @@ do_child(struct ssh *ssh, Session *s, const char *command) | ||
398 | /* When PAM is enabled we rely on it to do the nologin check */ | ||
399 | if (!options.use_pam) | ||
400 | do_nologin(pw); | ||
401 | - do_setusercontext(pw); | ||
402 | + do_setusercontext(pw, s->authctxt->role); | ||
403 | /* | ||
404 | * PAM session modules in do_setusercontext may have | ||
405 | * generated messages, so if this in an interactive | ||
406 | @@ -1891,7 +1891,7 @@ session_pty_req(struct ssh *ssh, Session *s) | ||
407 | tty_parse_modes(s->ttyfd, &n_bytes); | ||
408 | |||
409 | if (!use_privsep) | ||
410 | - pty_setowner(s->pw, s->tty); | ||
411 | + pty_setowner(s->pw, s->tty, s->authctxt->role); | ||
412 | |||
413 | /* Set window size from the packet. */ | ||
414 | pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); | ||
415 | diff --git a/session.h b/session.h | ||
416 | index 54dd1f0c..8535ebce 100644 | ||
417 | --- a/session.h | ||
418 | +++ b/session.h | ||
419 | @@ -76,7 +76,7 @@ void session_pty_cleanup2(Session *); | ||
420 | Session *session_new(void); | ||
421 | Session *session_by_tty(char *); | ||
422 | void session_close(struct ssh *, Session *); | ||
423 | -void do_setusercontext(struct passwd *); | ||
424 | +void do_setusercontext(struct passwd *, const char *); | ||
425 | |||
426 | const char *session_get_remote_name_or_ip(struct ssh *, u_int, int); | ||
427 | |||
428 | diff --git a/sshd.c b/sshd.c | ||
429 | index a66e9ca6..af1ec337 100644 | ||
430 | --- a/sshd.c | ||
431 | +++ b/sshd.c | ||
432 | @@ -677,7 +677,7 @@ privsep_postauth(Authctxt *authctxt) | ||
433 | reseed_prngs(); | ||
434 | |||
435 | /* Drop privileges */ | ||
436 | - do_setusercontext(authctxt->pw); | ||
437 | + do_setusercontext(authctxt->pw, authctxt->role); | ||
438 | |||
439 | skip: | ||
440 | /* It is safe now to apply the key state */ | ||
441 | diff --git a/sshpty.c b/sshpty.c | ||
442 | index fe2fb5aa..feb22b06 100644 | ||
443 | --- a/sshpty.c | ||
444 | +++ b/sshpty.c | ||
445 | @@ -187,7 +187,7 @@ pty_change_window_size(int ptyfd, u_int row, u_int col, | ||
446 | } | ||
447 | |||
448 | void | ||
449 | -pty_setowner(struct passwd *pw, const char *tty) | ||
450 | +pty_setowner(struct passwd *pw, const char *tty, const char *role) | ||
451 | { | ||
452 | struct group *grp; | ||
453 | gid_t gid; | ||
454 | @@ -209,7 +209,7 @@ pty_setowner(struct passwd *pw, const char *tty) | ||
455 | strerror(errno)); | ||
456 | |||
457 | #ifdef WITH_SELINUX | ||
458 | - ssh_selinux_setup_pty(pw->pw_name, tty); | ||
459 | + ssh_selinux_setup_pty(pw->pw_name, tty, role); | ||
460 | #endif | ||
461 | |||
462 | if (st.st_uid != pw->pw_uid || st.st_gid != gid) { | ||
463 | diff --git a/sshpty.h b/sshpty.h | ||
464 | index 9ec7e9a1..de7e000a 100644 | ||
465 | --- a/sshpty.h | ||
466 | +++ b/sshpty.h | ||
467 | @@ -24,5 +24,5 @@ int pty_allocate(int *, int *, char *, size_t); | ||
468 | void pty_release(const char *); | ||
469 | void pty_make_controlling_tty(int *, const char *); | ||
470 | void pty_change_window_size(int, u_int, u_int, u_int, u_int); | ||
471 | -void pty_setowner(struct passwd *, const char *); | ||
472 | +void pty_setowner(struct passwd *, const char *, const char *); | ||
473 | void disconnect_controlling_tty(void); | ||
diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 000000000..01aa2c87c --- /dev/null +++ b/debian/patches/series | |||
@@ -0,0 +1,30 @@ | |||
1 | gssapi.patch | ||
2 | restore-tcp-wrappers.patch | ||
3 | selinux-role.patch | ||
4 | ssh-vulnkey-compat.patch | ||
5 | keepalive-extensions.patch | ||
6 | syslog-level-silent.patch | ||
7 | user-group-modes.patch | ||
8 | scp-quoting.patch | ||
9 | shell-path.patch | ||
10 | dnssec-sshfp.patch | ||
11 | auth-log-verbosity.patch | ||
12 | mention-ssh-keygen-on-keychange.patch | ||
13 | package-versioning.patch | ||
14 | debian-banner.patch | ||
15 | authorized-keys-man-symlink.patch | ||
16 | openbsd-docs.patch | ||
17 | ssh-argv0.patch | ||
18 | doc-hash-tab-completion.patch | ||
19 | ssh-agent-setgid.patch | ||
20 | no-openssl-version-status.patch | ||
21 | gnome-ssh-askpass2-icon.patch | ||
22 | systemd-readiness.patch | ||
23 | debian-config.patch | ||
24 | no-dsa-host-key-by-default.patch | ||
25 | restore-authorized_keys2.patch | ||
26 | seccomp-s390-flock-ipc.patch | ||
27 | seccomp-getuid-geteuid.patch | ||
28 | seccomp-s390-ioctl-ep11-crypto.patch | ||
29 | permitopen-argument-handling.patch | ||
30 | fix-regress-putty-transfer.patch | ||
diff --git a/debian/patches/shell-path.patch b/debian/patches/shell-path.patch new file mode 100644 index 000000000..29abf10f2 --- /dev/null +++ b/debian/patches/shell-path.patch | |||
@@ -0,0 +1,39 @@ | |||
1 | From c239ba6fa4560704a237779f82445d5f125847e1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:00 +0000 | ||
4 | Subject: Look for $SHELL on the path for ProxyCommand/LocalCommand | ||
5 | |||
6 | There's some debate on the upstream bug about whether POSIX requires this. | ||
7 | I (Colin Watson) agree with Vincent and think it does. | ||
8 | |||
9 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1494 | ||
10 | Bug-Debian: http://bugs.debian.org/492728 | ||
11 | Last-Update: 2013-09-14 | ||
12 | |||
13 | Patch-Name: shell-path.patch | ||
14 | --- | ||
15 | sshconnect.c | 4 ++-- | ||
16 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/sshconnect.c b/sshconnect.c | ||
19 | index dc7a704d..5eed5880 100644 | ||
20 | --- a/sshconnect.c | ||
21 | +++ b/sshconnect.c | ||
22 | @@ -235,7 +235,7 @@ ssh_proxy_connect(struct ssh *ssh, const char *host, u_short port, | ||
23 | /* Execute the proxy command. Note that we gave up any | ||
24 | extra privileges above. */ | ||
25 | signal(SIGPIPE, SIG_DFL); | ||
26 | - execv(argv[0], argv); | ||
27 | + execvp(argv[0], argv); | ||
28 | perror(argv[0]); | ||
29 | exit(1); | ||
30 | } | ||
31 | @@ -1435,7 +1435,7 @@ ssh_local_cmd(const char *args) | ||
32 | if (pid == 0) { | ||
33 | signal(SIGPIPE, SIG_DFL); | ||
34 | debug3("Executing %s -c \"%s\"", shell, args); | ||
35 | - execl(shell, shell, "-c", args, (char *)NULL); | ||
36 | + execlp(shell, shell, "-c", args, (char *)NULL); | ||
37 | error("Couldn't execute %s -c \"%s\": %s", | ||
38 | shell, args, strerror(errno)); | ||
39 | _exit(1); | ||
diff --git a/debian/patches/ssh-agent-setgid.patch b/debian/patches/ssh-agent-setgid.patch new file mode 100644 index 000000000..9ac4977b5 --- /dev/null +++ b/debian/patches/ssh-agent-setgid.patch | |||
@@ -0,0 +1,40 @@ | |||
1 | From b37d4f364f9c9bfbaf372e903ebbe80ef8ae2264 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:13 +0000 | ||
4 | Subject: Document consequences of ssh-agent being setgid in ssh-agent(1) | ||
5 | |||
6 | Bug-Debian: http://bugs.debian.org/711623 | ||
7 | Forwarded: no | ||
8 | Last-Update: 2013-06-08 | ||
9 | |||
10 | Patch-Name: ssh-agent-setgid.patch | ||
11 | --- | ||
12 | ssh-agent.1 | 15 +++++++++++++++ | ||
13 | 1 file changed, 15 insertions(+) | ||
14 | |||
15 | diff --git a/ssh-agent.1 b/ssh-agent.1 | ||
16 | index 83b2b41c..7230704a 100644 | ||
17 | --- a/ssh-agent.1 | ||
18 | +++ b/ssh-agent.1 | ||
19 | @@ -206,6 +206,21 @@ environment variable holds the agent's process ID. | ||
20 | .Pp | ||
21 | The agent exits automatically when the command given on the command | ||
22 | line terminates. | ||
23 | +.Pp | ||
24 | +In Debian, | ||
25 | +.Nm | ||
26 | +is installed with the set-group-id bit set, to prevent | ||
27 | +.Xr ptrace 2 | ||
28 | +attacks retrieving private key material. | ||
29 | +This has the side-effect of causing the run-time linker to remove certain | ||
30 | +environment variables which might have security implications for set-id | ||
31 | +programs, including | ||
32 | +.Ev LD_PRELOAD , | ||
33 | +.Ev LD_LIBRARY_PATH , | ||
34 | +and | ||
35 | +.Ev TMPDIR . | ||
36 | +If you need to set any of these environment variables, you will need to do | ||
37 | +so in the program executed by ssh-agent. | ||
38 | .Sh FILES | ||
39 | .Bl -tag -width Ds | ||
40 | .It Pa $TMPDIR/ssh-XXXXXXXXXX/agent.<ppid> | ||
diff --git a/debian/patches/ssh-argv0.patch b/debian/patches/ssh-argv0.patch new file mode 100644 index 000000000..3a560ad78 --- /dev/null +++ b/debian/patches/ssh-argv0.patch | |||
@@ -0,0 +1,31 @@ | |||
1 | From 7e5cf5d27a7be47203280c665ca7311269f53671 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:10 +0000 | ||
4 | Subject: ssh(1): Refer to ssh-argv0(1) | ||
5 | |||
6 | Old versions of OpenSSH (up to 2.5 or thereabouts) allowed creating symlinks | ||
7 | to ssh with the name of the host you want to connect to. Debian ships an | ||
8 | ssh-argv0 script restoring this feature; this patch refers to its manual | ||
9 | page from ssh(1). | ||
10 | |||
11 | Bug-Debian: http://bugs.debian.org/111341 | ||
12 | Forwarded: not-needed | ||
13 | Last-Update: 2013-09-14 | ||
14 | |||
15 | Patch-Name: ssh-argv0.patch | ||
16 | --- | ||
17 | ssh.1 | 1 + | ||
18 | 1 file changed, 1 insertion(+) | ||
19 | |||
20 | diff --git a/ssh.1 b/ssh.1 | ||
21 | index 2a2aab30..711fe608 100644 | ||
22 | --- a/ssh.1 | ||
23 | +++ b/ssh.1 | ||
24 | @@ -1556,6 +1556,7 @@ if an error occurred. | ||
25 | .Xr sftp 1 , | ||
26 | .Xr ssh-add 1 , | ||
27 | .Xr ssh-agent 1 , | ||
28 | +.Xr ssh-argv0 1 , | ||
29 | .Xr ssh-keygen 1 , | ||
30 | .Xr ssh-keyscan 1 , | ||
31 | .Xr tun 4 , | ||
diff --git a/debian/patches/ssh-vulnkey-compat.patch b/debian/patches/ssh-vulnkey-compat.patch new file mode 100644 index 000000000..ef1ce4e99 --- /dev/null +++ b/debian/patches/ssh-vulnkey-compat.patch | |||
@@ -0,0 +1,42 @@ | |||
1 | From 19971fb92159a621b55f0b9da76dd38a56d7247c Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@ubuntu.com> | ||
3 | Date: Sun, 9 Feb 2014 16:09:50 +0000 | ||
4 | Subject: Accept obsolete ssh-vulnkey configuration options | ||
5 | |||
6 | These options were used as part of Debian's response to CVE-2008-0166. | ||
7 | Nearly six years later, we no longer need to continue carrying the bulk | ||
8 | of that patch, but we do need to avoid failing when the associated | ||
9 | configuration options are still present. | ||
10 | |||
11 | Last-Update: 2014-02-09 | ||
12 | |||
13 | Patch-Name: ssh-vulnkey-compat.patch | ||
14 | --- | ||
15 | readconf.c | 1 + | ||
16 | servconf.c | 1 + | ||
17 | 2 files changed, 2 insertions(+) | ||
18 | |||
19 | diff --git a/readconf.c b/readconf.c | ||
20 | index 99e03ee1..d2b28a41 100644 | ||
21 | --- a/readconf.c | ||
22 | +++ b/readconf.c | ||
23 | @@ -189,6 +189,7 @@ static struct { | ||
24 | { "fallbacktorsh", oDeprecated }, | ||
25 | { "globalknownhostsfile2", oDeprecated }, | ||
26 | { "rhostsauthentication", oDeprecated }, | ||
27 | + { "useblacklistedkeys", oDeprecated }, | ||
28 | { "userknownhostsfile2", oDeprecated }, | ||
29 | { "useroaming", oDeprecated }, | ||
30 | { "usersh", oDeprecated }, | ||
31 | diff --git a/servconf.c b/servconf.c | ||
32 | index 8ba74517..9889fb0a 100644 | ||
33 | --- a/servconf.c | ||
34 | +++ b/servconf.c | ||
35 | @@ -525,6 +525,7 @@ static struct { | ||
36 | { "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL }, | ||
37 | { "xauthlocation", sXAuthLocation, SSHCFG_GLOBAL }, | ||
38 | { "strictmodes", sStrictModes, SSHCFG_GLOBAL }, | ||
39 | + { "permitblacklistedkeys", sDeprecated, SSHCFG_GLOBAL }, | ||
40 | { "permitemptypasswords", sEmptyPasswd, SSHCFG_ALL }, | ||
41 | { "permituserenvironment", sPermitUserEnvironment, SSHCFG_GLOBAL }, | ||
42 | { "uselogin", sDeprecated, SSHCFG_GLOBAL }, | ||
diff --git a/debian/patches/syslog-level-silent.patch b/debian/patches/syslog-level-silent.patch new file mode 100644 index 000000000..3ed6287a9 --- /dev/null +++ b/debian/patches/syslog-level-silent.patch | |||
@@ -0,0 +1,47 @@ | |||
1 | From 215bd91f12b0ddb9754483ee6e3c3b4751256dca Mon Sep 17 00:00:00 2001 | ||
2 | From: Jonathan David Amery <jdamery@ysolde.ucam.org> | ||
3 | Date: Sun, 9 Feb 2014 16:09:54 +0000 | ||
4 | Subject: "LogLevel SILENT" compatibility | ||
5 | |||
6 | "LogLevel SILENT" (-qq) was introduced in Debian openssh 1:3.0.1p1-1 to | ||
7 | match the behaviour of non-free SSH, in which -q does not suppress fatal | ||
8 | errors. However, this was unintentionally broken in 1:4.6p1-2 and nobody | ||
9 | complained, so we've dropped most of it. The parts that remain are basic | ||
10 | configuration file compatibility, and an adjustment to "Pseudo-terminal will | ||
11 | not be allocated ..." which should be split out into a separate patch. | ||
12 | |||
13 | Author: Matthew Vernon <matthew@debian.org> | ||
14 | Author: Colin Watson <cjwatson@debian.org> | ||
15 | Last-Update: 2013-09-14 | ||
16 | |||
17 | Patch-Name: syslog-level-silent.patch | ||
18 | --- | ||
19 | log.c | 1 + | ||
20 | ssh.c | 2 +- | ||
21 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
22 | |||
23 | diff --git a/log.c b/log.c | ||
24 | index 99450dd1..1559091d 100644 | ||
25 | --- a/log.c | ||
26 | +++ b/log.c | ||
27 | @@ -93,6 +93,7 @@ static struct { | ||
28 | LogLevel val; | ||
29 | } log_levels[] = | ||
30 | { | ||
31 | + { "SILENT", SYSLOG_LEVEL_QUIET }, /* compatibility */ | ||
32 | { "QUIET", SYSLOG_LEVEL_QUIET }, | ||
33 | { "FATAL", SYSLOG_LEVEL_FATAL }, | ||
34 | { "ERROR", SYSLOG_LEVEL_ERROR }, | ||
35 | diff --git a/ssh.c b/ssh.c | ||
36 | index ae37432b..9cb21171 100644 | ||
37 | --- a/ssh.c | ||
38 | +++ b/ssh.c | ||
39 | @@ -1166,7 +1166,7 @@ main(int ac, char **av) | ||
40 | /* Do not allocate a tty if stdin is not a tty. */ | ||
41 | if ((!isatty(fileno(stdin)) || stdin_null_flag) && | ||
42 | options.request_tty != REQUEST_TTY_FORCE) { | ||
43 | - if (tty_flag) | ||
44 | + if (tty_flag && options.log_level != SYSLOG_LEVEL_QUIET) | ||
45 | logit("Pseudo-terminal will not be allocated because " | ||
46 | "stdin is not a terminal."); | ||
47 | tty_flag = 0; | ||
diff --git a/debian/patches/systemd-readiness.patch b/debian/patches/systemd-readiness.patch new file mode 100644 index 000000000..537a5cab6 --- /dev/null +++ b/debian/patches/systemd-readiness.patch | |||
@@ -0,0 +1,84 @@ | |||
1 | From ba3f6b85ede72ef42987f0069f5ed2b88ebe69fd Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Biebl <biebl@debian.org> | ||
3 | Date: Mon, 21 Dec 2015 16:08:47 +0000 | ||
4 | Subject: Add systemd readiness notification support | ||
5 | |||
6 | Bug-Debian: https://bugs.debian.org/778913 | ||
7 | Forwarded: no | ||
8 | Last-Update: 2017-08-22 | ||
9 | |||
10 | Patch-Name: systemd-readiness.patch | ||
11 | --- | ||
12 | configure.ac | 24 ++++++++++++++++++++++++ | ||
13 | sshd.c | 9 +++++++++ | ||
14 | 2 files changed, 33 insertions(+) | ||
15 | |||
16 | diff --git a/configure.ac b/configure.ac | ||
17 | index 3b30736b..483a9038 100644 | ||
18 | --- a/configure.ac | ||
19 | +++ b/configure.ac | ||
20 | @@ -4389,6 +4389,29 @@ AC_ARG_WITH([kerberos5], | ||
21 | AC_SUBST([GSSLIBS]) | ||
22 | AC_SUBST([K5LIBS]) | ||
23 | |||
24 | +# Check whether user wants systemd support | ||
25 | +SYSTEMD_MSG="no" | ||
26 | +AC_ARG_WITH(systemd, | ||
27 | + [ --with-systemd Enable systemd support], | ||
28 | + [ if test "x$withval" != "xno" ; then | ||
29 | + AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no]) | ||
30 | + if test "$PKGCONFIG" != "no"; then | ||
31 | + AC_MSG_CHECKING([for libsystemd]) | ||
32 | + if $PKGCONFIG --exists libsystemd; then | ||
33 | + SYSTEMD_CFLAGS=`$PKGCONFIG --cflags libsystemd` | ||
34 | + SYSTEMD_LIBS=`$PKGCONFIG --libs libsystemd` | ||
35 | + CPPFLAGS="$CPPFLAGS $SYSTEMD_CFLAGS" | ||
36 | + SSHDLIBS="$SSHDLIBS $SYSTEMD_LIBS" | ||
37 | + AC_MSG_RESULT([yes]) | ||
38 | + AC_DEFINE(HAVE_SYSTEMD, 1, [Define if you want systemd support.]) | ||
39 | + SYSTEMD_MSG="yes" | ||
40 | + else | ||
41 | + AC_MSG_RESULT([no]) | ||
42 | + fi | ||
43 | + fi | ||
44 | + fi ] | ||
45 | +) | ||
46 | + | ||
47 | # Looking for programs, paths and files | ||
48 | |||
49 | PRIVSEP_PATH=/var/empty | ||
50 | @@ -5196,6 +5219,7 @@ echo " libldns support: $LDNS_MSG" | ||
51 | echo " Solaris process contract support: $SPC_MSG" | ||
52 | echo " Solaris project support: $SP_MSG" | ||
53 | echo " Solaris privilege support: $SPP_MSG" | ||
54 | +echo " systemd support: $SYSTEMD_MSG" | ||
55 | echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG" | ||
56 | echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" | ||
57 | echo " BSD Auth support: $BSD_AUTH_MSG" | ||
58 | diff --git a/sshd.c b/sshd.c | ||
59 | index a5a1193d..1fde5a63 100644 | ||
60 | --- a/sshd.c | ||
61 | +++ b/sshd.c | ||
62 | @@ -85,6 +85,10 @@ | ||
63 | #include <prot.h> | ||
64 | #endif | ||
65 | |||
66 | +#ifdef HAVE_SYSTEMD | ||
67 | +#include <systemd/sd-daemon.h> | ||
68 | +#endif | ||
69 | + | ||
70 | #include "xmalloc.h" | ||
71 | #include "ssh.h" | ||
72 | #include "ssh2.h" | ||
73 | @@ -1881,6 +1885,11 @@ main(int ac, char **av) | ||
74 | } | ||
75 | } | ||
76 | |||
77 | +#ifdef HAVE_SYSTEMD | ||
78 | + /* Signal systemd that we are ready to accept connections */ | ||
79 | + sd_notify(0, "READY=1"); | ||
80 | +#endif | ||
81 | + | ||
82 | /* Accept a connection and return in a forked child */ | ||
83 | server_accept_loop(&sock_in, &sock_out, | ||
84 | &newsock, config_s); | ||
diff --git a/debian/patches/user-group-modes.patch b/debian/patches/user-group-modes.patch new file mode 100644 index 000000000..338c7567d --- /dev/null +++ b/debian/patches/user-group-modes.patch | |||
@@ -0,0 +1,210 @@ | |||
1 | From b1033fed87fd9fa24dccab45f00cadcbc7144c47 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:09:58 +0000 | ||
4 | Subject: Allow harmless group-writability | ||
5 | |||
6 | Allow secure files (~/.ssh/config, ~/.ssh/authorized_keys, etc.) to be | ||
7 | group-writable, provided that the group in question contains only the file's | ||
8 | owner. Rejected upstream for IMO incorrect reasons (e.g. a misunderstanding | ||
9 | about the contents of gr->gr_mem). Given that per-user groups and umask 002 | ||
10 | are the default setup in Debian (for good reasons - this makes operating in | ||
11 | setgid directories with other groups much easier), we need to permit this by | ||
12 | default. | ||
13 | |||
14 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1060 | ||
15 | Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=314347 | ||
16 | Last-Update: 2017-10-04 | ||
17 | |||
18 | Patch-Name: user-group-modes.patch | ||
19 | --- | ||
20 | auth-rhosts.c | 6 ++---- | ||
21 | auth.c | 3 +-- | ||
22 | misc.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- | ||
23 | misc.h | 2 ++ | ||
24 | readconf.c | 3 +-- | ||
25 | ssh.1 | 2 ++ | ||
26 | ssh_config.5 | 2 ++ | ||
27 | 7 files changed, 63 insertions(+), 13 deletions(-) | ||
28 | |||
29 | diff --git a/auth-rhosts.c b/auth-rhosts.c | ||
30 | index ecf956f0..4dccd5e6 100644 | ||
31 | --- a/auth-rhosts.c | ||
32 | +++ b/auth-rhosts.c | ||
33 | @@ -261,8 +261,7 @@ auth_rhosts2(struct passwd *pw, const char *client_user, const char *hostname, | ||
34 | return 0; | ||
35 | } | ||
36 | if (options.strict_modes && | ||
37 | - ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || | ||
38 | - (st.st_mode & 022) != 0)) { | ||
39 | + !secure_permissions(&st, pw->pw_uid)) { | ||
40 | logit("Rhosts authentication refused for %.100s: " | ||
41 | "bad ownership or modes for home directory.", pw->pw_name); | ||
42 | auth_debug_add("Rhosts authentication refused for %.100s: " | ||
43 | @@ -288,8 +287,7 @@ auth_rhosts2(struct passwd *pw, const char *client_user, const char *hostname, | ||
44 | * allowing access to their account by anyone. | ||
45 | */ | ||
46 | if (options.strict_modes && | ||
47 | - ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || | ||
48 | - (st.st_mode & 022) != 0)) { | ||
49 | + !secure_permissions(&st, pw->pw_uid)) { | ||
50 | logit("Rhosts authentication refused for %.100s: bad modes for %.200s", | ||
51 | pw->pw_name, buf); | ||
52 | auth_debug_add("Bad file modes for %.200s", buf); | ||
53 | diff --git a/auth.c b/auth.c | ||
54 | index 6aec3605..68a1e4a7 100644 | ||
55 | --- a/auth.c | ||
56 | +++ b/auth.c | ||
57 | @@ -467,8 +467,7 @@ check_key_in_hostfiles(struct passwd *pw, struct sshkey *key, const char *host, | ||
58 | user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); | ||
59 | if (options.strict_modes && | ||
60 | (stat(user_hostfile, &st) == 0) && | ||
61 | - ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || | ||
62 | - (st.st_mode & 022) != 0)) { | ||
63 | + !secure_permissions(&st, pw->pw_uid)) { | ||
64 | logit("Authentication refused for %.100s: " | ||
65 | "bad owner or modes for %.200s", | ||
66 | pw->pw_name, user_hostfile); | ||
67 | diff --git a/misc.c b/misc.c | ||
68 | index 05950a47..40aeeef3 100644 | ||
69 | --- a/misc.c | ||
70 | +++ b/misc.c | ||
71 | @@ -57,8 +57,9 @@ | ||
72 | #include <netdb.h> | ||
73 | #ifdef HAVE_PATHS_H | ||
74 | # include <paths.h> | ||
75 | -#include <pwd.h> | ||
76 | #endif | ||
77 | +#include <pwd.h> | ||
78 | +#include <grp.h> | ||
79 | #ifdef SSH_TUN_OPENBSD | ||
80 | #include <net/if.h> | ||
81 | #endif | ||
82 | @@ -723,6 +724,55 @@ read_keyfile_line(FILE *f, const char *filename, char *buf, size_t bufsz, | ||
83 | return -1; | ||
84 | } | ||
85 | |||
86 | +int | ||
87 | +secure_permissions(struct stat *st, uid_t uid) | ||
88 | +{ | ||
89 | + if (!platform_sys_dir_uid(st->st_uid) && st->st_uid != uid) | ||
90 | + return 0; | ||
91 | + if ((st->st_mode & 002) != 0) | ||
92 | + return 0; | ||
93 | + if ((st->st_mode & 020) != 0) { | ||
94 | + /* If the file is group-writable, the group in question must | ||
95 | + * have exactly one member, namely the file's owner. | ||
96 | + * (Zero-member groups are typically used by setgid | ||
97 | + * binaries, and are unlikely to be suitable.) | ||
98 | + */ | ||
99 | + struct passwd *pw; | ||
100 | + struct group *gr; | ||
101 | + int members = 0; | ||
102 | + | ||
103 | + gr = getgrgid(st->st_gid); | ||
104 | + if (!gr) | ||
105 | + return 0; | ||
106 | + | ||
107 | + /* Check primary group memberships. */ | ||
108 | + while ((pw = getpwent()) != NULL) { | ||
109 | + if (pw->pw_gid == gr->gr_gid) { | ||
110 | + ++members; | ||
111 | + if (pw->pw_uid != uid) | ||
112 | + return 0; | ||
113 | + } | ||
114 | + } | ||
115 | + endpwent(); | ||
116 | + | ||
117 | + pw = getpwuid(st->st_uid); | ||
118 | + if (!pw) | ||
119 | + return 0; | ||
120 | + | ||
121 | + /* Check supplementary group memberships. */ | ||
122 | + if (gr->gr_mem[0]) { | ||
123 | + ++members; | ||
124 | + if (strcmp(pw->pw_name, gr->gr_mem[0]) || | ||
125 | + gr->gr_mem[1]) | ||
126 | + return 0; | ||
127 | + } | ||
128 | + | ||
129 | + if (!members) | ||
130 | + return 0; | ||
131 | + } | ||
132 | + return 1; | ||
133 | +} | ||
134 | + | ||
135 | int | ||
136 | tun_open(int tun, int mode) | ||
137 | { | ||
138 | @@ -1626,8 +1676,7 @@ safe_path(const char *name, struct stat *stp, const char *pw_dir, | ||
139 | snprintf(err, errlen, "%s is not a regular file", buf); | ||
140 | return -1; | ||
141 | } | ||
142 | - if ((!platform_sys_dir_uid(stp->st_uid) && stp->st_uid != uid) || | ||
143 | - (stp->st_mode & 022) != 0) { | ||
144 | + if (!secure_permissions(stp, uid)) { | ||
145 | snprintf(err, errlen, "bad ownership or modes for file %s", | ||
146 | buf); | ||
147 | return -1; | ||
148 | @@ -1642,8 +1691,7 @@ safe_path(const char *name, struct stat *stp, const char *pw_dir, | ||
149 | strlcpy(buf, cp, sizeof(buf)); | ||
150 | |||
151 | if (stat(buf, &st) < 0 || | ||
152 | - (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) || | ||
153 | - (st.st_mode & 022) != 0) { | ||
154 | + !secure_permissions(&st, uid)) { | ||
155 | snprintf(err, errlen, | ||
156 | "bad ownership or modes for directory %s", buf); | ||
157 | return -1; | ||
158 | diff --git a/misc.h b/misc.h | ||
159 | index 153d1137..d8759ab1 100644 | ||
160 | --- a/misc.h | ||
161 | +++ b/misc.h | ||
162 | @@ -163,6 +163,8 @@ char *read_passphrase(const char *, int); | ||
163 | int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2))); | ||
164 | int read_keyfile_line(FILE *, const char *, char *, size_t, u_long *); | ||
165 | |||
166 | +int secure_permissions(struct stat *st, uid_t uid); | ||
167 | + | ||
168 | #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) | ||
169 | #define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) | ||
170 | #define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y)) | ||
171 | diff --git a/readconf.c b/readconf.c | ||
172 | index 45caa095..be3d5873 100644 | ||
173 | --- a/readconf.c | ||
174 | +++ b/readconf.c | ||
175 | @@ -1766,8 +1766,7 @@ read_config_file_depth(const char *filename, struct passwd *pw, | ||
176 | |||
177 | if (fstat(fileno(f), &sb) == -1) | ||
178 | fatal("fstat %s: %s", filename, strerror(errno)); | ||
179 | - if (((sb.st_uid != 0 && sb.st_uid != getuid()) || | ||
180 | - (sb.st_mode & 022) != 0)) | ||
181 | + if (!secure_permissions(&sb, getuid())) | ||
182 | fatal("Bad owner or permissions on %s", filename); | ||
183 | } | ||
184 | |||
185 | diff --git a/ssh.1 b/ssh.1 | ||
186 | index 2ab1697f..3cc94688 100644 | ||
187 | --- a/ssh.1 | ||
188 | +++ b/ssh.1 | ||
189 | @@ -1456,6 +1456,8 @@ The file format and configuration options are described in | ||
190 | .Xr ssh_config 5 . | ||
191 | Because of the potential for abuse, this file must have strict permissions: | ||
192 | read/write for the user, and not writable by others. | ||
193 | +It may be group-writable provided that the group in question contains only | ||
194 | +the user. | ||
195 | .Pp | ||
196 | .It Pa ~/.ssh/environment | ||
197 | Contains additional definitions for environment variables; see | ||
198 | diff --git a/ssh_config.5 b/ssh_config.5 | ||
199 | index d6f43c2d..7810a418 100644 | ||
200 | --- a/ssh_config.5 | ||
201 | +++ b/ssh_config.5 | ||
202 | @@ -1786,6 +1786,8 @@ The format of this file is described above. | ||
203 | This file is used by the SSH client. | ||
204 | Because of the potential for abuse, this file must have strict permissions: | ||
205 | read/write for the user, and not accessible by others. | ||
206 | +It may be group-writable provided that the group in question contains only | ||
207 | +the user. | ||
208 | .It Pa /etc/ssh/ssh_config | ||
209 | Systemwide configuration file. | ||
210 | This file provides defaults for those | ||