diff options
Diffstat (limited to 'debian/patches')
34 files changed, 6282 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..1b52fd4cc --- /dev/null +++ b/debian/patches/auth-log-verbosity.patch | |||
@@ -0,0 +1,133 @@ | |||
1 | From ee78b163ac7fe57b819e8ddf84b32e67b6a950a3 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: 2013-09-14 | ||
9 | |||
10 | Patch-Name: auth-log-verbosity.patch | ||
11 | --- | ||
12 | auth-options.c | 35 ++++++++++++++++++++++++++--------- | ||
13 | auth-options.h | 1 + | ||
14 | auth-rsa.c | 2 ++ | ||
15 | auth2-pubkey.c | 3 +++ | ||
16 | 4 files changed, 32 insertions(+), 9 deletions(-) | ||
17 | |||
18 | diff --git a/auth-options.c b/auth-options.c | ||
19 | index facfc02..9ab1880 100644 | ||
20 | --- a/auth-options.c | ||
21 | +++ b/auth-options.c | ||
22 | @@ -58,9 +58,20 @@ int forced_tun_device = -1; | ||
23 | /* "principals=" option. */ | ||
24 | char *authorized_principals = NULL; | ||
25 | |||
26 | +/* Throttle log messages. */ | ||
27 | +int logged_from_hostip = 0; | ||
28 | +int logged_cert_hostip = 0; | ||
29 | + | ||
30 | extern ServerOptions options; | ||
31 | |||
32 | void | ||
33 | +auth_start_parse_options(void) | ||
34 | +{ | ||
35 | + logged_from_hostip = 0; | ||
36 | + logged_cert_hostip = 0; | ||
37 | +} | ||
38 | + | ||
39 | +void | ||
40 | auth_clear_options(void) | ||
41 | { | ||
42 | no_agent_forwarding_flag = 0; | ||
43 | @@ -293,10 +304,13 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) | ||
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 | @@ -519,11 +533,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 34852e5..1653855 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 *, char *, u_long); | ||
91 | void auth_clear_options(void); | ||
92 | int auth_cert_options(struct sshkey *, struct passwd *); | ||
93 | diff --git a/auth-rsa.c b/auth-rsa.c | ||
94 | index cbd971b..4cf2163 100644 | ||
95 | --- a/auth-rsa.c | ||
96 | +++ b/auth-rsa.c | ||
97 | @@ -181,6 +181,8 @@ rsa_key_allowed_in_file(struct passwd *pw, char *file, | ||
98 | if ((f = auth_openkeyfile(file, pw, options.strict_modes)) == NULL) | ||
99 | return 0; | ||
100 | |||
101 | + auth_start_parse_options(); | ||
102 | + | ||
103 | /* | ||
104 | * Go though the accepted keys, looking for the current key. If | ||
105 | * found, perform a challenge-response dialog to verify that the | ||
106 | diff --git a/auth2-pubkey.c b/auth2-pubkey.c | ||
107 | index 5aa319c..1eee161 100644 | ||
108 | --- a/auth2-pubkey.c | ||
109 | +++ b/auth2-pubkey.c | ||
110 | @@ -561,6 +561,7 @@ process_principals(FILE *f, char *file, struct passwd *pw, | ||
111 | u_long linenum = 0; | ||
112 | u_int i; | ||
113 | |||
114 | + auth_start_parse_options(); | ||
115 | while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) { | ||
116 | /* Skip leading whitespace. */ | ||
117 | for (cp = line; *cp == ' ' || *cp == '\t'; cp++) | ||
118 | @@ -726,6 +727,7 @@ check_authkeys_file(FILE *f, char *file, Key* key, struct passwd *pw) | ||
119 | found_key = 0; | ||
120 | |||
121 | found = NULL; | ||
122 | + auth_start_parse_options(); | ||
123 | while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) { | ||
124 | char *cp, *key_options = NULL; | ||
125 | if (found != NULL) | ||
126 | @@ -872,6 +874,7 @@ user_cert_trusted_ca(struct passwd *pw, Key *key) | ||
127 | if (key_cert_check_authority(key, 0, 1, | ||
128 | use_authorized_principals ? NULL : pw->pw_name, &reason) != 0) | ||
129 | goto fail_reason; | ||
130 | + auth_start_parse_options(); | ||
131 | if (auth_cert_options(key, pw) != 0) | ||
132 | goto out; | ||
133 | |||
diff --git a/debian/patches/authorized-keys-man-symlink.patch b/debian/patches/authorized-keys-man-symlink.patch new file mode 100644 index 000000000..e2f08085e --- /dev/null +++ b/debian/patches/authorized-keys-man-symlink.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | From 4a7ce48c3db45ebb9cb76fe21fc9e8811a43d840 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 c406aec..37cb023 100644 | ||
17 | --- a/Makefile.in | ||
18 | +++ b/Makefile.in | ||
19 | @@ -325,6 +325,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/backport-do-not-resend-username-to-pam.patch b/debian/patches/backport-do-not-resend-username-to-pam.patch new file mode 100644 index 000000000..24b7ce271 --- /dev/null +++ b/debian/patches/backport-do-not-resend-username-to-pam.patch | |||
@@ -0,0 +1,43 @@ | |||
1 | From f84305e9391e13c01a78df0d93e2edd40c14f601 Mon Sep 17 00:00:00 2001 | ||
2 | From: Damien Miller <djm@mindrot.org> | ||
3 | Date: Tue, 11 Aug 2015 13:33:24 +1000 | ||
4 | Subject: Don't resend username to PAM; it already has it. | ||
5 | |||
6 | Pointed out by Moritz Jodeit; ok dtucker@ | ||
7 | |||
8 | Origin: upstream, https://anongit.mindrot.org/openssh.git/commit/?id=d4697fe9a28dab7255c60433e4dd23cf7fce8a8b | ||
9 | Forwarded: not-needed | ||
10 | Last-Update: 2015-08-19 | ||
11 | |||
12 | Patch-Name: backport-do-not-resend-username-to-pam.patch | ||
13 | --- | ||
14 | monitor.c | 2 -- | ||
15 | monitor_wrap.c | 1 - | ||
16 | 2 files changed, 3 deletions(-) | ||
17 | |||
18 | diff --git a/monitor.c b/monitor.c | ||
19 | index 12ed6fd..870a6b9 100644 | ||
20 | --- a/monitor.c | ||
21 | +++ b/monitor.c | ||
22 | @@ -1143,9 +1143,7 @@ extern KbdintDevice sshpam_device; | ||
23 | int | ||
24 | mm_answer_pam_init_ctx(int sock, Buffer *m) | ||
25 | { | ||
26 | - | ||
27 | debug3("%s", __func__); | ||
28 | - authctxt->user = buffer_get_string(m, NULL); | ||
29 | sshpam_ctxt = (sshpam_device.init_ctx)(authctxt); | ||
30 | sshpam_authok = NULL; | ||
31 | buffer_clear(m); | ||
32 | diff --git a/monitor_wrap.c b/monitor_wrap.c | ||
33 | index 2a0fe9b..e2fcf75 100644 | ||
34 | --- a/monitor_wrap.c | ||
35 | +++ b/monitor_wrap.c | ||
36 | @@ -632,7 +632,6 @@ mm_sshpam_init_ctx(Authctxt *authctxt) | ||
37 | |||
38 | debug3("%s", __func__); | ||
39 | buffer_init(&m); | ||
40 | - buffer_put_cstring(&m, authctxt->user); | ||
41 | mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_INIT_CTX, &m); | ||
42 | debug3("%s: waiting for MONITOR_ANS_PAM_INIT_CTX", __func__); | ||
43 | mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_INIT_CTX, &m); | ||
diff --git a/debian/patches/backport-fix-pty-permissions.patch b/debian/patches/backport-fix-pty-permissions.patch new file mode 100644 index 000000000..cbd5a12c4 --- /dev/null +++ b/debian/patches/backport-fix-pty-permissions.patch | |||
@@ -0,0 +1,33 @@ | |||
1 | From bf3247821b4335eddd22664b0e1b30393ba31415 Mon Sep 17 00:00:00 2001 | ||
2 | From: "djm@openbsd.org" <djm@openbsd.org> | ||
3 | Date: Thu, 30 Jul 2015 23:09:15 +0000 | ||
4 | Subject: Fix pty permissions | ||
5 | |||
6 | Origin: upstream, https://anongit.mindrot.org/openssh.git/commit/?id=6f941396b6835ad18018845f515b0c4fe20be21a | ||
7 | Forwarded: not-needed | ||
8 | Last-Update: 2015-08-19 | ||
9 | |||
10 | Patch-Name: backport-fix-pty-permissions.patch | ||
11 | --- | ||
12 | sshpty.c | 4 ++-- | ||
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/sshpty.c b/sshpty.c | ||
16 | index 0e32b39..e89efb7 100644 | ||
17 | --- a/sshpty.c | ||
18 | +++ b/sshpty.c | ||
19 | @@ -1,4 +1,4 @@ | ||
20 | -/* $OpenBSD: sshpty.c,v 1.29 2014/09/03 18:55:07 djm Exp $ */ | ||
21 | +/* $OpenBSD: sshpty.c,v 1.30 2015/07/30 23:09:15 djm Exp $ */ | ||
22 | /* | ||
23 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | ||
24 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | ||
25 | @@ -197,7 +197,7 @@ pty_setowner(struct passwd *pw, const char *tty, const char *role) | ||
26 | /* Determine the group to make the owner of the tty. */ | ||
27 | grp = getgrnam("tty"); | ||
28 | gid = (grp != NULL) ? grp->gr_gid : pw->pw_gid; | ||
29 | - mode = (grp != NULL) ? 0622 : 0600; | ||
30 | + mode = (grp != NULL) ? 0620 : 0600; | ||
31 | |||
32 | /* | ||
33 | * Change owner and mode of the tty as required. | ||
diff --git a/debian/patches/backport-kbdint-duplicates.patch b/debian/patches/backport-kbdint-duplicates.patch new file mode 100644 index 000000000..c7e395d86 --- /dev/null +++ b/debian/patches/backport-kbdint-duplicates.patch | |||
@@ -0,0 +1,53 @@ | |||
1 | From 5c0c1192be30b7c0e60d96b5e6739c4ad49f087b Mon Sep 17 00:00:00 2001 | ||
2 | From: "djm@openbsd.org" <djm@openbsd.org> | ||
3 | Date: Sat, 18 Jul 2015 07:57:14 +0000 | ||
4 | Subject: only query each keyboard-interactive device once per authentication | ||
5 | request regardless of how many times it is listed | ||
6 | |||
7 | ok markus@ | ||
8 | |||
9 | Origin: upstream, https://anongit.mindrot.org/openssh.git/commit/?id=5b64f85bb811246c59ebab70aed331f26ba37b18 | ||
10 | Forwarded: not-needed | ||
11 | Last-Update: 2015-08-19 | ||
12 | |||
13 | Patch-Name: backport-kbdint-duplicates.patch | ||
14 | --- | ||
15 | auth2-chall.c | 11 ++++++++--- | ||
16 | 1 file changed, 8 insertions(+), 3 deletions(-) | ||
17 | |||
18 | diff --git a/auth2-chall.c b/auth2-chall.c | ||
19 | index ddabe1a..4aff09d 100644 | ||
20 | --- a/auth2-chall.c | ||
21 | +++ b/auth2-chall.c | ||
22 | @@ -1,4 +1,4 @@ | ||
23 | -/* $OpenBSD: auth2-chall.c,v 1.42 2015/01/19 20:07:45 markus Exp $ */ | ||
24 | +/* $OpenBSD: auth2-chall.c,v 1.43 2015/07/18 07:57:14 djm Exp $ */ | ||
25 | /* | ||
26 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | ||
27 | * Copyright (c) 2001 Per Allansson. All rights reserved. | ||
28 | @@ -83,6 +83,7 @@ struct KbdintAuthctxt | ||
29 | void *ctxt; | ||
30 | KbdintDevice *device; | ||
31 | u_int nreq; | ||
32 | + u_int devices_done; | ||
33 | }; | ||
34 | |||
35 | #ifdef USE_PAM | ||
36 | @@ -169,11 +170,15 @@ kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt) | ||
37 | if (len == 0) | ||
38 | break; | ||
39 | for (i = 0; devices[i]; i++) { | ||
40 | - if (!auth2_method_allowed(authctxt, | ||
41 | + if ((kbdintctxt->devices_done & (1 << i)) != 0 || | ||
42 | + !auth2_method_allowed(authctxt, | ||
43 | "keyboard-interactive", devices[i]->name)) | ||
44 | continue; | ||
45 | - if (strncmp(kbdintctxt->devices, devices[i]->name, len) == 0) | ||
46 | + if (strncmp(kbdintctxt->devices, devices[i]->name, | ||
47 | + len) == 0) { | ||
48 | kbdintctxt->device = devices[i]; | ||
49 | + kbdintctxt->devices_done |= 1 << i; | ||
50 | + } | ||
51 | } | ||
52 | t = kbdintctxt->devices; | ||
53 | kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL; | ||
diff --git a/debian/patches/backport-pam-use-after-free.patch b/debian/patches/backport-pam-use-after-free.patch new file mode 100644 index 000000000..52690882c --- /dev/null +++ b/debian/patches/backport-pam-use-after-free.patch | |||
@@ -0,0 +1,39 @@ | |||
1 | From a97f75bc484762111ae4e994791f4a5af6294c26 Mon Sep 17 00:00:00 2001 | ||
2 | From: Damien Miller <djm@mindrot.org> | ||
3 | Date: Tue, 11 Aug 2015 13:34:12 +1000 | ||
4 | Subject: set sshpam_ctxt to NULL after free | ||
5 | |||
6 | Avoids use-after-free in monitor when privsep child is compromised. | ||
7 | Reported by Moritz Jodeit; ok dtucker@ | ||
8 | |||
9 | Origin: upstream, https://anongit.mindrot.org/openssh.git/commit/?id=5e75f5198769056089fb06c4d738ab0e5abc66f7 | ||
10 | Forwarded: not-needed | ||
11 | Last-Update: 2015-08-19 | ||
12 | |||
13 | Patch-Name: backport-pam-use-after-free.patch | ||
14 | --- | ||
15 | monitor.c | 4 +++- | ||
16 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
17 | |||
18 | diff --git a/monitor.c b/monitor.c | ||
19 | index 870a6b9..e8541b4 100644 | ||
20 | --- a/monitor.c | ||
21 | +++ b/monitor.c | ||
22 | @@ -1225,14 +1225,16 @@ mm_answer_pam_respond(int sock, Buffer *m) | ||
23 | int | ||
24 | mm_answer_pam_free_ctx(int sock, Buffer *m) | ||
25 | { | ||
26 | + int r = sshpam_authok != NULL && sshpam_authok == sshpam_ctxt; | ||
27 | |||
28 | debug3("%s", __func__); | ||
29 | (sshpam_device.free_ctx)(sshpam_ctxt); | ||
30 | + sshpam_ctxt = sshpam_authok = NULL; | ||
31 | buffer_clear(m); | ||
32 | mm_request_send(sock, MONITOR_ANS_PAM_FREE_CTX, m); | ||
33 | auth_method = "keyboard-interactive"; | ||
34 | auth_submethod = "pam"; | ||
35 | - return (sshpam_authok == sshpam_ctxt); | ||
36 | + return r; | ||
37 | } | ||
38 | #endif | ||
39 | |||
diff --git a/debian/patches/consolekit.patch b/debian/patches/consolekit.patch new file mode 100644 index 000000000..5ab47c0ca --- /dev/null +++ b/debian/patches/consolekit.patch | |||
@@ -0,0 +1,576 @@ | |||
1 | From 1197fd975ab8fd11b1ac83557ef750129b16c0d8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@ubuntu.com> | ||
3 | Date: Sun, 9 Feb 2014 16:09:57 +0000 | ||
4 | Subject: Add support for registering ConsoleKit sessions on login | ||
5 | |||
6 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1450 | ||
7 | Last-Updated: 2015-08-19 | ||
8 | |||
9 | Patch-Name: consolekit.patch | ||
10 | --- | ||
11 | Makefile.in | 3 +- | ||
12 | configure.ac | 25 ++++++ | ||
13 | consolekit.c | 241 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
14 | consolekit.h | 24 ++++++ | ||
15 | monitor.c | 42 ++++++++++ | ||
16 | monitor.h | 2 + | ||
17 | monitor_wrap.c | 30 +++++++ | ||
18 | monitor_wrap.h | 4 + | ||
19 | session.c | 13 ++++ | ||
20 | session.h | 6 ++ | ||
21 | 10 files changed, 389 insertions(+), 1 deletion(-) | ||
22 | create mode 100644 consolekit.c | ||
23 | create mode 100644 consolekit.h | ||
24 | |||
25 | diff --git a/Makefile.in b/Makefile.in | ||
26 | index 3d2a328..c406aec 100644 | ||
27 | --- a/Makefile.in | ||
28 | +++ b/Makefile.in | ||
29 | @@ -111,7 +111,8 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \ | ||
30 | sftp-server.o sftp-common.o \ | ||
31 | roaming_common.o roaming_serv.o \ | ||
32 | sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \ | ||
33 | - sandbox-seccomp-filter.o sandbox-capsicum.o | ||
34 | + sandbox-seccomp-filter.o sandbox-capsicum.o \ | ||
35 | + consolekit.o | ||
36 | |||
37 | MANPAGES = moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out | ||
38 | MANPAGES_IN = moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5 | ||
39 | diff --git a/configure.ac b/configure.ac | ||
40 | index 4d55c46..cd6acaf 100644 | ||
41 | --- a/configure.ac | ||
42 | +++ b/configure.ac | ||
43 | @@ -4188,6 +4188,30 @@ AC_ARG_WITH([kerberos5], | ||
44 | AC_SUBST([GSSLIBS]) | ||
45 | AC_SUBST([K5LIBS]) | ||
46 | |||
47 | +# Check whether user wants ConsoleKit support | ||
48 | +CONSOLEKIT_MSG="no" | ||
49 | +LIBCK_CONNECTOR="" | ||
50 | +AC_ARG_WITH(consolekit, | ||
51 | + [ --with-consolekit Enable ConsoleKit support], | ||
52 | + [ if test "x$withval" != "xno" ; then | ||
53 | + AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no]) | ||
54 | + if test "$PKGCONFIG" != "no"; then | ||
55 | + AC_MSG_CHECKING([for ck-connector]) | ||
56 | + if $PKGCONFIG --exists ck-connector; then | ||
57 | + CKCON_CFLAGS=`$PKGCONFIG --cflags ck-connector` | ||
58 | + CKCON_LIBS=`$PKGCONFIG --libs ck-connector` | ||
59 | + CPPFLAGS="$CPPFLAGS $CKCON_CFLAGS" | ||
60 | + SSHDLIBS="$SSHDLIBS $CKCON_LIBS" | ||
61 | + AC_MSG_RESULT([yes]) | ||
62 | + AC_DEFINE(USE_CONSOLEKIT, 1, [Define if you want ConsoleKit support.]) | ||
63 | + CONSOLEKIT_MSG="yes" | ||
64 | + else | ||
65 | + AC_MSG_RESULT([no]) | ||
66 | + fi | ||
67 | + fi | ||
68 | + fi ] | ||
69 | +) | ||
70 | + | ||
71 | # Looking for programs, paths and files | ||
72 | |||
73 | PRIVSEP_PATH=/var/empty | ||
74 | @@ -4989,6 +5013,7 @@ echo " MD5 password support: $MD5_MSG" | ||
75 | echo " libedit support: $LIBEDIT_MSG" | ||
76 | echo " Solaris process contract support: $SPC_MSG" | ||
77 | echo " Solaris project support: $SP_MSG" | ||
78 | +echo " ConsoleKit support: $CONSOLEKIT_MSG" | ||
79 | echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG" | ||
80 | echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" | ||
81 | echo " BSD Auth support: $BSD_AUTH_MSG" | ||
82 | diff --git a/consolekit.c b/consolekit.c | ||
83 | new file mode 100644 | ||
84 | index 0000000..0266f06 | ||
85 | --- /dev/null | ||
86 | +++ b/consolekit.c | ||
87 | @@ -0,0 +1,241 @@ | ||
88 | +/* | ||
89 | + * Copyright (c) 2008 Colin Watson. All rights reserved. | ||
90 | + * | ||
91 | + * Permission to use, copy, modify, and distribute this software for any | ||
92 | + * purpose with or without fee is hereby granted, provided that the above | ||
93 | + * copyright notice and this permission notice appear in all copies. | ||
94 | + * | ||
95 | + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
96 | + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
97 | + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
98 | + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
99 | + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
100 | + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
101 | + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
102 | + */ | ||
103 | +/* | ||
104 | + * Loosely based on pam-ck-connector, which is: | ||
105 | + * | ||
106 | + * Copyright (c) 2007 David Zeuthen <davidz@redhat.com> | ||
107 | + * | ||
108 | + * Permission is hereby granted, free of charge, to any person | ||
109 | + * obtaining a copy of this software and associated documentation | ||
110 | + * files (the "Software"), to deal in the Software without | ||
111 | + * restriction, including without limitation the rights to use, | ||
112 | + * copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
113 | + * copies of the Software, and to permit persons to whom the | ||
114 | + * Software is furnished to do so, subject to the following | ||
115 | + * conditions: | ||
116 | + * | ||
117 | + * The above copyright notice and this permission notice shall be | ||
118 | + * included in all copies or substantial portions of the Software. | ||
119 | + * | ||
120 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
121 | + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
122 | + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
123 | + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
124 | + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
125 | + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
126 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
127 | + * OTHER DEALINGS IN THE SOFTWARE. | ||
128 | + */ | ||
129 | + | ||
130 | +#include "includes.h" | ||
131 | + | ||
132 | +#ifdef USE_CONSOLEKIT | ||
133 | + | ||
134 | +#include <ck-connector.h> | ||
135 | + | ||
136 | +#include "openbsd-compat/sys-queue.h" | ||
137 | +#include "xmalloc.h" | ||
138 | +#include "channels.h" | ||
139 | +#include "key.h" | ||
140 | +#include "hostfile.h" | ||
141 | +#include "auth.h" | ||
142 | +#include "log.h" | ||
143 | +#include "misc.h" | ||
144 | +#include "servconf.h" | ||
145 | +#include "canohost.h" | ||
146 | +#include "session.h" | ||
147 | +#include "consolekit.h" | ||
148 | + | ||
149 | +extern ServerOptions options; | ||
150 | +extern u_int utmp_len; | ||
151 | + | ||
152 | +void | ||
153 | +set_active(const char *cookie) | ||
154 | +{ | ||
155 | + DBusError err; | ||
156 | + DBusConnection *connection; | ||
157 | + DBusMessage *message = NULL, *reply = NULL; | ||
158 | + char *sid; | ||
159 | + DBusMessageIter iter, subiter; | ||
160 | + const char *interface, *property; | ||
161 | + dbus_bool_t active; | ||
162 | + | ||
163 | + dbus_error_init(&err); | ||
164 | + connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); | ||
165 | + if (!connection) { | ||
166 | + if (dbus_error_is_set(&err)) { | ||
167 | + error("unable to open DBus connection: %s", | ||
168 | + err.message); | ||
169 | + dbus_error_free(&err); | ||
170 | + } | ||
171 | + goto out; | ||
172 | + } | ||
173 | + dbus_connection_set_exit_on_disconnect(connection, FALSE); | ||
174 | + | ||
175 | + message = dbus_message_new_method_call("org.freedesktop.ConsoleKit", | ||
176 | + "/org/freedesktop/ConsoleKit/Manager", | ||
177 | + "org.freedesktop.ConsoleKit.Manager", | ||
178 | + "GetSessionForCookie"); | ||
179 | + if (!message) | ||
180 | + goto out; | ||
181 | + if (!dbus_message_append_args(message, DBUS_TYPE_STRING, &cookie, | ||
182 | + DBUS_TYPE_INVALID)) { | ||
183 | + if (dbus_error_is_set(&err)) { | ||
184 | + error("unable to get current session: %s", | ||
185 | + err.message); | ||
186 | + dbus_error_free(&err); | ||
187 | + } | ||
188 | + goto out; | ||
189 | + } | ||
190 | + | ||
191 | + dbus_error_init(&err); | ||
192 | + reply = dbus_connection_send_with_reply_and_block(connection, message, | ||
193 | + -1, &err); | ||
194 | + if (!reply) { | ||
195 | + if (dbus_error_is_set(&err)) { | ||
196 | + error("unable to get current session: %s", | ||
197 | + err.message); | ||
198 | + dbus_error_free(&err); | ||
199 | + } | ||
200 | + goto out; | ||
201 | + } | ||
202 | + | ||
203 | + dbus_error_init(&err); | ||
204 | + if (!dbus_message_get_args(reply, &err, | ||
205 | + DBUS_TYPE_OBJECT_PATH, &sid, | ||
206 | + DBUS_TYPE_INVALID)) { | ||
207 | + if (dbus_error_is_set(&err)) { | ||
208 | + error("unable to get current session: %s", | ||
209 | + err.message); | ||
210 | + dbus_error_free(&err); | ||
211 | + } | ||
212 | + goto out; | ||
213 | + } | ||
214 | + dbus_message_unref(reply); | ||
215 | + dbus_message_unref(message); | ||
216 | + message = reply = NULL; | ||
217 | + | ||
218 | + message = dbus_message_new_method_call("org.freedesktop.ConsoleKit", | ||
219 | + sid, "org.freedesktop.DBus.Properties", "Set"); | ||
220 | + if (!message) | ||
221 | + goto out; | ||
222 | + interface = "org.freedesktop.ConsoleKit.Session"; | ||
223 | + property = "active"; | ||
224 | + if (!dbus_message_append_args(message, | ||
225 | + DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &property, | ||
226 | + DBUS_TYPE_INVALID)) | ||
227 | + goto out; | ||
228 | + dbus_message_iter_init_append(message, &iter); | ||
229 | + if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, | ||
230 | + DBUS_TYPE_BOOLEAN_AS_STRING, &subiter)) | ||
231 | + goto out; | ||
232 | + active = TRUE; | ||
233 | + if (!dbus_message_iter_append_basic(&subiter, DBUS_TYPE_BOOLEAN, | ||
234 | + &active)) | ||
235 | + goto out; | ||
236 | + if (!dbus_message_iter_close_container(&iter, &subiter)) | ||
237 | + goto out; | ||
238 | + | ||
239 | + dbus_error_init(&err); | ||
240 | + reply = dbus_connection_send_with_reply_and_block(connection, message, | ||
241 | + -1, &err); | ||
242 | + if (!reply) { | ||
243 | + if (dbus_error_is_set(&err)) { | ||
244 | + error("unable to make current session active: %s", | ||
245 | + err.message); | ||
246 | + dbus_error_free(&err); | ||
247 | + } | ||
248 | + goto out; | ||
249 | + } | ||
250 | + | ||
251 | +out: | ||
252 | + if (reply) | ||
253 | + dbus_message_unref(reply); | ||
254 | + if (message) | ||
255 | + dbus_message_unref(message); | ||
256 | +} | ||
257 | + | ||
258 | +/* | ||
259 | + * We pass display separately rather than using s->display because the | ||
260 | + * latter is not available in the monitor when using privsep. | ||
261 | + */ | ||
262 | + | ||
263 | +char * | ||
264 | +consolekit_register(Session *s, const char *display) | ||
265 | +{ | ||
266 | + DBusError err; | ||
267 | + const char *tty = s->tty; | ||
268 | + const char *remote_host_name; | ||
269 | + dbus_bool_t is_local = FALSE; | ||
270 | + const char *cookie = NULL; | ||
271 | + | ||
272 | + if (s->ckc) { | ||
273 | + debug("already registered with ConsoleKit"); | ||
274 | + return xstrdup(ck_connector_get_cookie(s->ckc)); | ||
275 | + } | ||
276 | + | ||
277 | + s->ckc = ck_connector_new(); | ||
278 | + if (!s->ckc) { | ||
279 | + error("ck_connector_new failed"); | ||
280 | + return NULL; | ||
281 | + } | ||
282 | + | ||
283 | + if (!tty) | ||
284 | + tty = ""; | ||
285 | + if (!display) | ||
286 | + display = ""; | ||
287 | + remote_host_name = get_remote_name_or_ip(utmp_len, options.use_dns); | ||
288 | + if (!remote_host_name) | ||
289 | + remote_host_name = ""; | ||
290 | + | ||
291 | + dbus_error_init(&err); | ||
292 | + if (!ck_connector_open_session_with_parameters(s->ckc, &err, | ||
293 | + "unix-user", &s->pw->pw_uid, | ||
294 | + "display-device", &tty, | ||
295 | + "x11-display", &display, | ||
296 | + "remote-host-name", &remote_host_name, | ||
297 | + "is-local", &is_local, | ||
298 | + NULL)) { | ||
299 | + if (dbus_error_is_set(&err)) { | ||
300 | + debug("%s", err.message); | ||
301 | + dbus_error_free(&err); | ||
302 | + } else { | ||
303 | + debug("insufficient privileges or D-Bus / ConsoleKit " | ||
304 | + "not available"); | ||
305 | + } | ||
306 | + return NULL; | ||
307 | + } | ||
308 | + | ||
309 | + debug("registered uid=%d on tty='%s' with ConsoleKit", | ||
310 | + s->pw->pw_uid, s->tty); | ||
311 | + | ||
312 | + cookie = ck_connector_get_cookie(s->ckc); | ||
313 | + set_active(cookie); | ||
314 | + return xstrdup(cookie); | ||
315 | +} | ||
316 | + | ||
317 | +void | ||
318 | +consolekit_unregister(Session *s) | ||
319 | +{ | ||
320 | + if (s->ckc) { | ||
321 | + debug("unregistering ConsoleKit session %s", | ||
322 | + ck_connector_get_cookie(s->ckc)); | ||
323 | + ck_connector_unref(s->ckc); | ||
324 | + s->ckc = NULL; | ||
325 | + } | ||
326 | +} | ||
327 | + | ||
328 | +#endif /* USE_CONSOLEKIT */ | ||
329 | diff --git a/consolekit.h b/consolekit.h | ||
330 | new file mode 100644 | ||
331 | index 0000000..8ce3716 | ||
332 | --- /dev/null | ||
333 | +++ b/consolekit.h | ||
334 | @@ -0,0 +1,24 @@ | ||
335 | +/* | ||
336 | + * Copyright (c) 2008 Colin Watson. All rights reserved. | ||
337 | + * | ||
338 | + * Permission to use, copy, modify, and distribute this software for any | ||
339 | + * purpose with or without fee is hereby granted, provided that the above | ||
340 | + * copyright notice and this permission notice appear in all copies. | ||
341 | + * | ||
342 | + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
343 | + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
344 | + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
345 | + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
346 | + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
347 | + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
348 | + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
349 | + */ | ||
350 | + | ||
351 | +#ifdef USE_CONSOLEKIT | ||
352 | + | ||
353 | +struct Session; | ||
354 | + | ||
355 | +char * consolekit_register(struct Session *, const char *); | ||
356 | +void consolekit_unregister(struct Session *); | ||
357 | + | ||
358 | +#endif /* USE_CONSOLEKIT */ | ||
359 | diff --git a/monitor.c b/monitor.c | ||
360 | index 3a3d2f0..12ed6fd 100644 | ||
361 | --- a/monitor.c | ||
362 | +++ b/monitor.c | ||
363 | @@ -104,6 +104,9 @@ | ||
364 | #include "authfd.h" | ||
365 | #include "match.h" | ||
366 | #include "ssherr.h" | ||
367 | +#ifdef USE_CONSOLEKIT | ||
368 | +#include "consolekit.h" | ||
369 | +#endif | ||
370 | |||
371 | #ifdef GSSAPI | ||
372 | static Gssctxt *gsscontext = NULL; | ||
373 | @@ -169,6 +172,10 @@ int mm_answer_audit_command(int, Buffer *); | ||
374 | |||
375 | static int monitor_read_log(struct monitor *); | ||
376 | |||
377 | +#ifdef USE_CONSOLEKIT | ||
378 | +int mm_answer_consolekit_register(int, Buffer *); | ||
379 | +#endif | ||
380 | + | ||
381 | static Authctxt *authctxt; | ||
382 | |||
383 | #ifdef WITH_SSH1 | ||
384 | @@ -261,6 +268,9 @@ struct mon_table mon_dispatch_postauth20[] = { | ||
385 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, | ||
386 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command}, | ||
387 | #endif | ||
388 | +#ifdef USE_CONSOLEKIT | ||
389 | + {MONITOR_REQ_CONSOLEKIT_REGISTER, 0, mm_answer_consolekit_register}, | ||
390 | +#endif | ||
391 | {0, 0, NULL} | ||
392 | }; | ||
393 | |||
394 | @@ -306,6 +316,9 @@ struct mon_table mon_dispatch_postauth15[] = { | ||
395 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, | ||
396 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command}, | ||
397 | #endif | ||
398 | +#ifdef USE_CONSOLEKIT | ||
399 | + {MONITOR_REQ_CONSOLEKIT_REGISTER, 0, mm_answer_consolekit_register}, | ||
400 | +#endif | ||
401 | #endif /* WITH_SSH1 */ | ||
402 | {0, 0, NULL} | ||
403 | }; | ||
404 | @@ -488,6 +501,9 @@ monitor_child_postauth(struct monitor *pmonitor) | ||
405 | monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); | ||
406 | monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); | ||
407 | } | ||
408 | +#ifdef USE_CONSOLEKIT | ||
409 | + monitor_permit(mon_dispatch, MONITOR_REQ_CONSOLEKIT_REGISTER, 1); | ||
410 | +#endif | ||
411 | |||
412 | for (;;) | ||
413 | monitor_read(pmonitor, mon_dispatch, NULL); | ||
414 | @@ -2191,3 +2207,29 @@ mm_answer_gss_updatecreds(int socket, Buffer *m) { | ||
415 | |||
416 | #endif /* GSSAPI */ | ||
417 | |||
418 | +#ifdef USE_CONSOLEKIT | ||
419 | +int | ||
420 | +mm_answer_consolekit_register(int sock, Buffer *m) | ||
421 | +{ | ||
422 | + Session *s; | ||
423 | + char *tty, *display; | ||
424 | + char *cookie = NULL; | ||
425 | + | ||
426 | + debug3("%s entering", __func__); | ||
427 | + | ||
428 | + tty = buffer_get_string(m, NULL); | ||
429 | + display = buffer_get_string(m, NULL); | ||
430 | + s = session_by_tty(tty); | ||
431 | + if (s != NULL) | ||
432 | + cookie = consolekit_register(s, display); | ||
433 | + buffer_clear(m); | ||
434 | + buffer_put_cstring(m, cookie != NULL ? cookie : ""); | ||
435 | + mm_request_send(sock, MONITOR_ANS_CONSOLEKIT_REGISTER, m); | ||
436 | + | ||
437 | + free(cookie); | ||
438 | + free(display); | ||
439 | + free(tty); | ||
440 | + | ||
441 | + return (0); | ||
442 | +} | ||
443 | +#endif /* USE_CONSOLEKIT */ | ||
444 | diff --git a/monitor.h b/monitor.h | ||
445 | index 2d82b8b..fd8d92c 100644 | ||
446 | --- a/monitor.h | ||
447 | +++ b/monitor.h | ||
448 | @@ -70,6 +70,8 @@ enum monitor_reqtype { | ||
449 | |||
450 | MONITOR_REQ_AUTHROLE = 154, | ||
451 | |||
452 | + MONITOR_REQ_CONSOLEKIT_REGISTER = 156, MONITOR_ANS_CONSOLEKIT_REGISTER = 157, | ||
453 | + | ||
454 | }; | ||
455 | |||
456 | struct mm_master; | ||
457 | diff --git a/monitor_wrap.c b/monitor_wrap.c | ||
458 | index 6ae72a0..2a0fe9b 100644 | ||
459 | --- a/monitor_wrap.c | ||
460 | +++ b/monitor_wrap.c | ||
461 | @@ -1151,3 +1151,33 @@ mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *store) | ||
462 | |||
463 | #endif /* GSSAPI */ | ||
464 | |||
465 | +#ifdef USE_CONSOLEKIT | ||
466 | +char * | ||
467 | +mm_consolekit_register(Session *s, const char *display) | ||
468 | +{ | ||
469 | + Buffer m; | ||
470 | + char *cookie; | ||
471 | + | ||
472 | + debug3("%s entering", __func__); | ||
473 | + | ||
474 | + if (s->ttyfd == -1) | ||
475 | + return NULL; | ||
476 | + buffer_init(&m); | ||
477 | + buffer_put_cstring(&m, s->tty); | ||
478 | + buffer_put_cstring(&m, display != NULL ? display : ""); | ||
479 | + mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_CONSOLEKIT_REGISTER, &m); | ||
480 | + buffer_clear(&m); | ||
481 | + | ||
482 | + mm_request_receive_expect(pmonitor->m_recvfd, | ||
483 | + MONITOR_ANS_CONSOLEKIT_REGISTER, &m); | ||
484 | + cookie = buffer_get_string(&m, NULL); | ||
485 | + buffer_free(&m); | ||
486 | + | ||
487 | + /* treat empty cookie as missing cookie */ | ||
488 | + if (strlen(cookie) == 0) { | ||
489 | + free(cookie); | ||
490 | + cookie = NULL; | ||
491 | + } | ||
492 | + return (cookie); | ||
493 | +} | ||
494 | +#endif /* USE_CONSOLEKIT */ | ||
495 | diff --git a/monitor_wrap.h b/monitor_wrap.h | ||
496 | index 57e740f..6829392 100644 | ||
497 | --- a/monitor_wrap.h | ||
498 | +++ b/monitor_wrap.h | ||
499 | @@ -108,4 +108,8 @@ int mm_skey_respond(void *, u_int, char **); | ||
500 | /* zlib allocation hooks */ | ||
501 | void mm_init_compression(struct mm_master *); | ||
502 | |||
503 | +#ifdef USE_CONSOLEKIT | ||
504 | +char *mm_consolekit_register(struct Session *, const char *); | ||
505 | +#endif /* USE_CONSOLEKIT */ | ||
506 | + | ||
507 | #endif /* _MM_WRAP_H_ */ | ||
508 | diff --git a/session.c b/session.c | ||
509 | index afac4a5..c6bd728 100644 | ||
510 | --- a/session.c | ||
511 | +++ b/session.c | ||
512 | @@ -94,6 +94,7 @@ | ||
513 | #include "kex.h" | ||
514 | #include "monitor_wrap.h" | ||
515 | #include "sftp.h" | ||
516 | +#include "consolekit.h" | ||
517 | |||
518 | #if defined(KRB5) && defined(USE_AFS) | ||
519 | #include <kafs.h> | ||
520 | @@ -1144,6 +1145,9 @@ do_setup_env(Session *s, const char *shell) | ||
521 | #if !defined (HAVE_LOGIN_CAP) && !defined (HAVE_CYGWIN) | ||
522 | char *path = NULL; | ||
523 | #endif | ||
524 | +#ifdef USE_CONSOLEKIT | ||
525 | + const char *ckcookie = NULL; | ||
526 | +#endif /* USE_CONSOLEKIT */ | ||
527 | |||
528 | /* Initialize the environment. */ | ||
529 | envsize = 100; | ||
530 | @@ -1288,6 +1292,11 @@ do_setup_env(Session *s, const char *shell) | ||
531 | child_set_env(&env, &envsize, "KRB5CCNAME", | ||
532 | s->authctxt->krb5_ccname); | ||
533 | #endif | ||
534 | +#ifdef USE_CONSOLEKIT | ||
535 | + ckcookie = PRIVSEP(consolekit_register(s, s->display)); | ||
536 | + if (ckcookie) | ||
537 | + child_set_env(&env, &envsize, "XDG_SESSION_COOKIE", ckcookie); | ||
538 | +#endif /* USE_CONSOLEKIT */ | ||
539 | #ifdef USE_PAM | ||
540 | /* | ||
541 | * Pull in any environment variables that may have | ||
542 | @@ -2351,6 +2360,10 @@ session_pty_cleanup2(Session *s) | ||
543 | |||
544 | debug("session_pty_cleanup: session %d release %s", s->self, s->tty); | ||
545 | |||
546 | +#ifdef USE_CONSOLEKIT | ||
547 | + consolekit_unregister(s); | ||
548 | +#endif /* USE_CONSOLEKIT */ | ||
549 | + | ||
550 | /* Record that the user has logged out. */ | ||
551 | if (s->pid != 0) | ||
552 | record_logout(s->pid, s->tty, s->pw->pw_name); | ||
553 | diff --git a/session.h b/session.h | ||
554 | index ef6593c..a6b6983 100644 | ||
555 | --- a/session.h | ||
556 | +++ b/session.h | ||
557 | @@ -26,6 +26,8 @@ | ||
558 | #ifndef SESSION_H | ||
559 | #define SESSION_H | ||
560 | |||
561 | +struct _CkConnector; | ||
562 | + | ||
563 | #define TTYSZ 64 | ||
564 | typedef struct Session Session; | ||
565 | struct Session { | ||
566 | @@ -61,6 +63,10 @@ struct Session { | ||
567 | char *name; | ||
568 | char *val; | ||
569 | } *env; | ||
570 | + | ||
571 | +#ifdef USE_CONSOLEKIT | ||
572 | + struct _CkConnector *ckc; | ||
573 | +#endif /* USE_CONSOLEKIT */ | ||
574 | }; | ||
575 | |||
576 | void do_authenticated(Authctxt *); | ||
diff --git a/debian/patches/debian-banner.patch b/debian/patches/debian-banner.patch new file mode 100644 index 000000000..42fc5be76 --- /dev/null +++ b/debian/patches/debian-banner.patch | |||
@@ -0,0 +1,111 @@ | |||
1 | From 91729e3501d53d11fcc7a364b36994305c495945 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: 2015-08-19 | ||
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 8a5bd7b..fe3e311 100644 | ||
23 | --- a/servconf.c | ||
24 | +++ b/servconf.c | ||
25 | @@ -169,6 +169,7 @@ initialize_server_options(ServerOptions *options) | ||
26 | options->ip_qos_bulk = -1; | ||
27 | options->version_addendum = NULL; | ||
28 | options->fingerprint_hash = -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 | @@ -347,6 +348,8 @@ fill_default_server_options(ServerOptions *options) | ||
34 | options->fwd_opts.streamlocal_bind_unlink = 0; | ||
35 | if (options->fingerprint_hash == -1) | ||
36 | options->fingerprint_hash = SSH_FP_HASH_DEFAULT; | ||
37 | + if (options->debian_banner == -1) | ||
38 | + options->debian_banner = 1; | ||
39 | /* Turn privilege separation on by default */ | ||
40 | if (use_privsep == -1) | ||
41 | use_privsep = PRIVSEP_NOSANDBOX; | ||
42 | @@ -419,6 +422,7 @@ typedef enum { | ||
43 | sAuthenticationMethods, sHostKeyAgent, sPermitUserRC, | ||
44 | sStreamLocalBindMask, sStreamLocalBindUnlink, | ||
45 | sAllowStreamLocalForwarding, sFingerprintHash, | ||
46 | + sDebianBanner, | ||
47 | sDeprecated, sUnsupported | ||
48 | } ServerOpCodes; | ||
49 | |||
50 | @@ -565,6 +569,7 @@ static struct { | ||
51 | { "streamlocalbindunlink", sStreamLocalBindUnlink, SSHCFG_ALL }, | ||
52 | { "allowstreamlocalforwarding", sAllowStreamLocalForwarding, SSHCFG_ALL }, | ||
53 | { "fingerprinthash", sFingerprintHash, SSHCFG_GLOBAL }, | ||
54 | + { "debianbanner", sDebianBanner, SSHCFG_GLOBAL }, | ||
55 | { NULL, sBadOption, 0 } | ||
56 | }; | ||
57 | |||
58 | @@ -1850,6 +1855,10 @@ process_server_config_line(ServerOptions *options, char *line, | ||
59 | options->fingerprint_hash = value; | ||
60 | break; | ||
61 | |||
62 | + case sDebianBanner: | ||
63 | + intptr = &options->debian_banner; | ||
64 | + goto parse_int; | ||
65 | + | ||
66 | case sDeprecated: | ||
67 | logit("%s line %d: Deprecated option %s", | ||
68 | filename, linenum, arg); | ||
69 | diff --git a/servconf.h b/servconf.h | ||
70 | index b99b270..ba7b739 100644 | ||
71 | --- a/servconf.h | ||
72 | +++ b/servconf.h | ||
73 | @@ -196,6 +196,8 @@ typedef struct { | ||
74 | char *auth_methods[MAX_AUTH_METHODS]; | ||
75 | |||
76 | int fingerprint_hash; | ||
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 96e75c6..7886d0e 100644 | ||
84 | --- a/sshd.c | ||
85 | +++ b/sshd.c | ||
86 | @@ -442,7 +442,8 @@ sshd_exchange_identification(int sock_in, int sock_out) | ||
87 | } | ||
88 | |||
89 | xasprintf(&server_version_string, "SSH-%d.%d-%.100s%s%s%s", | ||
90 | - major, minor, SSH_RELEASE, | ||
91 | + major, minor, | ||
92 | + options.debian_banner ? SSH_RELEASE : SSH_RELEASE_MINIMUM, | ||
93 | *options.version_addendum == '\0' ? "" : " ", | ||
94 | options.version_addendum, newline); | ||
95 | |||
96 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
97 | index 1269bbd..a5afbc3 100644 | ||
98 | --- a/sshd_config.5 | ||
99 | +++ b/sshd_config.5 | ||
100 | @@ -528,6 +528,11 @@ or | ||
101 | .Dq no . | ||
102 | The default is | ||
103 | .Dq delayed . | ||
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 | +.Dq 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..c990a01c3 --- /dev/null +++ b/debian/patches/debian-config.patch | |||
@@ -0,0 +1,198 @@ | |||
1 | From 88ebb6a4a95f2f9ded930587c33f08cff0fc1db4 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 and disable GSSAPIDelegateCredentials by | ||
15 | default. | ||
16 | |||
17 | sshd: Refer to /usr/share/doc/openssh-server/README.Debian.gz alongside | ||
18 | PermitRootLogin default. | ||
19 | |||
20 | Document all of this, along with several sshd defaults set in | ||
21 | debian/openssh-server.postinst. | ||
22 | |||
23 | Author: Russ Allbery <rra@debian.org> | ||
24 | Forwarded: not-needed | ||
25 | Last-Update: 2015-08-19 | ||
26 | |||
27 | Patch-Name: debian-config.patch | ||
28 | --- | ||
29 | readconf.c | 2 +- | ||
30 | ssh.1 | 21 +++++++++++++++++++++ | ||
31 | ssh_config | 7 ++++++- | ||
32 | ssh_config.5 | 19 ++++++++++++++++++- | ||
33 | sshd_config | 3 ++- | ||
34 | sshd_config.5 | 25 +++++++++++++++++++++++++ | ||
35 | 6 files changed, 73 insertions(+), 4 deletions(-) | ||
36 | |||
37 | diff --git a/readconf.c b/readconf.c | ||
38 | index 5f6c37f..f0769b5 100644 | ||
39 | --- a/readconf.c | ||
40 | +++ b/readconf.c | ||
41 | @@ -1748,7 +1748,7 @@ fill_default_options(Options * options) | ||
42 | if (options->forward_x11 == -1) | ||
43 | options->forward_x11 = 0; | ||
44 | if (options->forward_x11_trusted == -1) | ||
45 | - options->forward_x11_trusted = 0; | ||
46 | + options->forward_x11_trusted = 1; | ||
47 | if (options->forward_x11_timeout == -1) | ||
48 | options->forward_x11_timeout = 1200; | ||
49 | if (options->exit_on_forward_failure == -1) | ||
50 | diff --git a/ssh.1 b/ssh.1 | ||
51 | index 2178863..e2cce49 100644 | ||
52 | --- a/ssh.1 | ||
53 | +++ b/ssh.1 | ||
54 | @@ -670,12 +670,33 @@ option and the | ||
55 | directive in | ||
56 | .Xr ssh_config 5 | ||
57 | for more information. | ||
58 | +.Pp | ||
59 | +(Debian-specific: X11 forwarding is not subjected to X11 SECURITY extension | ||
60 | +restrictions by default, because too many programs currently crash in this | ||
61 | +mode. | ||
62 | +Set the | ||
63 | +.Cm ForwardX11Trusted | ||
64 | +option to | ||
65 | +.Dq no | ||
66 | +to restore the upstream behaviour. | ||
67 | +This may change in future depending on client-side improvements.) | ||
68 | .It Fl x | ||
69 | Disables X11 forwarding. | ||
70 | .It Fl Y | ||
71 | Enables trusted X11 forwarding. | ||
72 | Trusted X11 forwardings are not subjected to the X11 SECURITY extension | ||
73 | controls. | ||
74 | +.Pp | ||
75 | +(Debian-specific: This option does nothing in the default configuration: it | ||
76 | +is equivalent to | ||
77 | +.Dq Cm ForwardX11Trusted No yes , | ||
78 | +which is the default as described above. | ||
79 | +Set the | ||
80 | +.Cm ForwardX11Trusted | ||
81 | +option to | ||
82 | +.Dq no | ||
83 | +to restore the upstream behaviour. | ||
84 | +This may change in future depending on client-side improvements.) | ||
85 | .It Fl y | ||
86 | Send log information using the | ||
87 | .Xr syslog 3 | ||
88 | diff --git a/ssh_config b/ssh_config | ||
89 | index 228e5ab..c9386aa 100644 | ||
90 | --- a/ssh_config | ||
91 | +++ b/ssh_config | ||
92 | @@ -17,9 +17,10 @@ | ||
93 | # list of available options, their meanings and defaults, please see the | ||
94 | # ssh_config(5) man page. | ||
95 | |||
96 | -# Host * | ||
97 | +Host * | ||
98 | # ForwardAgent no | ||
99 | # ForwardX11 no | ||
100 | +# ForwardX11Trusted yes | ||
101 | # RhostsRSAAuthentication no | ||
102 | # RSAAuthentication yes | ||
103 | # PasswordAuthentication yes | ||
104 | @@ -48,3 +49,7 @@ | ||
105 | # VisualHostKey no | ||
106 | # ProxyCommand ssh -q -W %h:%p gateway.example.com | ||
107 | # RekeyLimit 1G 1h | ||
108 | + SendEnv LANG LC_* | ||
109 | + HashKnownHosts yes | ||
110 | + GSSAPIAuthentication yes | ||
111 | + GSSAPIDelegateCredentials no | ||
112 | diff --git a/ssh_config.5 b/ssh_config.5 | ||
113 | index acd581b..844d1a0 100644 | ||
114 | --- a/ssh_config.5 | ||
115 | +++ b/ssh_config.5 | ||
116 | @@ -74,6 +74,22 @@ Since the first obtained value for each parameter is used, more | ||
117 | host-specific declarations should be given near the beginning of the | ||
118 | file, and general defaults at the end. | ||
119 | .Pp | ||
120 | +Note that the Debian | ||
121 | +.Ic openssh-client | ||
122 | +package sets several options as standard in | ||
123 | +.Pa /etc/ssh/ssh_config | ||
124 | +which are not the default in | ||
125 | +.Xr ssh 1 : | ||
126 | +.Pp | ||
127 | +.Bl -bullet -offset indent -compact | ||
128 | +.It | ||
129 | +.Cm SendEnv No LANG LC_* | ||
130 | +.It | ||
131 | +.Cm HashKnownHosts No yes | ||
132 | +.It | ||
133 | +.Cm GSSAPIAuthentication No yes | ||
134 | +.El | ||
135 | +.Pp | ||
136 | The configuration file has the following format: | ||
137 | .Pp | ||
138 | Empty lines and lines starting with | ||
139 | @@ -716,7 +732,8 @@ token used for the session will be set to expire after 20 minutes. | ||
140 | Remote clients will be refused access after this time. | ||
141 | .Pp | ||
142 | The default is | ||
143 | -.Dq no . | ||
144 | +.Dq yes | ||
145 | +(Debian-specific). | ||
146 | .Pp | ||
147 | See the X11 SECURITY extension specification for full details on | ||
148 | the restrictions imposed on untrusted clients. | ||
149 | diff --git a/sshd_config b/sshd_config | ||
150 | index 1dfd0f1..23a338f 100644 | ||
151 | --- a/sshd_config | ||
152 | +++ b/sshd_config | ||
153 | @@ -41,7 +41,8 @@ | ||
154 | # Authentication: | ||
155 | |||
156 | #LoginGraceTime 2m | ||
157 | -#PermitRootLogin no | ||
158 | +# See /usr/share/doc/openssh-server/README.Debian.gz. | ||
159 | +#PermitRootLogin without-password | ||
160 | #StrictModes yes | ||
161 | #MaxAuthTries 6 | ||
162 | #MaxSessions 10 | ||
163 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
164 | index 355b445..eb6bff8 100644 | ||
165 | --- a/sshd_config.5 | ||
166 | +++ b/sshd_config.5 | ||
167 | @@ -57,6 +57,31 @@ Arguments may optionally be enclosed in double quotes | ||
168 | .Pq \&" | ||
169 | in order to represent arguments containing spaces. | ||
170 | .Pp | ||
171 | +Note that the Debian | ||
172 | +.Ic openssh-server | ||
173 | +package sets several options as standard in | ||
174 | +.Pa /etc/ssh/sshd_config | ||
175 | +which are not the default in | ||
176 | +.Xr sshd 8 . | ||
177 | +The exact list depends on whether the package was installed fresh or | ||
178 | +upgraded from various possible previous versions, but includes at least the | ||
179 | +following: | ||
180 | +.Pp | ||
181 | +.Bl -bullet -offset indent -compact | ||
182 | +.It | ||
183 | +.Cm ChallengeResponseAuthentication No no | ||
184 | +.It | ||
185 | +.Cm X11Forwarding No yes | ||
186 | +.It | ||
187 | +.Cm PrintMotd No no | ||
188 | +.It | ||
189 | +.Cm AcceptEnv No LANG LC_* | ||
190 | +.It | ||
191 | +.Cm Subsystem No sftp /usr/lib/openssh/sftp-server | ||
192 | +.It | ||
193 | +.Cm UsePAM No yes | ||
194 | +.El | ||
195 | +.Pp | ||
196 | The possible | ||
197 | keywords and their meanings are as follows (note that | ||
198 | 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..57bd567e4 --- /dev/null +++ b/debian/patches/dnssec-sshfp.patch | |||
@@ -0,0 +1,94 @@ | |||
1 | From dbde51cd7abb931b2d8635230bd77c9ec3b75074 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 f201b60..a406f58 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 dc6fe05..e061a29 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 1283f55..dbbc85a 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..b80cc4e25 --- /dev/null +++ b/debian/patches/doc-hash-tab-completion.patch | |||
@@ -0,0 +1,28 @@ | |||
1 | From 9e2f66b771364d835a5308218b777b08935596b8 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 1d0c52b..acd581b 100644 | ||
17 | --- a/ssh_config.5 | ||
18 | +++ b/ssh_config.5 | ||
19 | @@ -802,6 +802,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/doc-upstart.patch b/debian/patches/doc-upstart.patch new file mode 100644 index 000000000..151c57eb1 --- /dev/null +++ b/debian/patches/doc-upstart.patch | |||
@@ -0,0 +1,29 @@ | |||
1 | From 64f36a889a1afd364636c1ded6b6a694675fca67 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@ubuntu.com> | ||
3 | Date: Sun, 9 Feb 2014 16:10:12 +0000 | ||
4 | Subject: Refer to ssh's Upstart job as well as its init script | ||
5 | |||
6 | Forwarded: not-needed | ||
7 | Last-Update: 2013-09-14 | ||
8 | |||
9 | Patch-Name: doc-upstart.patch | ||
10 | --- | ||
11 | sshd.8 | 5 ++++- | ||
12 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/sshd.8 b/sshd.8 | ||
15 | index 2f4d4f3..42f1520 100644 | ||
16 | --- a/sshd.8 | ||
17 | +++ b/sshd.8 | ||
18 | @@ -67,7 +67,10 @@ over an insecure network. | ||
19 | .Nm | ||
20 | listens for connections from clients. | ||
21 | It is normally started at boot from | ||
22 | -.Pa /etc/init.d/ssh . | ||
23 | +.Pa /etc/init.d/ssh | ||
24 | +(or | ||
25 | +.Pa /etc/init/ssh.conf | ||
26 | +on systems using the Upstart init daemon). | ||
27 | It forks a new | ||
28 | daemon for each incoming connection. | ||
29 | The forked daemons handle | ||
diff --git a/debian/patches/gnome-ssh-askpass2-icon.patch b/debian/patches/gnome-ssh-askpass2-icon.patch new file mode 100644 index 000000000..cdb3fc7f0 --- /dev/null +++ b/debian/patches/gnome-ssh-askpass2-icon.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | From f3e58419e41e29f5d03c2d91f4576febac922112 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 9d97c30..04b3a11 100644 | ||
16 | --- a/contrib/gnome-ssh-askpass2.c | ||
17 | +++ b/contrib/gnome-ssh-askpass2.c | ||
18 | @@ -209,6 +209,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..3f616af7d --- /dev/null +++ b/debian/patches/gssapi.patch | |||
@@ -0,0 +1,3020 @@ | |||
1 | From 5d3dc7ea4c96cab9483d5389a3b04163771fdee2 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: 2015-08-19 | ||
21 | |||
22 | Patch-Name: gssapi.patch | ||
23 | --- | ||
24 | ChangeLog.gssapi | 113 +++++++++++++++++++ | ||
25 | Makefile.in | 5 +- | ||
26 | auth-krb5.c | 17 ++- | ||
27 | auth2-gss.c | 48 +++++++- | ||
28 | auth2.c | 2 + | ||
29 | clientloop.c | 13 +++ | ||
30 | config.h.in | 6 + | ||
31 | configure.ac | 24 ++++ | ||
32 | gss-genr.c | 275 ++++++++++++++++++++++++++++++++++++++++++++- | ||
33 | gss-serv-krb5.c | 85 ++++++++++++-- | ||
34 | gss-serv.c | 185 +++++++++++++++++++++++++++--- | ||
35 | kex.c | 16 +++ | ||
36 | kex.h | 14 +++ | ||
37 | kexgssc.c | 336 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
38 | kexgsss.c | 295 ++++++++++++++++++++++++++++++++++++++++++++++++ | ||
39 | monitor.c | 108 +++++++++++++++++- | ||
40 | monitor.h | 3 + | ||
41 | monitor_wrap.c | 47 +++++++- | ||
42 | monitor_wrap.h | 4 +- | ||
43 | readconf.c | 42 +++++++ | ||
44 | readconf.h | 5 + | ||
45 | servconf.c | 28 ++++- | ||
46 | servconf.h | 2 + | ||
47 | ssh-gss.h | 41 ++++++- | ||
48 | ssh_config | 2 + | ||
49 | ssh_config.5 | 34 +++++- | ||
50 | sshconnect2.c | 124 +++++++++++++++++++- | ||
51 | sshd.c | 110 ++++++++++++++++++ | ||
52 | sshd_config | 2 + | ||
53 | sshd_config.5 | 11 ++ | ||
54 | sshkey.c | 3 +- | ||
55 | sshkey.h | 1 + | ||
56 | 32 files changed, 1955 insertions(+), 46 deletions(-) | ||
57 | create mode 100644 ChangeLog.gssapi | ||
58 | create mode 100644 kexgssc.c | ||
59 | create mode 100644 kexgsss.c | ||
60 | |||
61 | diff --git a/ChangeLog.gssapi b/ChangeLog.gssapi | ||
62 | new file mode 100644 | ||
63 | index 0000000..f117a33 | ||
64 | --- /dev/null | ||
65 | +++ b/ChangeLog.gssapi | ||
66 | @@ -0,0 +1,113 @@ | ||
67 | +20110101 | ||
68 | + - Finally update for OpenSSH 5.6p1 | ||
69 | + - Add GSSAPIServerIdentity option from Jim Basney | ||
70 | + | ||
71 | +20100308 | ||
72 | + - [ Makefile.in, key.c, key.h ] | ||
73 | + Updates for OpenSSH 5.4p1 | ||
74 | + - [ servconf.c ] | ||
75 | + Include GSSAPI options in the sshd -T configuration dump, and flag | ||
76 | + some older configuration options as being unsupported. Thanks to Colin | ||
77 | + Watson. | ||
78 | + - | ||
79 | + | ||
80 | +20100124 | ||
81 | + - [ sshconnect2.c ] | ||
82 | + Adapt to deal with additional element in Authmethod structure. Thanks to | ||
83 | + Colin Watson | ||
84 | + | ||
85 | +20090615 | ||
86 | + - [ gss-genr.c gss-serv.c kexgssc.c kexgsss.c monitor.c sshconnect2.c | ||
87 | + sshd.c ] | ||
88 | + Fix issues identified by Greg Hudson following a code review | ||
89 | + Check return value of gss_indicate_mechs | ||
90 | + Protect GSSAPI calls in monitor, so they can only be used if enabled | ||
91 | + Check return values of bignum functions in key exchange | ||
92 | + Use BN_clear_free to clear other side's DH value | ||
93 | + Make ssh_gssapi_id_kex more robust | ||
94 | + Only configure kex table pointers if GSSAPI is enabled | ||
95 | + Don't leak mechanism list, or gss mechanism list | ||
96 | + Cast data.length before printing | ||
97 | + If serverkey isn't provided, use an empty string, rather than NULL | ||
98 | + | ||
99 | +20090201 | ||
100 | + - [ gss-genr.c gss-serv.c kex.h kexgssc.c readconf.c readconf.h ssh-gss.h | ||
101 | + ssh_config.5 sshconnet2.c ] | ||
102 | + Add support for the GSSAPIClientIdentity option, which allows the user | ||
103 | + to specify which GSSAPI identity to use to contact a given server | ||
104 | + | ||
105 | +20080404 | ||
106 | + - [ gss-serv.c ] | ||
107 | + Add code to actually implement GSSAPIStrictAcceptCheck, which had somehow | ||
108 | + been omitted from a previous version of this patch. Reported by Borislav | ||
109 | + Stoichkov | ||
110 | + | ||
111 | +20070317 | ||
112 | + - [ gss-serv-krb5.c ] | ||
113 | + Remove C99ism, where new_ccname was being declared in the middle of a | ||
114 | + function | ||
115 | + | ||
116 | +20061220 | ||
117 | + - [ servconf.c ] | ||
118 | + Make default for GSSAPIStrictAcceptorCheck be Yes, to match previous, and | ||
119 | + documented, behaviour. Reported by Dan Watson. | ||
120 | + | ||
121 | +20060910 | ||
122 | + - [ gss-genr.c kexgssc.c kexgsss.c kex.h monitor.c sshconnect2.c sshd.c | ||
123 | + ssh-gss.h ] | ||
124 | + add support for gss-group14-sha1 key exchange mechanisms | ||
125 | + - [ gss-serv.c servconf.c servconf.h sshd_config sshd_config.5 ] | ||
126 | + Add GSSAPIStrictAcceptorCheck option to allow the disabling of | ||
127 | + acceptor principal checking on multi-homed machines. | ||
128 | + <Bugzilla #928> | ||
129 | + - [ sshd_config ssh_config ] | ||
130 | + Add settings for GSSAPIKeyExchange and GSSAPITrustDNS to the sample | ||
131 | + configuration files | ||
132 | + - [ kexgss.c kegsss.c sshconnect2.c sshd.c ] | ||
133 | + Code cleanup. Replace strlen/xmalloc/snprintf sequences with xasprintf() | ||
134 | + Limit length of error messages displayed by client | ||
135 | + | ||
136 | +20060909 | ||
137 | + - [ gss-genr.c gss-serv.c ] | ||
138 | + move ssh_gssapi_acquire_cred() and ssh_gssapi_server_ctx to be server | ||
139 | + only, where they belong | ||
140 | + <Bugzilla #1225> | ||
141 | + | ||
142 | +20060829 | ||
143 | + - [ gss-serv-krb5.c ] | ||
144 | + Fix CCAPI credentials cache name when creating KRB5CCNAME environment | ||
145 | + variable | ||
146 | + | ||
147 | +20060828 | ||
148 | + - [ gss-genr.c ] | ||
149 | + Avoid Heimdal context freeing problem | ||
150 | + <Fixed upstream 20060829> | ||
151 | + | ||
152 | +20060818 | ||
153 | + - [ gss-genr.c ssh-gss.h sshconnect2.c ] | ||
154 | + Make sure that SPENGO is disabled | ||
155 | + <Bugzilla #1218 - Fixed upstream 20060818> | ||
156 | + | ||
157 | +20060421 | ||
158 | + - [ gssgenr.c, sshconnect2.c ] | ||
159 | + a few type changes (signed versus unsigned, int versus size_t) to | ||
160 | + fix compiler errors/warnings | ||
161 | + (from jbasney AT ncsa.uiuc.edu) | ||
162 | + - [ kexgssc.c, sshconnect2.c ] | ||
163 | + fix uninitialized variable warnings | ||
164 | + (from jbasney AT ncsa.uiuc.edu) | ||
165 | + - [ gssgenr.c ] | ||
166 | + pass oid to gss_display_status (helpful when using GSSAPI mechglue) | ||
167 | + (from jbasney AT ncsa.uiuc.edu) | ||
168 | + <Bugzilla #1220 > | ||
169 | + - [ gss-serv-krb5.c ] | ||
170 | + #ifdef HAVE_GSSAPI_KRB5 should be #ifdef HAVE_GSSAPI_KRB5_H | ||
171 | + (from jbasney AT ncsa.uiuc.edu) | ||
172 | + <Fixed upstream 20060304> | ||
173 | + - [ readconf.c, readconf.h, ssh_config.5, sshconnect2.c | ||
174 | + add client-side GssapiKeyExchange option | ||
175 | + (from jbasney AT ncsa.uiuc.edu) | ||
176 | + - [ sshconnect2.c ] | ||
177 | + add support for GssapiTrustDns option for gssapi-with-mic | ||
178 | + (from jbasney AT ncsa.uiuc.edu) | ||
179 | + <gssapi-with-mic support is Bugzilla #1008> | ||
180 | diff --git a/Makefile.in b/Makefile.in | ||
181 | index 40cc7aa..3d2a328 100644 | ||
182 | --- a/Makefile.in | ||
183 | +++ b/Makefile.in | ||
184 | @@ -91,7 +91,8 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \ | ||
185 | sc25519.o ge25519.o fe25519.o ed25519.o verify.o hash.o blocks.o \ | ||
186 | kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \ | ||
187 | kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \ | ||
188 | - kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o | ||
189 | + kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o \ | ||
190 | + kexgssc.o | ||
191 | |||
192 | SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \ | ||
193 | sshconnect.o sshconnect1.o sshconnect2.o mux.o \ | ||
194 | @@ -105,7 +106,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \ | ||
195 | auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \ | ||
196 | auth2-none.o auth2-passwd.o auth2-pubkey.o \ | ||
197 | monitor_mm.o monitor.o monitor_wrap.o auth-krb5.o \ | ||
198 | - auth2-gss.o gss-serv.o gss-serv-krb5.o \ | ||
199 | + auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o \ | ||
200 | loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \ | ||
201 | sftp-server.o sftp-common.o \ | ||
202 | roaming_common.o roaming_serv.o \ | ||
203 | diff --git a/auth-krb5.c b/auth-krb5.c | ||
204 | index 0089b18..ec47869 100644 | ||
205 | --- a/auth-krb5.c | ||
206 | +++ b/auth-krb5.c | ||
207 | @@ -183,8 +183,13 @@ auth_krb5_password(Authctxt *authctxt, const char *password) | ||
208 | |||
209 | len = strlen(authctxt->krb5_ticket_file) + 6; | ||
210 | authctxt->krb5_ccname = xmalloc(len); | ||
211 | +#ifdef USE_CCAPI | ||
212 | + snprintf(authctxt->krb5_ccname, len, "API:%s", | ||
213 | + authctxt->krb5_ticket_file); | ||
214 | +#else | ||
215 | snprintf(authctxt->krb5_ccname, len, "FILE:%s", | ||
216 | authctxt->krb5_ticket_file); | ||
217 | +#endif | ||
218 | |||
219 | #ifdef USE_PAM | ||
220 | if (options.use_pam) | ||
221 | @@ -241,15 +246,22 @@ krb5_cleanup_proc(Authctxt *authctxt) | ||
222 | #ifndef HEIMDAL | ||
223 | krb5_error_code | ||
224 | ssh_krb5_cc_gen(krb5_context ctx, krb5_ccache *ccache) { | ||
225 | - int tmpfd, ret, oerrno; | ||
226 | + int ret, oerrno; | ||
227 | char ccname[40]; | ||
228 | mode_t old_umask; | ||
229 | +#ifdef USE_CCAPI | ||
230 | + char cctemplate[] = "API:krb5cc_%d"; | ||
231 | +#else | ||
232 | + char cctemplate[] = "FILE:/tmp/krb5cc_%d_XXXXXXXXXX"; | ||
233 | + int tmpfd; | ||
234 | +#endif | ||
235 | |||
236 | ret = snprintf(ccname, sizeof(ccname), | ||
237 | - "FILE:/tmp/krb5cc_%d_XXXXXXXXXX", geteuid()); | ||
238 | + cctemplate, geteuid()); | ||
239 | if (ret < 0 || (size_t)ret >= sizeof(ccname)) | ||
240 | return ENOMEM; | ||
241 | |||
242 | +#ifndef USE_CCAPI | ||
243 | old_umask = umask(0177); | ||
244 | tmpfd = mkstemp(ccname + strlen("FILE:")); | ||
245 | oerrno = errno; | ||
246 | @@ -266,6 +278,7 @@ ssh_krb5_cc_gen(krb5_context ctx, krb5_ccache *ccache) { | ||
247 | return oerrno; | ||
248 | } | ||
249 | close(tmpfd); | ||
250 | +#endif | ||
251 | |||
252 | return (krb5_cc_resolve(ctx, ccname, ccache)); | ||
253 | } | ||
254 | diff --git a/auth2-gss.c b/auth2-gss.c | ||
255 | index 1ca8357..3b5036d 100644 | ||
256 | --- a/auth2-gss.c | ||
257 | +++ b/auth2-gss.c | ||
258 | @@ -1,7 +1,7 @@ | ||
259 | /* $OpenBSD: auth2-gss.c,v 1.22 2015/01/19 20:07:45 markus Exp $ */ | ||
260 | |||
261 | /* | ||
262 | - * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | ||
263 | + * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved. | ||
264 | * | ||
265 | * Redistribution and use in source and binary forms, with or without | ||
266 | * modification, are permitted provided that the following conditions | ||
267 | @@ -53,6 +53,40 @@ static int input_gssapi_mic(int type, u_int32_t plen, void *ctxt); | ||
268 | static int input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt); | ||
269 | static int input_gssapi_errtok(int, u_int32_t, void *); | ||
270 | |||
271 | +/* | ||
272 | + * The 'gssapi_keyex' userauth mechanism. | ||
273 | + */ | ||
274 | +static int | ||
275 | +userauth_gsskeyex(Authctxt *authctxt) | ||
276 | +{ | ||
277 | + int authenticated = 0; | ||
278 | + Buffer b; | ||
279 | + gss_buffer_desc mic, gssbuf; | ||
280 | + u_int len; | ||
281 | + | ||
282 | + mic.value = packet_get_string(&len); | ||
283 | + mic.length = len; | ||
284 | + | ||
285 | + packet_check_eom(); | ||
286 | + | ||
287 | + ssh_gssapi_buildmic(&b, authctxt->user, authctxt->service, | ||
288 | + "gssapi-keyex"); | ||
289 | + | ||
290 | + gssbuf.value = buffer_ptr(&b); | ||
291 | + gssbuf.length = buffer_len(&b); | ||
292 | + | ||
293 | + /* gss_kex_context is NULL with privsep, so we can't check it here */ | ||
294 | + if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gss_kex_context, | ||
295 | + &gssbuf, &mic)))) | ||
296 | + authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user, | ||
297 | + authctxt->pw)); | ||
298 | + | ||
299 | + buffer_free(&b); | ||
300 | + free(mic.value); | ||
301 | + | ||
302 | + return (authenticated); | ||
303 | +} | ||
304 | + | ||
305 | /* | ||
306 | * We only support those mechanisms that we know about (ie ones that we know | ||
307 | * how to check local user kuserok and the like) | ||
308 | @@ -238,7 +272,8 @@ input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt) | ||
309 | |||
310 | packet_check_eom(); | ||
311 | |||
312 | - authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user)); | ||
313 | + authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user, | ||
314 | + authctxt->pw)); | ||
315 | |||
316 | authctxt->postponed = 0; | ||
317 | dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL); | ||
318 | @@ -274,7 +309,8 @@ input_gssapi_mic(int type, u_int32_t plen, void *ctxt) | ||
319 | gssbuf.length = buffer_len(&b); | ||
320 | |||
321 | if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gssctxt, &gssbuf, &mic)))) | ||
322 | - authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user)); | ||
323 | + authenticated = | ||
324 | + PRIVSEP(ssh_gssapi_userok(authctxt->user, authctxt->pw)); | ||
325 | else | ||
326 | logit("GSSAPI MIC check failed"); | ||
327 | |||
328 | @@ -290,6 +326,12 @@ input_gssapi_mic(int type, u_int32_t plen, void *ctxt) | ||
329 | return 0; | ||
330 | } | ||
331 | |||
332 | +Authmethod method_gsskeyex = { | ||
333 | + "gssapi-keyex", | ||
334 | + userauth_gsskeyex, | ||
335 | + &options.gss_authentication | ||
336 | +}; | ||
337 | + | ||
338 | Authmethod method_gssapi = { | ||
339 | "gssapi-with-mic", | ||
340 | userauth_gssapi, | ||
341 | diff --git a/auth2.c b/auth2.c | ||
342 | index 7177962..3f49bdc 100644 | ||
343 | --- a/auth2.c | ||
344 | +++ b/auth2.c | ||
345 | @@ -70,6 +70,7 @@ extern Authmethod method_passwd; | ||
346 | extern Authmethod method_kbdint; | ||
347 | extern Authmethod method_hostbased; | ||
348 | #ifdef GSSAPI | ||
349 | +extern Authmethod method_gsskeyex; | ||
350 | extern Authmethod method_gssapi; | ||
351 | #endif | ||
352 | |||
353 | @@ -77,6 +78,7 @@ Authmethod *authmethods[] = { | ||
354 | &method_none, | ||
355 | &method_pubkey, | ||
356 | #ifdef GSSAPI | ||
357 | + &method_gsskeyex, | ||
358 | &method_gssapi, | ||
359 | #endif | ||
360 | &method_passwd, | ||
361 | diff --git a/clientloop.c b/clientloop.c | ||
362 | index dc0e557..77d5498 100644 | ||
363 | --- a/clientloop.c | ||
364 | +++ b/clientloop.c | ||
365 | @@ -114,6 +114,10 @@ | ||
366 | #include "ssherr.h" | ||
367 | #include "hostfile.h" | ||
368 | |||
369 | +#ifdef GSSAPI | ||
370 | +#include "ssh-gss.h" | ||
371 | +#endif | ||
372 | + | ||
373 | /* import options */ | ||
374 | extern Options options; | ||
375 | |||
376 | @@ -1609,6 +1613,15 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | ||
377 | /* Do channel operations unless rekeying in progress. */ | ||
378 | if (!rekeying) { | ||
379 | channel_after_select(readset, writeset); | ||
380 | + | ||
381 | +#ifdef GSSAPI | ||
382 | + if (options.gss_renewal_rekey && | ||
383 | + ssh_gssapi_credentials_updated(NULL)) { | ||
384 | + debug("credentials updated - forcing rekey"); | ||
385 | + need_rekeying = 1; | ||
386 | + } | ||
387 | +#endif | ||
388 | + | ||
389 | if (need_rekeying || packet_need_rekeying()) { | ||
390 | debug("need rekeying"); | ||
391 | active_state->kex->done = 0; | ||
392 | diff --git a/config.h.in b/config.h.in | ||
393 | index 7e7e38e..6c7de98 100644 | ||
394 | --- a/config.h.in | ||
395 | +++ b/config.h.in | ||
396 | @@ -1623,6 +1623,9 @@ | ||
397 | /* Use btmp to log bad logins */ | ||
398 | #undef USE_BTMP | ||
399 | |||
400 | +/* platform uses an in-memory credentials cache */ | ||
401 | +#undef USE_CCAPI | ||
402 | + | ||
403 | /* Use libedit for sftp */ | ||
404 | #undef USE_LIBEDIT | ||
405 | |||
406 | @@ -1638,6 +1641,9 @@ | ||
407 | /* Use PIPES instead of a socketpair() */ | ||
408 | #undef USE_PIPES | ||
409 | |||
410 | +/* platform has the Security Authorization Session API */ | ||
411 | +#undef USE_SECURITY_SESSION_API | ||
412 | + | ||
413 | /* Define if you have Solaris process contracts */ | ||
414 | #undef USE_SOLARIS_PROCESS_CONTRACTS | ||
415 | |||
416 | diff --git a/configure.ac b/configure.ac | ||
417 | index bb0095f..df21693 100644 | ||
418 | --- a/configure.ac | ||
419 | +++ b/configure.ac | ||
420 | @@ -625,6 +625,30 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) | ||
421 | [Use tunnel device compatibility to OpenBSD]) | ||
422 | AC_DEFINE([SSH_TUN_PREPEND_AF], [1], | ||
423 | [Prepend the address family to IP tunnel traffic]) | ||
424 | + AC_MSG_CHECKING([if we have the Security Authorization Session API]) | ||
425 | + AC_TRY_COMPILE([#include <Security/AuthSession.h>], | ||
426 | + [SessionCreate(0, 0);], | ||
427 | + [ac_cv_use_security_session_api="yes" | ||
428 | + AC_DEFINE([USE_SECURITY_SESSION_API], [1], | ||
429 | + [platform has the Security Authorization Session API]) | ||
430 | + LIBS="$LIBS -framework Security" | ||
431 | + AC_MSG_RESULT([yes])], | ||
432 | + [ac_cv_use_security_session_api="no" | ||
433 | + AC_MSG_RESULT([no])]) | ||
434 | + AC_MSG_CHECKING([if we have an in-memory credentials cache]) | ||
435 | + AC_TRY_COMPILE( | ||
436 | + [#include <Kerberos/Kerberos.h>], | ||
437 | + [cc_context_t c; | ||
438 | + (void) cc_initialize (&c, 0, NULL, NULL);], | ||
439 | + [AC_DEFINE([USE_CCAPI], [1], | ||
440 | + [platform uses an in-memory credentials cache]) | ||
441 | + LIBS="$LIBS -framework Security" | ||
442 | + AC_MSG_RESULT([yes]) | ||
443 | + if test "x$ac_cv_use_security_session_api" = "xno"; then | ||
444 | + AC_MSG_ERROR([*** Need a security framework to use the credentials cache API ***]) | ||
445 | + fi], | ||
446 | + [AC_MSG_RESULT([no])] | ||
447 | + ) | ||
448 | m4_pattern_allow([AU_IPv]) | ||
449 | AC_CHECK_DECL([AU_IPv4], [], | ||
450 | AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records]) | ||
451 | diff --git a/gss-genr.c b/gss-genr.c | ||
452 | index d617d60..b4eca3f 100644 | ||
453 | --- a/gss-genr.c | ||
454 | +++ b/gss-genr.c | ||
455 | @@ -1,7 +1,7 @@ | ||
456 | /* $OpenBSD: gss-genr.c,v 1.23 2015/01/20 23:14:00 deraadt Exp $ */ | ||
457 | |||
458 | /* | ||
459 | - * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved. | ||
460 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
461 | * | ||
462 | * Redistribution and use in source and binary forms, with or without | ||
463 | * modification, are permitted provided that the following conditions | ||
464 | @@ -41,12 +41,167 @@ | ||
465 | #include "buffer.h" | ||
466 | #include "log.h" | ||
467 | #include "ssh2.h" | ||
468 | +#include "cipher.h" | ||
469 | +#include "key.h" | ||
470 | +#include "kex.h" | ||
471 | +#include <openssl/evp.h> | ||
472 | |||
473 | #include "ssh-gss.h" | ||
474 | |||
475 | extern u_char *session_id2; | ||
476 | extern u_int session_id2_len; | ||
477 | |||
478 | +typedef struct { | ||
479 | + char *encoded; | ||
480 | + gss_OID oid; | ||
481 | +} ssh_gss_kex_mapping; | ||
482 | + | ||
483 | +/* | ||
484 | + * XXX - It would be nice to find a more elegant way of handling the | ||
485 | + * XXX passing of the key exchange context to the userauth routines | ||
486 | + */ | ||
487 | + | ||
488 | +Gssctxt *gss_kex_context = NULL; | ||
489 | + | ||
490 | +static ssh_gss_kex_mapping *gss_enc2oid = NULL; | ||
491 | + | ||
492 | +int | ||
493 | +ssh_gssapi_oid_table_ok(void) { | ||
494 | + return (gss_enc2oid != NULL); | ||
495 | +} | ||
496 | + | ||
497 | +/* | ||
498 | + * Return a list of the gss-group1-sha1 mechanisms supported by this program | ||
499 | + * | ||
500 | + * We test mechanisms to ensure that we can use them, to avoid starting | ||
501 | + * a key exchange with a bad mechanism | ||
502 | + */ | ||
503 | + | ||
504 | +char * | ||
505 | +ssh_gssapi_client_mechanisms(const char *host, const char *client) { | ||
506 | + gss_OID_set gss_supported; | ||
507 | + OM_uint32 min_status; | ||
508 | + | ||
509 | + if (GSS_ERROR(gss_indicate_mechs(&min_status, &gss_supported))) | ||
510 | + return NULL; | ||
511 | + | ||
512 | + return(ssh_gssapi_kex_mechs(gss_supported, ssh_gssapi_check_mechanism, | ||
513 | + host, client)); | ||
514 | +} | ||
515 | + | ||
516 | +char * | ||
517 | +ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check, | ||
518 | + const char *host, const char *client) { | ||
519 | + Buffer buf; | ||
520 | + size_t i; | ||
521 | + int oidpos, enclen; | ||
522 | + char *mechs, *encoded; | ||
523 | + u_char digest[EVP_MAX_MD_SIZE]; | ||
524 | + char deroid[2]; | ||
525 | + const EVP_MD *evp_md = EVP_md5(); | ||
526 | + EVP_MD_CTX md; | ||
527 | + | ||
528 | + if (gss_enc2oid != NULL) { | ||
529 | + for (i = 0; gss_enc2oid[i].encoded != NULL; i++) | ||
530 | + free(gss_enc2oid[i].encoded); | ||
531 | + free(gss_enc2oid); | ||
532 | + } | ||
533 | + | ||
534 | + gss_enc2oid = xmalloc(sizeof(ssh_gss_kex_mapping) * | ||
535 | + (gss_supported->count + 1)); | ||
536 | + | ||
537 | + buffer_init(&buf); | ||
538 | + | ||
539 | + oidpos = 0; | ||
540 | + for (i = 0; i < gss_supported->count; i++) { | ||
541 | + if (gss_supported->elements[i].length < 128 && | ||
542 | + (*check)(NULL, &(gss_supported->elements[i]), host, client)) { | ||
543 | + | ||
544 | + deroid[0] = SSH_GSS_OIDTYPE; | ||
545 | + deroid[1] = gss_supported->elements[i].length; | ||
546 | + | ||
547 | + EVP_DigestInit(&md, evp_md); | ||
548 | + EVP_DigestUpdate(&md, deroid, 2); | ||
549 | + EVP_DigestUpdate(&md, | ||
550 | + gss_supported->elements[i].elements, | ||
551 | + gss_supported->elements[i].length); | ||
552 | + EVP_DigestFinal(&md, digest, NULL); | ||
553 | + | ||
554 | + encoded = xmalloc(EVP_MD_size(evp_md) * 2); | ||
555 | + enclen = __b64_ntop(digest, EVP_MD_size(evp_md), | ||
556 | + encoded, EVP_MD_size(evp_md) * 2); | ||
557 | + | ||
558 | + if (oidpos != 0) | ||
559 | + buffer_put_char(&buf, ','); | ||
560 | + | ||
561 | + buffer_append(&buf, KEX_GSS_GEX_SHA1_ID, | ||
562 | + sizeof(KEX_GSS_GEX_SHA1_ID) - 1); | ||
563 | + buffer_append(&buf, encoded, enclen); | ||
564 | + buffer_put_char(&buf, ','); | ||
565 | + buffer_append(&buf, KEX_GSS_GRP1_SHA1_ID, | ||
566 | + sizeof(KEX_GSS_GRP1_SHA1_ID) - 1); | ||
567 | + buffer_append(&buf, encoded, enclen); | ||
568 | + buffer_put_char(&buf, ','); | ||
569 | + buffer_append(&buf, KEX_GSS_GRP14_SHA1_ID, | ||
570 | + sizeof(KEX_GSS_GRP14_SHA1_ID) - 1); | ||
571 | + buffer_append(&buf, encoded, enclen); | ||
572 | + | ||
573 | + gss_enc2oid[oidpos].oid = &(gss_supported->elements[i]); | ||
574 | + gss_enc2oid[oidpos].encoded = encoded; | ||
575 | + oidpos++; | ||
576 | + } | ||
577 | + } | ||
578 | + gss_enc2oid[oidpos].oid = NULL; | ||
579 | + gss_enc2oid[oidpos].encoded = NULL; | ||
580 | + | ||
581 | + buffer_put_char(&buf, '\0'); | ||
582 | + | ||
583 | + mechs = xmalloc(buffer_len(&buf)); | ||
584 | + buffer_get(&buf, mechs, buffer_len(&buf)); | ||
585 | + buffer_free(&buf); | ||
586 | + | ||
587 | + if (strlen(mechs) == 0) { | ||
588 | + free(mechs); | ||
589 | + mechs = NULL; | ||
590 | + } | ||
591 | + | ||
592 | + return (mechs); | ||
593 | +} | ||
594 | + | ||
595 | +gss_OID | ||
596 | +ssh_gssapi_id_kex(Gssctxt *ctx, char *name, int kex_type) { | ||
597 | + int i = 0; | ||
598 | + | ||
599 | + switch (kex_type) { | ||
600 | + case KEX_GSS_GRP1_SHA1: | ||
601 | + if (strlen(name) < sizeof(KEX_GSS_GRP1_SHA1_ID)) | ||
602 | + return GSS_C_NO_OID; | ||
603 | + name += sizeof(KEX_GSS_GRP1_SHA1_ID) - 1; | ||
604 | + break; | ||
605 | + case KEX_GSS_GRP14_SHA1: | ||
606 | + if (strlen(name) < sizeof(KEX_GSS_GRP14_SHA1_ID)) | ||
607 | + return GSS_C_NO_OID; | ||
608 | + name += sizeof(KEX_GSS_GRP14_SHA1_ID) - 1; | ||
609 | + break; | ||
610 | + case KEX_GSS_GEX_SHA1: | ||
611 | + if (strlen(name) < sizeof(KEX_GSS_GEX_SHA1_ID)) | ||
612 | + return GSS_C_NO_OID; | ||
613 | + name += sizeof(KEX_GSS_GEX_SHA1_ID) - 1; | ||
614 | + break; | ||
615 | + default: | ||
616 | + return GSS_C_NO_OID; | ||
617 | + } | ||
618 | + | ||
619 | + while (gss_enc2oid[i].encoded != NULL && | ||
620 | + strcmp(name, gss_enc2oid[i].encoded) != 0) | ||
621 | + i++; | ||
622 | + | ||
623 | + if (gss_enc2oid[i].oid != NULL && ctx != NULL) | ||
624 | + ssh_gssapi_set_oid(ctx, gss_enc2oid[i].oid); | ||
625 | + | ||
626 | + return gss_enc2oid[i].oid; | ||
627 | +} | ||
628 | + | ||
629 | /* Check that the OID in a data stream matches that in the context */ | ||
630 | int | ||
631 | ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len) | ||
632 | @@ -199,7 +354,7 @@ ssh_gssapi_init_ctx(Gssctxt *ctx, int deleg_creds, gss_buffer_desc *recv_tok, | ||
633 | } | ||
634 | |||
635 | ctx->major = gss_init_sec_context(&ctx->minor, | ||
636 | - GSS_C_NO_CREDENTIAL, &ctx->context, ctx->name, ctx->oid, | ||
637 | + ctx->client_creds, &ctx->context, ctx->name, ctx->oid, | ||
638 | GSS_C_MUTUAL_FLAG | GSS_C_INTEG_FLAG | deleg_flag, | ||
639 | 0, NULL, recv_tok, NULL, send_tok, flags, NULL); | ||
640 | |||
641 | @@ -229,8 +384,42 @@ ssh_gssapi_import_name(Gssctxt *ctx, const char *host) | ||
642 | } | ||
643 | |||
644 | OM_uint32 | ||
645 | +ssh_gssapi_client_identity(Gssctxt *ctx, const char *name) | ||
646 | +{ | ||
647 | + gss_buffer_desc gssbuf; | ||
648 | + gss_name_t gssname; | ||
649 | + OM_uint32 status; | ||
650 | + gss_OID_set oidset; | ||
651 | + | ||
652 | + gssbuf.value = (void *) name; | ||
653 | + gssbuf.length = strlen(gssbuf.value); | ||
654 | + | ||
655 | + gss_create_empty_oid_set(&status, &oidset); | ||
656 | + gss_add_oid_set_member(&status, ctx->oid, &oidset); | ||
657 | + | ||
658 | + ctx->major = gss_import_name(&ctx->minor, &gssbuf, | ||
659 | + GSS_C_NT_USER_NAME, &gssname); | ||
660 | + | ||
661 | + if (!ctx->major) | ||
662 | + ctx->major = gss_acquire_cred(&ctx->minor, | ||
663 | + gssname, 0, oidset, GSS_C_INITIATE, | ||
664 | + &ctx->client_creds, NULL, NULL); | ||
665 | + | ||
666 | + gss_release_name(&status, &gssname); | ||
667 | + gss_release_oid_set(&status, &oidset); | ||
668 | + | ||
669 | + if (ctx->major) | ||
670 | + ssh_gssapi_error(ctx); | ||
671 | + | ||
672 | + return(ctx->major); | ||
673 | +} | ||
674 | + | ||
675 | +OM_uint32 | ||
676 | ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash) | ||
677 | { | ||
678 | + if (ctx == NULL) | ||
679 | + return -1; | ||
680 | + | ||
681 | if ((ctx->major = gss_get_mic(&ctx->minor, ctx->context, | ||
682 | GSS_C_QOP_DEFAULT, buffer, hash))) | ||
683 | ssh_gssapi_error(ctx); | ||
684 | @@ -238,6 +427,19 @@ ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash) | ||
685 | return (ctx->major); | ||
686 | } | ||
687 | |||
688 | +/* Priviledged when used by server */ | ||
689 | +OM_uint32 | ||
690 | +ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic) | ||
691 | +{ | ||
692 | + if (ctx == NULL) | ||
693 | + return -1; | ||
694 | + | ||
695 | + ctx->major = gss_verify_mic(&ctx->minor, ctx->context, | ||
696 | + gssbuf, gssmic, NULL); | ||
697 | + | ||
698 | + return (ctx->major); | ||
699 | +} | ||
700 | + | ||
701 | void | ||
702 | ssh_gssapi_buildmic(Buffer *b, const char *user, const char *service, | ||
703 | const char *context) | ||
704 | @@ -251,11 +453,16 @@ ssh_gssapi_buildmic(Buffer *b, const char *user, const char *service, | ||
705 | } | ||
706 | |||
707 | int | ||
708 | -ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host) | ||
709 | +ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host, | ||
710 | + const char *client) | ||
711 | { | ||
712 | gss_buffer_desc token = GSS_C_EMPTY_BUFFER; | ||
713 | OM_uint32 major, minor; | ||
714 | gss_OID_desc spnego_oid = {6, (void *)"\x2B\x06\x01\x05\x05\x02"}; | ||
715 | + Gssctxt *intctx = NULL; | ||
716 | + | ||
717 | + if (ctx == NULL) | ||
718 | + ctx = &intctx; | ||
719 | |||
720 | /* RFC 4462 says we MUST NOT do SPNEGO */ | ||
721 | if (oid->length == spnego_oid.length && | ||
722 | @@ -265,6 +472,10 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host) | ||
723 | ssh_gssapi_build_ctx(ctx); | ||
724 | ssh_gssapi_set_oid(*ctx, oid); | ||
725 | major = ssh_gssapi_import_name(*ctx, host); | ||
726 | + | ||
727 | + if (!GSS_ERROR(major) && client) | ||
728 | + major = ssh_gssapi_client_identity(*ctx, client); | ||
729 | + | ||
730 | if (!GSS_ERROR(major)) { | ||
731 | major = ssh_gssapi_init_ctx(*ctx, 0, GSS_C_NO_BUFFER, &token, | ||
732 | NULL); | ||
733 | @@ -274,10 +485,66 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host) | ||
734 | GSS_C_NO_BUFFER); | ||
735 | } | ||
736 | |||
737 | - if (GSS_ERROR(major)) | ||
738 | + if (GSS_ERROR(major) || intctx != NULL) | ||
739 | ssh_gssapi_delete_ctx(ctx); | ||
740 | |||
741 | return (!GSS_ERROR(major)); | ||
742 | } | ||
743 | |||
744 | +int | ||
745 | +ssh_gssapi_credentials_updated(Gssctxt *ctxt) { | ||
746 | + static gss_name_t saved_name = GSS_C_NO_NAME; | ||
747 | + static OM_uint32 saved_lifetime = 0; | ||
748 | + static gss_OID saved_mech = GSS_C_NO_OID; | ||
749 | + static gss_name_t name; | ||
750 | + static OM_uint32 last_call = 0; | ||
751 | + OM_uint32 lifetime, now, major, minor; | ||
752 | + int equal; | ||
753 | + | ||
754 | + now = time(NULL); | ||
755 | + | ||
756 | + if (ctxt) { | ||
757 | + debug("Rekey has happened - updating saved versions"); | ||
758 | + | ||
759 | + if (saved_name != GSS_C_NO_NAME) | ||
760 | + gss_release_name(&minor, &saved_name); | ||
761 | + | ||
762 | + major = gss_inquire_cred(&minor, GSS_C_NO_CREDENTIAL, | ||
763 | + &saved_name, &saved_lifetime, NULL, NULL); | ||
764 | + | ||
765 | + if (!GSS_ERROR(major)) { | ||
766 | + saved_mech = ctxt->oid; | ||
767 | + saved_lifetime+= now; | ||
768 | + } else { | ||
769 | + /* Handle the error */ | ||
770 | + } | ||
771 | + return 0; | ||
772 | + } | ||
773 | + | ||
774 | + if (now - last_call < 10) | ||
775 | + return 0; | ||
776 | + | ||
777 | + last_call = now; | ||
778 | + | ||
779 | + if (saved_mech == GSS_C_NO_OID) | ||
780 | + return 0; | ||
781 | + | ||
782 | + major = gss_inquire_cred(&minor, GSS_C_NO_CREDENTIAL, | ||
783 | + &name, &lifetime, NULL, NULL); | ||
784 | + if (major == GSS_S_CREDENTIALS_EXPIRED) | ||
785 | + return 0; | ||
786 | + else if (GSS_ERROR(major)) | ||
787 | + return 0; | ||
788 | + | ||
789 | + major = gss_compare_name(&minor, saved_name, name, &equal); | ||
790 | + gss_release_name(&minor, &name); | ||
791 | + if (GSS_ERROR(major)) | ||
792 | + return 0; | ||
793 | + | ||
794 | + if (equal && (saved_lifetime < lifetime + now - 10)) | ||
795 | + return 1; | ||
796 | + | ||
797 | + return 0; | ||
798 | +} | ||
799 | + | ||
800 | #endif /* GSSAPI */ | ||
801 | diff --git a/gss-serv-krb5.c b/gss-serv-krb5.c | ||
802 | index 795992d..fd8b371 100644 | ||
803 | --- a/gss-serv-krb5.c | ||
804 | +++ b/gss-serv-krb5.c | ||
805 | @@ -1,7 +1,7 @@ | ||
806 | /* $OpenBSD: gss-serv-krb5.c,v 1.8 2013/07/20 01:55:13 djm Exp $ */ | ||
807 | |||
808 | /* | ||
809 | - * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | ||
810 | + * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved. | ||
811 | * | ||
812 | * Redistribution and use in source and binary forms, with or without | ||
813 | * modification, are permitted provided that the following conditions | ||
814 | @@ -121,8 +121,8 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client) | ||
815 | krb5_error_code problem; | ||
816 | krb5_principal princ; | ||
817 | OM_uint32 maj_status, min_status; | ||
818 | - int len; | ||
819 | const char *errmsg; | ||
820 | + const char *new_ccname; | ||
821 | |||
822 | if (client->creds == NULL) { | ||
823 | debug("No credentials stored"); | ||
824 | @@ -181,11 +181,16 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client) | ||
825 | return; | ||
826 | } | ||
827 | |||
828 | - client->store.filename = xstrdup(krb5_cc_get_name(krb_context, ccache)); | ||
829 | + new_ccname = krb5_cc_get_name(krb_context, ccache); | ||
830 | + | ||
831 | client->store.envvar = "KRB5CCNAME"; | ||
832 | - len = strlen(client->store.filename) + 6; | ||
833 | - client->store.envval = xmalloc(len); | ||
834 | - snprintf(client->store.envval, len, "FILE:%s", client->store.filename); | ||
835 | +#ifdef USE_CCAPI | ||
836 | + xasprintf(&client->store.envval, "API:%s", new_ccname); | ||
837 | + client->store.filename = NULL; | ||
838 | +#else | ||
839 | + xasprintf(&client->store.envval, "FILE:%s", new_ccname); | ||
840 | + client->store.filename = xstrdup(new_ccname); | ||
841 | +#endif | ||
842 | |||
843 | #ifdef USE_PAM | ||
844 | if (options.use_pam) | ||
845 | @@ -197,6 +202,71 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client) | ||
846 | return; | ||
847 | } | ||
848 | |||
849 | +int | ||
850 | +ssh_gssapi_krb5_updatecreds(ssh_gssapi_ccache *store, | ||
851 | + ssh_gssapi_client *client) | ||
852 | +{ | ||
853 | + krb5_ccache ccache = NULL; | ||
854 | + krb5_principal principal = NULL; | ||
855 | + char *name = NULL; | ||
856 | + krb5_error_code problem; | ||
857 | + OM_uint32 maj_status, min_status; | ||
858 | + | ||
859 | + if ((problem = krb5_cc_resolve(krb_context, store->envval, &ccache))) { | ||
860 | + logit("krb5_cc_resolve(): %.100s", | ||
861 | + krb5_get_err_text(krb_context, problem)); | ||
862 | + return 0; | ||
863 | + } | ||
864 | + | ||
865 | + /* Find out who the principal in this cache is */ | ||
866 | + if ((problem = krb5_cc_get_principal(krb_context, ccache, | ||
867 | + &principal))) { | ||
868 | + logit("krb5_cc_get_principal(): %.100s", | ||
869 | + krb5_get_err_text(krb_context, problem)); | ||
870 | + krb5_cc_close(krb_context, ccache); | ||
871 | + return 0; | ||
872 | + } | ||
873 | + | ||
874 | + if ((problem = krb5_unparse_name(krb_context, principal, &name))) { | ||
875 | + logit("krb5_unparse_name(): %.100s", | ||
876 | + krb5_get_err_text(krb_context, problem)); | ||
877 | + krb5_free_principal(krb_context, principal); | ||
878 | + krb5_cc_close(krb_context, ccache); | ||
879 | + return 0; | ||
880 | + } | ||
881 | + | ||
882 | + | ||
883 | + if (strcmp(name,client->exportedname.value)!=0) { | ||
884 | + debug("Name in local credentials cache differs. Not storing"); | ||
885 | + krb5_free_principal(krb_context, principal); | ||
886 | + krb5_cc_close(krb_context, ccache); | ||
887 | + krb5_free_unparsed_name(krb_context, name); | ||
888 | + return 0; | ||
889 | + } | ||
890 | + krb5_free_unparsed_name(krb_context, name); | ||
891 | + | ||
892 | + /* Name matches, so lets get on with it! */ | ||
893 | + | ||
894 | + if ((problem = krb5_cc_initialize(krb_context, ccache, principal))) { | ||
895 | + logit("krb5_cc_initialize(): %.100s", | ||
896 | + krb5_get_err_text(krb_context, problem)); | ||
897 | + krb5_free_principal(krb_context, principal); | ||
898 | + krb5_cc_close(krb_context, ccache); | ||
899 | + return 0; | ||
900 | + } | ||
901 | + | ||
902 | + krb5_free_principal(krb_context, principal); | ||
903 | + | ||
904 | + if ((maj_status = gss_krb5_copy_ccache(&min_status, client->creds, | ||
905 | + ccache))) { | ||
906 | + logit("gss_krb5_copy_ccache() failed. Sorry!"); | ||
907 | + krb5_cc_close(krb_context, ccache); | ||
908 | + return 0; | ||
909 | + } | ||
910 | + | ||
911 | + return 1; | ||
912 | +} | ||
913 | + | ||
914 | ssh_gssapi_mech gssapi_kerberos_mech = { | ||
915 | "toWM5Slw5Ew8Mqkay+al2g==", | ||
916 | "Kerberos", | ||
917 | @@ -204,7 +274,8 @@ ssh_gssapi_mech gssapi_kerberos_mech = { | ||
918 | NULL, | ||
919 | &ssh_gssapi_krb5_userok, | ||
920 | NULL, | ||
921 | - &ssh_gssapi_krb5_storecreds | ||
922 | + &ssh_gssapi_krb5_storecreds, | ||
923 | + &ssh_gssapi_krb5_updatecreds | ||
924 | }; | ||
925 | |||
926 | #endif /* KRB5 */ | ||
927 | diff --git a/gss-serv.c b/gss-serv.c | ||
928 | index 53993d6..2f6baf7 100644 | ||
929 | --- a/gss-serv.c | ||
930 | +++ b/gss-serv.c | ||
931 | @@ -1,7 +1,7 @@ | ||
932 | /* $OpenBSD: gss-serv.c,v 1.29 2015/05/22 03:50:02 djm Exp $ */ | ||
933 | |||
934 | /* | ||
935 | - * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | ||
936 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
937 | * | ||
938 | * Redistribution and use in source and binary forms, with or without | ||
939 | * modification, are permitted provided that the following conditions | ||
940 | @@ -45,17 +45,22 @@ | ||
941 | #include "session.h" | ||
942 | #include "misc.h" | ||
943 | #include "servconf.h" | ||
944 | +#include "uidswap.h" | ||
945 | |||
946 | #include "ssh-gss.h" | ||
947 | +#include "monitor_wrap.h" | ||
948 | + | ||
949 | +extern ServerOptions options; | ||
950 | |||
951 | extern ServerOptions options; | ||
952 | |||
953 | static ssh_gssapi_client gssapi_client = | ||
954 | { GSS_C_EMPTY_BUFFER, GSS_C_EMPTY_BUFFER, | ||
955 | - GSS_C_NO_CREDENTIAL, NULL, {NULL, NULL, NULL, NULL}}; | ||
956 | + GSS_C_NO_CREDENTIAL, GSS_C_NO_NAME, NULL, | ||
957 | + {NULL, NULL, NULL, NULL, NULL}, 0, 0}; | ||
958 | |||
959 | ssh_gssapi_mech gssapi_null_mech = | ||
960 | - { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL}; | ||
961 | + { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL, NULL}; | ||
962 | |||
963 | #ifdef KRB5 | ||
964 | extern ssh_gssapi_mech gssapi_kerberos_mech; | ||
965 | @@ -142,6 +147,29 @@ ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid) | ||
966 | } | ||
967 | |||
968 | /* Unprivileged */ | ||
969 | +char * | ||
970 | +ssh_gssapi_server_mechanisms(void) { | ||
971 | + gss_OID_set supported; | ||
972 | + | ||
973 | + ssh_gssapi_supported_oids(&supported); | ||
974 | + return (ssh_gssapi_kex_mechs(supported, &ssh_gssapi_server_check_mech, | ||
975 | + NULL, NULL)); | ||
976 | +} | ||
977 | + | ||
978 | +/* Unprivileged */ | ||
979 | +int | ||
980 | +ssh_gssapi_server_check_mech(Gssctxt **dum, gss_OID oid, const char *data, | ||
981 | + const char *dummy) { | ||
982 | + Gssctxt *ctx = NULL; | ||
983 | + int res; | ||
984 | + | ||
985 | + res = !GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctx, oid))); | ||
986 | + ssh_gssapi_delete_ctx(&ctx); | ||
987 | + | ||
988 | + return (res); | ||
989 | +} | ||
990 | + | ||
991 | +/* Unprivileged */ | ||
992 | void | ||
993 | ssh_gssapi_supported_oids(gss_OID_set *oidset) | ||
994 | { | ||
995 | @@ -151,7 +179,9 @@ ssh_gssapi_supported_oids(gss_OID_set *oidset) | ||
996 | gss_OID_set supported; | ||
997 | |||
998 | gss_create_empty_oid_set(&min_status, oidset); | ||
999 | - gss_indicate_mechs(&min_status, &supported); | ||
1000 | + | ||
1001 | + if (GSS_ERROR(gss_indicate_mechs(&min_status, &supported))) | ||
1002 | + return; | ||
1003 | |||
1004 | while (supported_mechs[i]->name != NULL) { | ||
1005 | if (GSS_ERROR(gss_test_oid_set_member(&min_status, | ||
1006 | @@ -277,8 +307,48 @@ OM_uint32 | ||
1007 | ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client) | ||
1008 | { | ||
1009 | int i = 0; | ||
1010 | + int equal = 0; | ||
1011 | + gss_name_t new_name = GSS_C_NO_NAME; | ||
1012 | + gss_buffer_desc ename = GSS_C_EMPTY_BUFFER; | ||
1013 | + | ||
1014 | + if (options.gss_store_rekey && client->used && ctx->client_creds) { | ||
1015 | + if (client->mech->oid.length != ctx->oid->length || | ||
1016 | + (memcmp(client->mech->oid.elements, | ||
1017 | + ctx->oid->elements, ctx->oid->length) !=0)) { | ||
1018 | + debug("Rekeyed credentials have different mechanism"); | ||
1019 | + return GSS_S_COMPLETE; | ||
1020 | + } | ||
1021 | + | ||
1022 | + if ((ctx->major = gss_inquire_cred_by_mech(&ctx->minor, | ||
1023 | + ctx->client_creds, ctx->oid, &new_name, | ||
1024 | + NULL, NULL, NULL))) { | ||
1025 | + ssh_gssapi_error(ctx); | ||
1026 | + return (ctx->major); | ||
1027 | + } | ||
1028 | + | ||
1029 | + ctx->major = gss_compare_name(&ctx->minor, client->name, | ||
1030 | + new_name, &equal); | ||
1031 | + | ||
1032 | + if (GSS_ERROR(ctx->major)) { | ||
1033 | + ssh_gssapi_error(ctx); | ||
1034 | + return (ctx->major); | ||
1035 | + } | ||
1036 | + | ||
1037 | + if (!equal) { | ||
1038 | + debug("Rekeyed credentials have different name"); | ||
1039 | + return GSS_S_COMPLETE; | ||
1040 | + } | ||
1041 | |||
1042 | - gss_buffer_desc ename; | ||
1043 | + debug("Marking rekeyed credentials for export"); | ||
1044 | + | ||
1045 | + gss_release_name(&ctx->minor, &client->name); | ||
1046 | + gss_release_cred(&ctx->minor, &client->creds); | ||
1047 | + client->name = new_name; | ||
1048 | + client->creds = ctx->client_creds; | ||
1049 | + ctx->client_creds = GSS_C_NO_CREDENTIAL; | ||
1050 | + client->updated = 1; | ||
1051 | + return GSS_S_COMPLETE; | ||
1052 | + } | ||
1053 | |||
1054 | client->mech = NULL; | ||
1055 | |||
1056 | @@ -293,6 +363,13 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client) | ||
1057 | if (client->mech == NULL) | ||
1058 | return GSS_S_FAILURE; | ||
1059 | |||
1060 | + if (ctx->client_creds && | ||
1061 | + (ctx->major = gss_inquire_cred_by_mech(&ctx->minor, | ||
1062 | + ctx->client_creds, ctx->oid, &client->name, NULL, NULL, NULL))) { | ||
1063 | + ssh_gssapi_error(ctx); | ||
1064 | + return (ctx->major); | ||
1065 | + } | ||
1066 | + | ||
1067 | if ((ctx->major = gss_display_name(&ctx->minor, ctx->client, | ||
1068 | &client->displayname, NULL))) { | ||
1069 | ssh_gssapi_error(ctx); | ||
1070 | @@ -310,6 +387,8 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client) | ||
1071 | return (ctx->major); | ||
1072 | } | ||
1073 | |||
1074 | + gss_release_buffer(&ctx->minor, &ename); | ||
1075 | + | ||
1076 | /* We can't copy this structure, so we just move the pointer to it */ | ||
1077 | client->creds = ctx->client_creds; | ||
1078 | ctx->client_creds = GSS_C_NO_CREDENTIAL; | ||
1079 | @@ -357,7 +436,7 @@ ssh_gssapi_do_child(char ***envp, u_int *envsizep) | ||
1080 | |||
1081 | /* Privileged */ | ||
1082 | int | ||
1083 | -ssh_gssapi_userok(char *user) | ||
1084 | +ssh_gssapi_userok(char *user, struct passwd *pw) | ||
1085 | { | ||
1086 | OM_uint32 lmin; | ||
1087 | |||
1088 | @@ -367,9 +446,11 @@ ssh_gssapi_userok(char *user) | ||
1089 | return 0; | ||
1090 | } | ||
1091 | if (gssapi_client.mech && gssapi_client.mech->userok) | ||
1092 | - if ((*gssapi_client.mech->userok)(&gssapi_client, user)) | ||
1093 | + if ((*gssapi_client.mech->userok)(&gssapi_client, user)) { | ||
1094 | + gssapi_client.used = 1; | ||
1095 | + gssapi_client.store.owner = pw; | ||
1096 | return 1; | ||
1097 | - else { | ||
1098 | + } else { | ||
1099 | /* Destroy delegated credentials if userok fails */ | ||
1100 | gss_release_buffer(&lmin, &gssapi_client.displayname); | ||
1101 | gss_release_buffer(&lmin, &gssapi_client.exportedname); | ||
1102 | @@ -383,14 +464,90 @@ ssh_gssapi_userok(char *user) | ||
1103 | return (0); | ||
1104 | } | ||
1105 | |||
1106 | -/* Privileged */ | ||
1107 | -OM_uint32 | ||
1108 | -ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic) | ||
1109 | +/* These bits are only used for rekeying. The unpriviledged child is running | ||
1110 | + * as the user, the monitor is root. | ||
1111 | + * | ||
1112 | + * In the child, we want to : | ||
1113 | + * *) Ask the monitor to store our credentials into the store we specify | ||
1114 | + * *) If it succeeds, maybe do a PAM update | ||
1115 | + */ | ||
1116 | + | ||
1117 | +/* Stuff for PAM */ | ||
1118 | + | ||
1119 | +#ifdef USE_PAM | ||
1120 | +static int ssh_gssapi_simple_conv(int n, const struct pam_message **msg, | ||
1121 | + struct pam_response **resp, void *data) | ||
1122 | { | ||
1123 | - ctx->major = gss_verify_mic(&ctx->minor, ctx->context, | ||
1124 | - gssbuf, gssmic, NULL); | ||
1125 | + return (PAM_CONV_ERR); | ||
1126 | +} | ||
1127 | +#endif | ||
1128 | |||
1129 | - return (ctx->major); | ||
1130 | +void | ||
1131 | +ssh_gssapi_rekey_creds(void) { | ||
1132 | + int ok; | ||
1133 | + int ret; | ||
1134 | +#ifdef USE_PAM | ||
1135 | + pam_handle_t *pamh = NULL; | ||
1136 | + struct pam_conv pamconv = {ssh_gssapi_simple_conv, NULL}; | ||
1137 | + char *envstr; | ||
1138 | +#endif | ||
1139 | + | ||
1140 | + if (gssapi_client.store.filename == NULL && | ||
1141 | + gssapi_client.store.envval == NULL && | ||
1142 | + gssapi_client.store.envvar == NULL) | ||
1143 | + return; | ||
1144 | + | ||
1145 | + ok = PRIVSEP(ssh_gssapi_update_creds(&gssapi_client.store)); | ||
1146 | + | ||
1147 | + if (!ok) | ||
1148 | + return; | ||
1149 | + | ||
1150 | + debug("Rekeyed credentials stored successfully"); | ||
1151 | + | ||
1152 | + /* Actually managing to play with the ssh pam stack from here will | ||
1153 | + * be next to impossible. In any case, we may want different options | ||
1154 | + * for rekeying. So, use our own :) | ||
1155 | + */ | ||
1156 | +#ifdef USE_PAM | ||
1157 | + if (!use_privsep) { | ||
1158 | + debug("Not even going to try and do PAM with privsep disabled"); | ||
1159 | + return; | ||
1160 | + } | ||
1161 | + | ||
1162 | + ret = pam_start("sshd-rekey", gssapi_client.store.owner->pw_name, | ||
1163 | + &pamconv, &pamh); | ||
1164 | + if (ret) | ||
1165 | + return; | ||
1166 | + | ||
1167 | + xasprintf(&envstr, "%s=%s", gssapi_client.store.envvar, | ||
1168 | + gssapi_client.store.envval); | ||
1169 | + | ||
1170 | + ret = pam_putenv(pamh, envstr); | ||
1171 | + if (!ret) | ||
1172 | + pam_setcred(pamh, PAM_REINITIALIZE_CRED); | ||
1173 | + pam_end(pamh, PAM_SUCCESS); | ||
1174 | +#endif | ||
1175 | +} | ||
1176 | + | ||
1177 | +int | ||
1178 | +ssh_gssapi_update_creds(ssh_gssapi_ccache *store) { | ||
1179 | + int ok = 0; | ||
1180 | + | ||
1181 | + /* Check we've got credentials to store */ | ||
1182 | + if (!gssapi_client.updated) | ||
1183 | + return 0; | ||
1184 | + | ||
1185 | + gssapi_client.updated = 0; | ||
1186 | + | ||
1187 | + temporarily_use_uid(gssapi_client.store.owner); | ||
1188 | + if (gssapi_client.mech && gssapi_client.mech->updatecreds) | ||
1189 | + ok = (*gssapi_client.mech->updatecreds)(store, &gssapi_client); | ||
1190 | + else | ||
1191 | + debug("No update function for this mechanism"); | ||
1192 | + | ||
1193 | + restore_uid(); | ||
1194 | + | ||
1195 | + return ok; | ||
1196 | } | ||
1197 | |||
1198 | #endif | ||
1199 | diff --git a/kex.c b/kex.c | ||
1200 | index dbc55ef..4d8e6f5 100644 | ||
1201 | --- a/kex.c | ||
1202 | +++ b/kex.c | ||
1203 | @@ -55,6 +55,10 @@ | ||
1204 | #include "sshbuf.h" | ||
1205 | #include "digest.h" | ||
1206 | |||
1207 | +#ifdef GSSAPI | ||
1208 | +#include "ssh-gss.h" | ||
1209 | +#endif | ||
1210 | + | ||
1211 | #if OPENSSL_VERSION_NUMBER >= 0x00907000L | ||
1212 | # if defined(HAVE_EVP_SHA256) | ||
1213 | # define evp_ssh_sha256 EVP_sha256 | ||
1214 | @@ -97,6 +101,14 @@ static const struct kexalg kexalgs[] = { | ||
1215 | #endif /* HAVE_EVP_SHA256 || !WITH_OPENSSL */ | ||
1216 | { NULL, -1, -1, -1}, | ||
1217 | }; | ||
1218 | +static const struct kexalg kexalg_prefixes[] = { | ||
1219 | +#ifdef GSSAPI | ||
1220 | + { KEX_GSS_GEX_SHA1_ID, KEX_GSS_GEX_SHA1, 0, SSH_DIGEST_SHA1 }, | ||
1221 | + { KEX_GSS_GRP1_SHA1_ID, KEX_GSS_GRP1_SHA1, 0, SSH_DIGEST_SHA1 }, | ||
1222 | + { KEX_GSS_GRP14_SHA1_ID, KEX_GSS_GRP14_SHA1, 0, SSH_DIGEST_SHA1 }, | ||
1223 | +#endif | ||
1224 | + { NULL, -1, -1, -1 }, | ||
1225 | +}; | ||
1226 | |||
1227 | char * | ||
1228 | kex_alg_list(char sep) | ||
1229 | @@ -129,6 +141,10 @@ kex_alg_by_name(const char *name) | ||
1230 | if (strcmp(k->name, name) == 0) | ||
1231 | return k; | ||
1232 | } | ||
1233 | + for (k = kexalg_prefixes; k->name != NULL; k++) { | ||
1234 | + if (strncmp(k->name, name, strlen(k->name)) == 0) | ||
1235 | + return k; | ||
1236 | + } | ||
1237 | return NULL; | ||
1238 | } | ||
1239 | |||
1240 | diff --git a/kex.h b/kex.h | ||
1241 | index f70b81f..7194b14 100644 | ||
1242 | --- a/kex.h | ||
1243 | +++ b/kex.h | ||
1244 | @@ -93,6 +93,9 @@ enum kex_exchange { | ||
1245 | KEX_DH_GEX_SHA256, | ||
1246 | KEX_ECDH_SHA2, | ||
1247 | KEX_C25519_SHA256, | ||
1248 | + KEX_GSS_GRP1_SHA1, | ||
1249 | + KEX_GSS_GRP14_SHA1, | ||
1250 | + KEX_GSS_GEX_SHA1, | ||
1251 | KEX_MAX | ||
1252 | }; | ||
1253 | |||
1254 | @@ -139,6 +142,12 @@ struct kex { | ||
1255 | u_int flags; | ||
1256 | int hash_alg; | ||
1257 | int ec_nid; | ||
1258 | +#ifdef GSSAPI | ||
1259 | + int gss_deleg_creds; | ||
1260 | + int gss_trust_dns; | ||
1261 | + char *gss_host; | ||
1262 | + char *gss_client; | ||
1263 | +#endif | ||
1264 | char *client_version_string; | ||
1265 | char *server_version_string; | ||
1266 | int (*verify_host_key)(struct sshkey *, struct ssh *); | ||
1267 | @@ -184,6 +193,11 @@ int kexecdh_server(struct ssh *); | ||
1268 | int kexc25519_client(struct ssh *); | ||
1269 | int kexc25519_server(struct ssh *); | ||
1270 | |||
1271 | +#ifdef GSSAPI | ||
1272 | +int kexgss_client(struct ssh *); | ||
1273 | +int kexgss_server(struct ssh *); | ||
1274 | +#endif | ||
1275 | + | ||
1276 | int kex_dh_hash(const char *, const char *, | ||
1277 | const u_char *, size_t, const u_char *, size_t, const u_char *, size_t, | ||
1278 | const BIGNUM *, const BIGNUM *, const BIGNUM *, u_char *, size_t *); | ||
1279 | diff --git a/kexgssc.c b/kexgssc.c | ||
1280 | new file mode 100644 | ||
1281 | index 0000000..a49bac2 | ||
1282 | --- /dev/null | ||
1283 | +++ b/kexgssc.c | ||
1284 | @@ -0,0 +1,336 @@ | ||
1285 | +/* | ||
1286 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
1287 | + * | ||
1288 | + * Redistribution and use in source and binary forms, with or without | ||
1289 | + * modification, are permitted provided that the following conditions | ||
1290 | + * are met: | ||
1291 | + * 1. Redistributions of source code must retain the above copyright | ||
1292 | + * notice, this list of conditions and the following disclaimer. | ||
1293 | + * 2. Redistributions in binary form must reproduce the above copyright | ||
1294 | + * notice, this list of conditions and the following disclaimer in the | ||
1295 | + * documentation and/or other materials provided with the distribution. | ||
1296 | + * | ||
1297 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR | ||
1298 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
1299 | + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
1300 | + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
1301 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
1302 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
1303 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
1304 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
1305 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
1306 | + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
1307 | + */ | ||
1308 | + | ||
1309 | +#include "includes.h" | ||
1310 | + | ||
1311 | +#ifdef GSSAPI | ||
1312 | + | ||
1313 | +#include "includes.h" | ||
1314 | + | ||
1315 | +#include <openssl/crypto.h> | ||
1316 | +#include <openssl/bn.h> | ||
1317 | + | ||
1318 | +#include <string.h> | ||
1319 | + | ||
1320 | +#include "xmalloc.h" | ||
1321 | +#include "buffer.h" | ||
1322 | +#include "ssh2.h" | ||
1323 | +#include "key.h" | ||
1324 | +#include "cipher.h" | ||
1325 | +#include "kex.h" | ||
1326 | +#include "log.h" | ||
1327 | +#include "packet.h" | ||
1328 | +#include "dh.h" | ||
1329 | +#include "digest.h" | ||
1330 | + | ||
1331 | +#include "ssh-gss.h" | ||
1332 | + | ||
1333 | +int | ||
1334 | +kexgss_client(struct ssh *ssh) { | ||
1335 | + gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER; | ||
1336 | + gss_buffer_desc recv_tok, gssbuf, msg_tok, *token_ptr; | ||
1337 | + Gssctxt *ctxt; | ||
1338 | + OM_uint32 maj_status, min_status, ret_flags; | ||
1339 | + u_int klen, kout, slen = 0, strlen; | ||
1340 | + DH *dh; | ||
1341 | + BIGNUM *dh_server_pub = NULL; | ||
1342 | + BIGNUM *shared_secret = NULL; | ||
1343 | + BIGNUM *p = NULL; | ||
1344 | + BIGNUM *g = NULL; | ||
1345 | + u_char *kbuf; | ||
1346 | + u_char *serverhostkey = NULL; | ||
1347 | + u_char *empty = ""; | ||
1348 | + char *msg; | ||
1349 | + int type = 0; | ||
1350 | + int first = 1; | ||
1351 | + int nbits = 0, min = DH_GRP_MIN, max = DH_GRP_MAX; | ||
1352 | + u_char hash[SSH_DIGEST_MAX_LENGTH]; | ||
1353 | + size_t hashlen; | ||
1354 | + | ||
1355 | + /* Initialise our GSSAPI world */ | ||
1356 | + ssh_gssapi_build_ctx(&ctxt); | ||
1357 | + if (ssh_gssapi_id_kex(ctxt, ssh->kex->name, ssh->kex->kex_type) | ||
1358 | + == GSS_C_NO_OID) | ||
1359 | + fatal("Couldn't identify host exchange"); | ||
1360 | + | ||
1361 | + if (ssh_gssapi_import_name(ctxt, ssh->kex->gss_host)) | ||
1362 | + fatal("Couldn't import hostname"); | ||
1363 | + | ||
1364 | + if (ssh->kex->gss_client && | ||
1365 | + ssh_gssapi_client_identity(ctxt, ssh->kex->gss_client)) | ||
1366 | + fatal("Couldn't acquire client credentials"); | ||
1367 | + | ||
1368 | + switch (ssh->kex->kex_type) { | ||
1369 | + case KEX_GSS_GRP1_SHA1: | ||
1370 | + dh = dh_new_group1(); | ||
1371 | + break; | ||
1372 | + case KEX_GSS_GRP14_SHA1: | ||
1373 | + dh = dh_new_group14(); | ||
1374 | + break; | ||
1375 | + case KEX_GSS_GEX_SHA1: | ||
1376 | + debug("Doing group exchange\n"); | ||
1377 | + nbits = dh_estimate(ssh->kex->we_need * 8); | ||
1378 | + packet_start(SSH2_MSG_KEXGSS_GROUPREQ); | ||
1379 | + packet_put_int(min); | ||
1380 | + packet_put_int(nbits); | ||
1381 | + packet_put_int(max); | ||
1382 | + | ||
1383 | + packet_send(); | ||
1384 | + | ||
1385 | + packet_read_expect(SSH2_MSG_KEXGSS_GROUP); | ||
1386 | + | ||
1387 | + if ((p = BN_new()) == NULL) | ||
1388 | + fatal("BN_new() failed"); | ||
1389 | + packet_get_bignum2(p); | ||
1390 | + if ((g = BN_new()) == NULL) | ||
1391 | + fatal("BN_new() failed"); | ||
1392 | + packet_get_bignum2(g); | ||
1393 | + packet_check_eom(); | ||
1394 | + | ||
1395 | + if (BN_num_bits(p) < min || BN_num_bits(p) > max) | ||
1396 | + fatal("GSSGRP_GEX group out of range: %d !< %d !< %d", | ||
1397 | + min, BN_num_bits(p), max); | ||
1398 | + | ||
1399 | + dh = dh_new_group(g, p); | ||
1400 | + break; | ||
1401 | + default: | ||
1402 | + fatal("%s: Unexpected KEX type %d", __func__, ssh->kex->kex_type); | ||
1403 | + } | ||
1404 | + | ||
1405 | + /* Step 1 - e is dh->pub_key */ | ||
1406 | + dh_gen_key(dh, ssh->kex->we_need * 8); | ||
1407 | + | ||
1408 | + /* This is f, we initialise it now to make life easier */ | ||
1409 | + dh_server_pub = BN_new(); | ||
1410 | + if (dh_server_pub == NULL) | ||
1411 | + fatal("dh_server_pub == NULL"); | ||
1412 | + | ||
1413 | + token_ptr = GSS_C_NO_BUFFER; | ||
1414 | + | ||
1415 | + do { | ||
1416 | + debug("Calling gss_init_sec_context"); | ||
1417 | + | ||
1418 | + maj_status = ssh_gssapi_init_ctx(ctxt, | ||
1419 | + ssh->kex->gss_deleg_creds, token_ptr, &send_tok, | ||
1420 | + &ret_flags); | ||
1421 | + | ||
1422 | + if (GSS_ERROR(maj_status)) { | ||
1423 | + if (send_tok.length != 0) { | ||
1424 | + packet_start(SSH2_MSG_KEXGSS_CONTINUE); | ||
1425 | + packet_put_string(send_tok.value, | ||
1426 | + send_tok.length); | ||
1427 | + } | ||
1428 | + fatal("gss_init_context failed"); | ||
1429 | + } | ||
1430 | + | ||
1431 | + /* If we've got an old receive buffer get rid of it */ | ||
1432 | + if (token_ptr != GSS_C_NO_BUFFER) | ||
1433 | + free(recv_tok.value); | ||
1434 | + | ||
1435 | + if (maj_status == GSS_S_COMPLETE) { | ||
1436 | + /* If mutual state flag is not true, kex fails */ | ||
1437 | + if (!(ret_flags & GSS_C_MUTUAL_FLAG)) | ||
1438 | + fatal("Mutual authentication failed"); | ||
1439 | + | ||
1440 | + /* If integ avail flag is not true kex fails */ | ||
1441 | + if (!(ret_flags & GSS_C_INTEG_FLAG)) | ||
1442 | + fatal("Integrity check failed"); | ||
1443 | + } | ||
1444 | + | ||
1445 | + /* | ||
1446 | + * If we have data to send, then the last message that we | ||
1447 | + * received cannot have been a 'complete'. | ||
1448 | + */ | ||
1449 | + if (send_tok.length != 0) { | ||
1450 | + if (first) { | ||
1451 | + packet_start(SSH2_MSG_KEXGSS_INIT); | ||
1452 | + packet_put_string(send_tok.value, | ||
1453 | + send_tok.length); | ||
1454 | + packet_put_bignum2(dh->pub_key); | ||
1455 | + first = 0; | ||
1456 | + } else { | ||
1457 | + packet_start(SSH2_MSG_KEXGSS_CONTINUE); | ||
1458 | + packet_put_string(send_tok.value, | ||
1459 | + send_tok.length); | ||
1460 | + } | ||
1461 | + packet_send(); | ||
1462 | + gss_release_buffer(&min_status, &send_tok); | ||
1463 | + | ||
1464 | + /* If we've sent them data, they should reply */ | ||
1465 | + do { | ||
1466 | + type = packet_read(); | ||
1467 | + if (type == SSH2_MSG_KEXGSS_HOSTKEY) { | ||
1468 | + debug("Received KEXGSS_HOSTKEY"); | ||
1469 | + if (serverhostkey) | ||
1470 | + fatal("Server host key received more than once"); | ||
1471 | + serverhostkey = | ||
1472 | + packet_get_string(&slen); | ||
1473 | + } | ||
1474 | + } while (type == SSH2_MSG_KEXGSS_HOSTKEY); | ||
1475 | + | ||
1476 | + switch (type) { | ||
1477 | + case SSH2_MSG_KEXGSS_CONTINUE: | ||
1478 | + debug("Received GSSAPI_CONTINUE"); | ||
1479 | + if (maj_status == GSS_S_COMPLETE) | ||
1480 | + fatal("GSSAPI Continue received from server when complete"); | ||
1481 | + recv_tok.value = packet_get_string(&strlen); | ||
1482 | + recv_tok.length = strlen; | ||
1483 | + break; | ||
1484 | + case SSH2_MSG_KEXGSS_COMPLETE: | ||
1485 | + debug("Received GSSAPI_COMPLETE"); | ||
1486 | + packet_get_bignum2(dh_server_pub); | ||
1487 | + msg_tok.value = packet_get_string(&strlen); | ||
1488 | + msg_tok.length = strlen; | ||
1489 | + | ||
1490 | + /* Is there a token included? */ | ||
1491 | + if (packet_get_char()) { | ||
1492 | + recv_tok.value= | ||
1493 | + packet_get_string(&strlen); | ||
1494 | + recv_tok.length = strlen; | ||
1495 | + /* If we're already complete - protocol error */ | ||
1496 | + if (maj_status == GSS_S_COMPLETE) | ||
1497 | + packet_disconnect("Protocol error: received token when complete"); | ||
1498 | + } else { | ||
1499 | + /* No token included */ | ||
1500 | + if (maj_status != GSS_S_COMPLETE) | ||
1501 | + packet_disconnect("Protocol error: did not receive final token"); | ||
1502 | + } | ||
1503 | + break; | ||
1504 | + case SSH2_MSG_KEXGSS_ERROR: | ||
1505 | + debug("Received Error"); | ||
1506 | + maj_status = packet_get_int(); | ||
1507 | + min_status = packet_get_int(); | ||
1508 | + msg = packet_get_string(NULL); | ||
1509 | + (void) packet_get_string_ptr(NULL); | ||
1510 | + fatal("GSSAPI Error: \n%.400s",msg); | ||
1511 | + default: | ||
1512 | + packet_disconnect("Protocol error: didn't expect packet type %d", | ||
1513 | + type); | ||
1514 | + } | ||
1515 | + token_ptr = &recv_tok; | ||
1516 | + } else { | ||
1517 | + /* No data, and not complete */ | ||
1518 | + if (maj_status != GSS_S_COMPLETE) | ||
1519 | + fatal("Not complete, and no token output"); | ||
1520 | + } | ||
1521 | + } while (maj_status & GSS_S_CONTINUE_NEEDED); | ||
1522 | + | ||
1523 | + /* | ||
1524 | + * We _must_ have received a COMPLETE message in reply from the | ||
1525 | + * server, which will have set dh_server_pub and msg_tok | ||
1526 | + */ | ||
1527 | + | ||
1528 | + if (type != SSH2_MSG_KEXGSS_COMPLETE) | ||
1529 | + fatal("Didn't receive a SSH2_MSG_KEXGSS_COMPLETE when I expected it"); | ||
1530 | + | ||
1531 | + /* Check f in range [1, p-1] */ | ||
1532 | + if (!dh_pub_is_valid(dh, dh_server_pub)) | ||
1533 | + packet_disconnect("bad server public DH value"); | ||
1534 | + | ||
1535 | + /* compute K=f^x mod p */ | ||
1536 | + klen = DH_size(dh); | ||
1537 | + kbuf = xmalloc(klen); | ||
1538 | + kout = DH_compute_key(kbuf, dh_server_pub, dh); | ||
1539 | + if (kout < 0) | ||
1540 | + fatal("DH_compute_key: failed"); | ||
1541 | + | ||
1542 | + shared_secret = BN_new(); | ||
1543 | + if (shared_secret == NULL) | ||
1544 | + fatal("kexgss_client: BN_new failed"); | ||
1545 | + | ||
1546 | + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) | ||
1547 | + fatal("kexdh_client: BN_bin2bn failed"); | ||
1548 | + | ||
1549 | + memset(kbuf, 0, klen); | ||
1550 | + free(kbuf); | ||
1551 | + | ||
1552 | + hashlen = sizeof(hash); | ||
1553 | + switch (ssh->kex->kex_type) { | ||
1554 | + case KEX_GSS_GRP1_SHA1: | ||
1555 | + case KEX_GSS_GRP14_SHA1: | ||
1556 | + kex_dh_hash( ssh->kex->client_version_string, | ||
1557 | + ssh->kex->server_version_string, | ||
1558 | + buffer_ptr(ssh->kex->my), buffer_len(ssh->kex->my), | ||
1559 | + buffer_ptr(ssh->kex->peer), buffer_len(ssh->kex->peer), | ||
1560 | + (serverhostkey ? serverhostkey : empty), slen, | ||
1561 | + dh->pub_key, /* e */ | ||
1562 | + dh_server_pub, /* f */ | ||
1563 | + shared_secret, /* K */ | ||
1564 | + hash, &hashlen | ||
1565 | + ); | ||
1566 | + break; | ||
1567 | + case KEX_GSS_GEX_SHA1: | ||
1568 | + kexgex_hash( | ||
1569 | + ssh->kex->hash_alg, | ||
1570 | + ssh->kex->client_version_string, | ||
1571 | + ssh->kex->server_version_string, | ||
1572 | + buffer_ptr(ssh->kex->my), buffer_len(ssh->kex->my), | ||
1573 | + buffer_ptr(ssh->kex->peer), buffer_len(ssh->kex->peer), | ||
1574 | + (serverhostkey ? serverhostkey : empty), slen, | ||
1575 | + min, nbits, max, | ||
1576 | + dh->p, dh->g, | ||
1577 | + dh->pub_key, | ||
1578 | + dh_server_pub, | ||
1579 | + shared_secret, | ||
1580 | + hash, &hashlen | ||
1581 | + ); | ||
1582 | + break; | ||
1583 | + default: | ||
1584 | + fatal("%s: Unexpected KEX type %d", __func__, ssh->kex->kex_type); | ||
1585 | + } | ||
1586 | + | ||
1587 | + gssbuf.value = hash; | ||
1588 | + gssbuf.length = hashlen; | ||
1589 | + | ||
1590 | + /* Verify that the hash matches the MIC we just got. */ | ||
1591 | + if (GSS_ERROR(ssh_gssapi_checkmic(ctxt, &gssbuf, &msg_tok))) | ||
1592 | + packet_disconnect("Hash's MIC didn't verify"); | ||
1593 | + | ||
1594 | + free(msg_tok.value); | ||
1595 | + | ||
1596 | + DH_free(dh); | ||
1597 | + free(serverhostkey); | ||
1598 | + BN_clear_free(dh_server_pub); | ||
1599 | + | ||
1600 | + /* save session id */ | ||
1601 | + if (ssh->kex->session_id == NULL) { | ||
1602 | + ssh->kex->session_id_len = hashlen; | ||
1603 | + ssh->kex->session_id = xmalloc(ssh->kex->session_id_len); | ||
1604 | + memcpy(ssh->kex->session_id, hash, ssh->kex->session_id_len); | ||
1605 | + } | ||
1606 | + | ||
1607 | + if (ssh->kex->gss_deleg_creds) | ||
1608 | + ssh_gssapi_credentials_updated(ctxt); | ||
1609 | + | ||
1610 | + if (gss_kex_context == NULL) | ||
1611 | + gss_kex_context = ctxt; | ||
1612 | + else | ||
1613 | + ssh_gssapi_delete_ctx(&ctxt); | ||
1614 | + | ||
1615 | + kex_derive_keys_bn(ssh, hash, hashlen, shared_secret); | ||
1616 | + BN_clear_free(shared_secret); | ||
1617 | + return kex_send_newkeys(ssh); | ||
1618 | +} | ||
1619 | + | ||
1620 | +#endif /* GSSAPI */ | ||
1621 | diff --git a/kexgsss.c b/kexgsss.c | ||
1622 | new file mode 100644 | ||
1623 | index 0000000..0847469 | ||
1624 | --- /dev/null | ||
1625 | +++ b/kexgsss.c | ||
1626 | @@ -0,0 +1,295 @@ | ||
1627 | +/* | ||
1628 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
1629 | + * | ||
1630 | + * Redistribution and use in source and binary forms, with or without | ||
1631 | + * modification, are permitted provided that the following conditions | ||
1632 | + * are met: | ||
1633 | + * 1. Redistributions of source code must retain the above copyright | ||
1634 | + * notice, this list of conditions and the following disclaimer. | ||
1635 | + * 2. Redistributions in binary form must reproduce the above copyright | ||
1636 | + * notice, this list of conditions and the following disclaimer in the | ||
1637 | + * documentation and/or other materials provided with the distribution. | ||
1638 | + * | ||
1639 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR | ||
1640 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
1641 | + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
1642 | + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
1643 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
1644 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
1645 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
1646 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
1647 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
1648 | + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
1649 | + */ | ||
1650 | + | ||
1651 | +#include "includes.h" | ||
1652 | + | ||
1653 | +#ifdef GSSAPI | ||
1654 | + | ||
1655 | +#include <string.h> | ||
1656 | + | ||
1657 | +#include <openssl/crypto.h> | ||
1658 | +#include <openssl/bn.h> | ||
1659 | + | ||
1660 | +#include "xmalloc.h" | ||
1661 | +#include "buffer.h" | ||
1662 | +#include "ssh2.h" | ||
1663 | +#include "key.h" | ||
1664 | +#include "cipher.h" | ||
1665 | +#include "kex.h" | ||
1666 | +#include "log.h" | ||
1667 | +#include "packet.h" | ||
1668 | +#include "dh.h" | ||
1669 | +#include "ssh-gss.h" | ||
1670 | +#include "monitor_wrap.h" | ||
1671 | +#include "misc.h" | ||
1672 | +#include "servconf.h" | ||
1673 | +#include "digest.h" | ||
1674 | + | ||
1675 | +extern ServerOptions options; | ||
1676 | + | ||
1677 | +int | ||
1678 | +kexgss_server(struct ssh *ssh) | ||
1679 | +{ | ||
1680 | + OM_uint32 maj_status, min_status; | ||
1681 | + | ||
1682 | + /* | ||
1683 | + * Some GSSAPI implementations use the input value of ret_flags (an | ||
1684 | + * output variable) as a means of triggering mechanism specific | ||
1685 | + * features. Initializing it to zero avoids inadvertently | ||
1686 | + * activating this non-standard behaviour. | ||
1687 | + */ | ||
1688 | + | ||
1689 | + OM_uint32 ret_flags = 0; | ||
1690 | + gss_buffer_desc gssbuf, recv_tok, msg_tok; | ||
1691 | + gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER; | ||
1692 | + Gssctxt *ctxt = NULL; | ||
1693 | + u_int slen, klen, kout; | ||
1694 | + u_char *kbuf; | ||
1695 | + DH *dh; | ||
1696 | + int min = -1, max = -1, nbits = -1; | ||
1697 | + BIGNUM *shared_secret = NULL; | ||
1698 | + BIGNUM *dh_client_pub = NULL; | ||
1699 | + int type = 0; | ||
1700 | + gss_OID oid; | ||
1701 | + char *mechs; | ||
1702 | + u_char hash[SSH_DIGEST_MAX_LENGTH]; | ||
1703 | + size_t hashlen; | ||
1704 | + | ||
1705 | + /* Initialise GSSAPI */ | ||
1706 | + | ||
1707 | + /* If we're rekeying, privsep means that some of the private structures | ||
1708 | + * in the GSSAPI code are no longer available. This kludges them back | ||
1709 | + * into life | ||
1710 | + */ | ||
1711 | + if (!ssh_gssapi_oid_table_ok()) { | ||
1712 | + mechs = ssh_gssapi_server_mechanisms(); | ||
1713 | + free(mechs); | ||
1714 | + } | ||
1715 | + | ||
1716 | + debug2("%s: Identifying %s", __func__, ssh->kex->name); | ||
1717 | + oid = ssh_gssapi_id_kex(NULL, ssh->kex->name, ssh->kex->kex_type); | ||
1718 | + if (oid == GSS_C_NO_OID) | ||
1719 | + fatal("Unknown gssapi mechanism"); | ||
1720 | + | ||
1721 | + debug2("%s: Acquiring credentials", __func__); | ||
1722 | + | ||
1723 | + if (GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctxt, oid)))) | ||
1724 | + fatal("Unable to acquire credentials for the server"); | ||
1725 | + | ||
1726 | + switch (ssh->kex->kex_type) { | ||
1727 | + case KEX_GSS_GRP1_SHA1: | ||
1728 | + dh = dh_new_group1(); | ||
1729 | + break; | ||
1730 | + case KEX_GSS_GRP14_SHA1: | ||
1731 | + dh = dh_new_group14(); | ||
1732 | + break; | ||
1733 | + case KEX_GSS_GEX_SHA1: | ||
1734 | + debug("Doing group exchange"); | ||
1735 | + packet_read_expect(SSH2_MSG_KEXGSS_GROUPREQ); | ||
1736 | + min = packet_get_int(); | ||
1737 | + nbits = packet_get_int(); | ||
1738 | + max = packet_get_int(); | ||
1739 | + min = MAX(DH_GRP_MIN, min); | ||
1740 | + max = MIN(DH_GRP_MAX, max); | ||
1741 | + packet_check_eom(); | ||
1742 | + if (max < min || nbits < min || max < nbits) | ||
1743 | + fatal("GSS_GEX, bad parameters: %d !< %d !< %d", | ||
1744 | + min, nbits, max); | ||
1745 | + dh = PRIVSEP(choose_dh(min, nbits, max)); | ||
1746 | + if (dh == NULL) | ||
1747 | + packet_disconnect("Protocol error: no matching group found"); | ||
1748 | + | ||
1749 | + packet_start(SSH2_MSG_KEXGSS_GROUP); | ||
1750 | + packet_put_bignum2(dh->p); | ||
1751 | + packet_put_bignum2(dh->g); | ||
1752 | + packet_send(); | ||
1753 | + | ||
1754 | + packet_write_wait(); | ||
1755 | + break; | ||
1756 | + default: | ||
1757 | + fatal("%s: Unexpected KEX type %d", __func__, ssh->kex->kex_type); | ||
1758 | + } | ||
1759 | + | ||
1760 | + dh_gen_key(dh, ssh->kex->we_need * 8); | ||
1761 | + | ||
1762 | + do { | ||
1763 | + debug("Wait SSH2_MSG_GSSAPI_INIT"); | ||
1764 | + type = packet_read(); | ||
1765 | + switch(type) { | ||
1766 | + case SSH2_MSG_KEXGSS_INIT: | ||
1767 | + if (dh_client_pub != NULL) | ||
1768 | + fatal("Received KEXGSS_INIT after initialising"); | ||
1769 | + recv_tok.value = packet_get_string(&slen); | ||
1770 | + recv_tok.length = slen; | ||
1771 | + | ||
1772 | + if ((dh_client_pub = BN_new()) == NULL) | ||
1773 | + fatal("dh_client_pub == NULL"); | ||
1774 | + | ||
1775 | + packet_get_bignum2(dh_client_pub); | ||
1776 | + | ||
1777 | + /* Send SSH_MSG_KEXGSS_HOSTKEY here, if we want */ | ||
1778 | + break; | ||
1779 | + case SSH2_MSG_KEXGSS_CONTINUE: | ||
1780 | + recv_tok.value = packet_get_string(&slen); | ||
1781 | + recv_tok.length = slen; | ||
1782 | + break; | ||
1783 | + default: | ||
1784 | + packet_disconnect( | ||
1785 | + "Protocol error: didn't expect packet type %d", | ||
1786 | + type); | ||
1787 | + } | ||
1788 | + | ||
1789 | + maj_status = PRIVSEP(ssh_gssapi_accept_ctx(ctxt, &recv_tok, | ||
1790 | + &send_tok, &ret_flags)); | ||
1791 | + | ||
1792 | + free(recv_tok.value); | ||
1793 | + | ||
1794 | + if (maj_status != GSS_S_COMPLETE && send_tok.length == 0) | ||
1795 | + fatal("Zero length token output when incomplete"); | ||
1796 | + | ||
1797 | + if (dh_client_pub == NULL) | ||
1798 | + fatal("No client public key"); | ||
1799 | + | ||
1800 | + if (maj_status & GSS_S_CONTINUE_NEEDED) { | ||
1801 | + debug("Sending GSSAPI_CONTINUE"); | ||
1802 | + packet_start(SSH2_MSG_KEXGSS_CONTINUE); | ||
1803 | + packet_put_string(send_tok.value, send_tok.length); | ||
1804 | + packet_send(); | ||
1805 | + gss_release_buffer(&min_status, &send_tok); | ||
1806 | + } | ||
1807 | + } while (maj_status & GSS_S_CONTINUE_NEEDED); | ||
1808 | + | ||
1809 | + if (GSS_ERROR(maj_status)) { | ||
1810 | + if (send_tok.length > 0) { | ||
1811 | + packet_start(SSH2_MSG_KEXGSS_CONTINUE); | ||
1812 | + packet_put_string(send_tok.value, send_tok.length); | ||
1813 | + packet_send(); | ||
1814 | + } | ||
1815 | + fatal("accept_ctx died"); | ||
1816 | + } | ||
1817 | + | ||
1818 | + if (!(ret_flags & GSS_C_MUTUAL_FLAG)) | ||
1819 | + fatal("Mutual Authentication flag wasn't set"); | ||
1820 | + | ||
1821 | + if (!(ret_flags & GSS_C_INTEG_FLAG)) | ||
1822 | + fatal("Integrity flag wasn't set"); | ||
1823 | + | ||
1824 | + if (!dh_pub_is_valid(dh, dh_client_pub)) | ||
1825 | + packet_disconnect("bad client public DH value"); | ||
1826 | + | ||
1827 | + klen = DH_size(dh); | ||
1828 | + kbuf = xmalloc(klen); | ||
1829 | + kout = DH_compute_key(kbuf, dh_client_pub, dh); | ||
1830 | + if (kout < 0) | ||
1831 | + fatal("DH_compute_key: failed"); | ||
1832 | + | ||
1833 | + shared_secret = BN_new(); | ||
1834 | + if (shared_secret == NULL) | ||
1835 | + fatal("kexgss_server: BN_new failed"); | ||
1836 | + | ||
1837 | + if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) | ||
1838 | + fatal("kexgss_server: BN_bin2bn failed"); | ||
1839 | + | ||
1840 | + memset(kbuf, 0, klen); | ||
1841 | + free(kbuf); | ||
1842 | + | ||
1843 | + hashlen = sizeof(hash); | ||
1844 | + switch (ssh->kex->kex_type) { | ||
1845 | + case KEX_GSS_GRP1_SHA1: | ||
1846 | + case KEX_GSS_GRP14_SHA1: | ||
1847 | + kex_dh_hash( | ||
1848 | + ssh->kex->client_version_string, ssh->kex->server_version_string, | ||
1849 | + buffer_ptr(ssh->kex->peer), buffer_len(ssh->kex->peer), | ||
1850 | + buffer_ptr(ssh->kex->my), buffer_len(ssh->kex->my), | ||
1851 | + NULL, 0, /* Change this if we start sending host keys */ | ||
1852 | + dh_client_pub, dh->pub_key, shared_secret, | ||
1853 | + hash, &hashlen | ||
1854 | + ); | ||
1855 | + break; | ||
1856 | + case KEX_GSS_GEX_SHA1: | ||
1857 | + kexgex_hash( | ||
1858 | + ssh->kex->hash_alg, | ||
1859 | + ssh->kex->client_version_string, ssh->kex->server_version_string, | ||
1860 | + buffer_ptr(ssh->kex->peer), buffer_len(ssh->kex->peer), | ||
1861 | + buffer_ptr(ssh->kex->my), buffer_len(ssh->kex->my), | ||
1862 | + NULL, 0, | ||
1863 | + min, nbits, max, | ||
1864 | + dh->p, dh->g, | ||
1865 | + dh_client_pub, | ||
1866 | + dh->pub_key, | ||
1867 | + shared_secret, | ||
1868 | + hash, &hashlen | ||
1869 | + ); | ||
1870 | + break; | ||
1871 | + default: | ||
1872 | + fatal("%s: Unexpected KEX type %d", __func__, ssh->kex->kex_type); | ||
1873 | + } | ||
1874 | + | ||
1875 | + BN_clear_free(dh_client_pub); | ||
1876 | + | ||
1877 | + if (ssh->kex->session_id == NULL) { | ||
1878 | + ssh->kex->session_id_len = hashlen; | ||
1879 | + ssh->kex->session_id = xmalloc(ssh->kex->session_id_len); | ||
1880 | + memcpy(ssh->kex->session_id, hash, ssh->kex->session_id_len); | ||
1881 | + } | ||
1882 | + | ||
1883 | + gssbuf.value = hash; | ||
1884 | + gssbuf.length = hashlen; | ||
1885 | + | ||
1886 | + if (GSS_ERROR(PRIVSEP(ssh_gssapi_sign(ctxt,&gssbuf,&msg_tok)))) | ||
1887 | + fatal("Couldn't get MIC"); | ||
1888 | + | ||
1889 | + packet_start(SSH2_MSG_KEXGSS_COMPLETE); | ||
1890 | + packet_put_bignum2(dh->pub_key); | ||
1891 | + packet_put_string(msg_tok.value,msg_tok.length); | ||
1892 | + | ||
1893 | + if (send_tok.length != 0) { | ||
1894 | + packet_put_char(1); /* true */ | ||
1895 | + packet_put_string(send_tok.value, send_tok.length); | ||
1896 | + } else { | ||
1897 | + packet_put_char(0); /* false */ | ||
1898 | + } | ||
1899 | + packet_send(); | ||
1900 | + | ||
1901 | + gss_release_buffer(&min_status, &send_tok); | ||
1902 | + gss_release_buffer(&min_status, &msg_tok); | ||
1903 | + | ||
1904 | + if (gss_kex_context == NULL) | ||
1905 | + gss_kex_context = ctxt; | ||
1906 | + else | ||
1907 | + ssh_gssapi_delete_ctx(&ctxt); | ||
1908 | + | ||
1909 | + DH_free(dh); | ||
1910 | + | ||
1911 | + kex_derive_keys_bn(ssh, hash, hashlen, shared_secret); | ||
1912 | + BN_clear_free(shared_secret); | ||
1913 | + kex_send_newkeys(ssh); | ||
1914 | + | ||
1915 | + /* If this was a rekey, then save out any delegated credentials we | ||
1916 | + * just exchanged. */ | ||
1917 | + if (options.gss_store_rekey) | ||
1918 | + ssh_gssapi_rekey_creds(); | ||
1919 | + return 0; | ||
1920 | +} | ||
1921 | +#endif /* GSSAPI */ | ||
1922 | diff --git a/monitor.c b/monitor.c | ||
1923 | index b410965..bdc2972 100644 | ||
1924 | --- a/monitor.c | ||
1925 | +++ b/monitor.c | ||
1926 | @@ -157,6 +157,8 @@ int mm_answer_gss_setup_ctx(int, Buffer *); | ||
1927 | int mm_answer_gss_accept_ctx(int, Buffer *); | ||
1928 | int mm_answer_gss_userok(int, Buffer *); | ||
1929 | int mm_answer_gss_checkmic(int, Buffer *); | ||
1930 | +int mm_answer_gss_sign(int, Buffer *); | ||
1931 | +int mm_answer_gss_updatecreds(int, Buffer *); | ||
1932 | #endif | ||
1933 | |||
1934 | #ifdef SSH_AUDIT_EVENTS | ||
1935 | @@ -234,11 +236,18 @@ struct mon_table mon_dispatch_proto20[] = { | ||
1936 | {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx}, | ||
1937 | {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok}, | ||
1938 | {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic}, | ||
1939 | + {MONITOR_REQ_GSSSIGN, MON_ONCE, mm_answer_gss_sign}, | ||
1940 | #endif | ||
1941 | {0, 0, NULL} | ||
1942 | }; | ||
1943 | |||
1944 | struct mon_table mon_dispatch_postauth20[] = { | ||
1945 | +#ifdef GSSAPI | ||
1946 | + {MONITOR_REQ_GSSSETUP, 0, mm_answer_gss_setup_ctx}, | ||
1947 | + {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx}, | ||
1948 | + {MONITOR_REQ_GSSSIGN, 0, mm_answer_gss_sign}, | ||
1949 | + {MONITOR_REQ_GSSUPCREDS, 0, mm_answer_gss_updatecreds}, | ||
1950 | +#endif | ||
1951 | #ifdef WITH_OPENSSL | ||
1952 | {MONITOR_REQ_MODULI, 0, mm_answer_moduli}, | ||
1953 | #endif | ||
1954 | @@ -353,6 +362,10 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor) | ||
1955 | /* Permit requests for moduli and signatures */ | ||
1956 | monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); | ||
1957 | monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); | ||
1958 | +#ifdef GSSAPI | ||
1959 | + /* and for the GSSAPI key exchange */ | ||
1960 | + monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1); | ||
1961 | +#endif | ||
1962 | } else { | ||
1963 | mon_dispatch = mon_dispatch_proto15; | ||
1964 | |||
1965 | @@ -461,6 +474,10 @@ monitor_child_postauth(struct monitor *pmonitor) | ||
1966 | monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); | ||
1967 | monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); | ||
1968 | monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); | ||
1969 | +#ifdef GSSAPI | ||
1970 | + /* and for the GSSAPI key exchange */ | ||
1971 | + monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1); | ||
1972 | +#endif | ||
1973 | } else { | ||
1974 | mon_dispatch = mon_dispatch_postauth15; | ||
1975 | monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); | ||
1976 | @@ -1864,6 +1881,13 @@ monitor_apply_keystate(struct monitor *pmonitor) | ||
1977 | # endif | ||
1978 | #endif /* WITH_OPENSSL */ | ||
1979 | kex->kex[KEX_C25519_SHA256] = kexc25519_server; | ||
1980 | +#ifdef GSSAPI | ||
1981 | + if (options.gss_keyex) { | ||
1982 | + kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; | ||
1983 | + kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server; | ||
1984 | + kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server; | ||
1985 | + } | ||
1986 | +#endif | ||
1987 | kex->load_host_public_key=&get_hostkey_public_by_type; | ||
1988 | kex->load_host_private_key=&get_hostkey_private_by_type; | ||
1989 | kex->host_key_index=&get_hostkey_index; | ||
1990 | @@ -1963,6 +1987,9 @@ mm_answer_gss_setup_ctx(int sock, Buffer *m) | ||
1991 | OM_uint32 major; | ||
1992 | u_int len; | ||
1993 | |||
1994 | + if (!options.gss_authentication && !options.gss_keyex) | ||
1995 | + fatal("In GSSAPI monitor when GSSAPI is disabled"); | ||
1996 | + | ||
1997 | goid.elements = buffer_get_string(m, &len); | ||
1998 | goid.length = len; | ||
1999 | |||
2000 | @@ -1990,6 +2017,9 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m) | ||
2001 | OM_uint32 flags = 0; /* GSI needs this */ | ||
2002 | u_int len; | ||
2003 | |||
2004 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2005 | + fatal("In GSSAPI monitor when GSSAPI is disabled"); | ||
2006 | + | ||
2007 | in.value = buffer_get_string(m, &len); | ||
2008 | in.length = len; | ||
2009 | major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags); | ||
2010 | @@ -2007,6 +2037,7 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m) | ||
2011 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0); | ||
2012 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1); | ||
2013 | monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1); | ||
2014 | + monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1); | ||
2015 | } | ||
2016 | return (0); | ||
2017 | } | ||
2018 | @@ -2018,6 +2049,9 @@ mm_answer_gss_checkmic(int sock, Buffer *m) | ||
2019 | OM_uint32 ret; | ||
2020 | u_int len; | ||
2021 | |||
2022 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2023 | + fatal("In GSSAPI monitor when GSSAPI is disabled"); | ||
2024 | + | ||
2025 | gssbuf.value = buffer_get_string(m, &len); | ||
2026 | gssbuf.length = len; | ||
2027 | mic.value = buffer_get_string(m, &len); | ||
2028 | @@ -2044,7 +2078,11 @@ mm_answer_gss_userok(int sock, Buffer *m) | ||
2029 | { | ||
2030 | int authenticated; | ||
2031 | |||
2032 | - authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user); | ||
2033 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2034 | + fatal("In GSSAPI monitor when GSSAPI is disabled"); | ||
2035 | + | ||
2036 | + authenticated = authctxt->valid && | ||
2037 | + ssh_gssapi_userok(authctxt->user, authctxt->pw); | ||
2038 | |||
2039 | buffer_clear(m); | ||
2040 | buffer_put_int(m, authenticated); | ||
2041 | @@ -2057,5 +2095,73 @@ mm_answer_gss_userok(int sock, Buffer *m) | ||
2042 | /* Monitor loop will terminate if authenticated */ | ||
2043 | return (authenticated); | ||
2044 | } | ||
2045 | + | ||
2046 | +int | ||
2047 | +mm_answer_gss_sign(int socket, Buffer *m) | ||
2048 | +{ | ||
2049 | + gss_buffer_desc data; | ||
2050 | + gss_buffer_desc hash = GSS_C_EMPTY_BUFFER; | ||
2051 | + OM_uint32 major, minor; | ||
2052 | + u_int len; | ||
2053 | + | ||
2054 | + if (!options.gss_authentication && !options.gss_keyex) | ||
2055 | + fatal("In GSSAPI monitor when GSSAPI is disabled"); | ||
2056 | + | ||
2057 | + data.value = buffer_get_string(m, &len); | ||
2058 | + data.length = len; | ||
2059 | + if (data.length != 20) | ||
2060 | + fatal("%s: data length incorrect: %d", __func__, | ||
2061 | + (int) data.length); | ||
2062 | + | ||
2063 | + /* Save the session ID on the first time around */ | ||
2064 | + if (session_id2_len == 0) { | ||
2065 | + session_id2_len = data.length; | ||
2066 | + session_id2 = xmalloc(session_id2_len); | ||
2067 | + memcpy(session_id2, data.value, session_id2_len); | ||
2068 | + } | ||
2069 | + major = ssh_gssapi_sign(gsscontext, &data, &hash); | ||
2070 | + | ||
2071 | + free(data.value); | ||
2072 | + | ||
2073 | + buffer_clear(m); | ||
2074 | + buffer_put_int(m, major); | ||
2075 | + buffer_put_string(m, hash.value, hash.length); | ||
2076 | + | ||
2077 | + mm_request_send(socket, MONITOR_ANS_GSSSIGN, m); | ||
2078 | + | ||
2079 | + gss_release_buffer(&minor, &hash); | ||
2080 | + | ||
2081 | + /* Turn on getpwnam permissions */ | ||
2082 | + monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1); | ||
2083 | + | ||
2084 | + /* And credential updating, for when rekeying */ | ||
2085 | + monitor_permit(mon_dispatch, MONITOR_REQ_GSSUPCREDS, 1); | ||
2086 | + | ||
2087 | + return (0); | ||
2088 | +} | ||
2089 | + | ||
2090 | +int | ||
2091 | +mm_answer_gss_updatecreds(int socket, Buffer *m) { | ||
2092 | + ssh_gssapi_ccache store; | ||
2093 | + int ok; | ||
2094 | + | ||
2095 | + store.filename = buffer_get_string(m, NULL); | ||
2096 | + store.envvar = buffer_get_string(m, NULL); | ||
2097 | + store.envval = buffer_get_string(m, NULL); | ||
2098 | + | ||
2099 | + ok = ssh_gssapi_update_creds(&store); | ||
2100 | + | ||
2101 | + free(store.filename); | ||
2102 | + free(store.envvar); | ||
2103 | + free(store.envval); | ||
2104 | + | ||
2105 | + buffer_clear(m); | ||
2106 | + buffer_put_int(m, ok); | ||
2107 | + | ||
2108 | + mm_request_send(socket, MONITOR_ANS_GSSUPCREDS, m); | ||
2109 | + | ||
2110 | + return(0); | ||
2111 | +} | ||
2112 | + | ||
2113 | #endif /* GSSAPI */ | ||
2114 | |||
2115 | diff --git a/monitor.h b/monitor.h | ||
2116 | index 93b8b66..bc50ade 100644 | ||
2117 | --- a/monitor.h | ||
2118 | +++ b/monitor.h | ||
2119 | @@ -65,6 +65,9 @@ enum monitor_reqtype { | ||
2120 | MONITOR_REQ_PAM_FREE_CTX = 110, MONITOR_ANS_PAM_FREE_CTX = 111, | ||
2121 | MONITOR_REQ_AUDIT_EVENT = 112, MONITOR_REQ_AUDIT_COMMAND = 113, | ||
2122 | |||
2123 | + MONITOR_REQ_GSSSIGN = 150, MONITOR_ANS_GSSSIGN = 151, | ||
2124 | + MONITOR_REQ_GSSUPCREDS = 152, MONITOR_ANS_GSSUPCREDS = 153, | ||
2125 | + | ||
2126 | }; | ||
2127 | |||
2128 | struct mm_master; | ||
2129 | diff --git a/monitor_wrap.c b/monitor_wrap.c | ||
2130 | index e6217b3..71e7c08 100644 | ||
2131 | --- a/monitor_wrap.c | ||
2132 | +++ b/monitor_wrap.c | ||
2133 | @@ -1069,7 +1069,7 @@ mm_ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic) | ||
2134 | } | ||
2135 | |||
2136 | int | ||
2137 | -mm_ssh_gssapi_userok(char *user) | ||
2138 | +mm_ssh_gssapi_userok(char *user, struct passwd *pw) | ||
2139 | { | ||
2140 | Buffer m; | ||
2141 | int authenticated = 0; | ||
2142 | @@ -1086,5 +1086,50 @@ mm_ssh_gssapi_userok(char *user) | ||
2143 | debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not "); | ||
2144 | return (authenticated); | ||
2145 | } | ||
2146 | + | ||
2147 | +OM_uint32 | ||
2148 | +mm_ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_desc *data, gss_buffer_desc *hash) | ||
2149 | +{ | ||
2150 | + Buffer m; | ||
2151 | + OM_uint32 major; | ||
2152 | + u_int len; | ||
2153 | + | ||
2154 | + buffer_init(&m); | ||
2155 | + buffer_put_string(&m, data->value, data->length); | ||
2156 | + | ||
2157 | + mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSIGN, &m); | ||
2158 | + mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSIGN, &m); | ||
2159 | + | ||
2160 | + major = buffer_get_int(&m); | ||
2161 | + hash->value = buffer_get_string(&m, &len); | ||
2162 | + hash->length = len; | ||
2163 | + | ||
2164 | + buffer_free(&m); | ||
2165 | + | ||
2166 | + return(major); | ||
2167 | +} | ||
2168 | + | ||
2169 | +int | ||
2170 | +mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *store) | ||
2171 | +{ | ||
2172 | + Buffer m; | ||
2173 | + int ok; | ||
2174 | + | ||
2175 | + buffer_init(&m); | ||
2176 | + | ||
2177 | + buffer_put_cstring(&m, store->filename ? store->filename : ""); | ||
2178 | + buffer_put_cstring(&m, store->envvar ? store->envvar : ""); | ||
2179 | + buffer_put_cstring(&m, store->envval ? store->envval : ""); | ||
2180 | + | ||
2181 | + mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSUPCREDS, &m); | ||
2182 | + mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSUPCREDS, &m); | ||
2183 | + | ||
2184 | + ok = buffer_get_int(&m); | ||
2185 | + | ||
2186 | + buffer_free(&m); | ||
2187 | + | ||
2188 | + return (ok); | ||
2189 | +} | ||
2190 | + | ||
2191 | #endif /* GSSAPI */ | ||
2192 | |||
2193 | diff --git a/monitor_wrap.h b/monitor_wrap.h | ||
2194 | index de4a08f..9758290 100644 | ||
2195 | --- a/monitor_wrap.h | ||
2196 | +++ b/monitor_wrap.h | ||
2197 | @@ -58,8 +58,10 @@ BIGNUM *mm_auth_rsa_generate_challenge(Key *); | ||
2198 | OM_uint32 mm_ssh_gssapi_server_ctx(Gssctxt **, gss_OID); | ||
2199 | OM_uint32 mm_ssh_gssapi_accept_ctx(Gssctxt *, | ||
2200 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | ||
2201 | -int mm_ssh_gssapi_userok(char *user); | ||
2202 | +int mm_ssh_gssapi_userok(char *user, struct passwd *); | ||
2203 | OM_uint32 mm_ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); | ||
2204 | +OM_uint32 mm_ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); | ||
2205 | +int mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *); | ||
2206 | #endif | ||
2207 | |||
2208 | #ifdef USE_PAM | ||
2209 | diff --git a/readconf.c b/readconf.c | ||
2210 | index db7d0bb..68dac76 100644 | ||
2211 | --- a/readconf.c | ||
2212 | +++ b/readconf.c | ||
2213 | @@ -147,6 +147,8 @@ typedef enum { | ||
2214 | oClearAllForwardings, oNoHostAuthenticationForLocalhost, | ||
2215 | oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout, | ||
2216 | oAddressFamily, oGssAuthentication, oGssDelegateCreds, | ||
2217 | + oGssTrustDns, oGssKeyEx, oGssClientIdentity, oGssRenewalRekey, | ||
2218 | + oGssServerIdentity, | ||
2219 | oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, | ||
2220 | oSendEnv, oControlPath, oControlMaster, oControlPersist, | ||
2221 | oHashKnownHosts, | ||
2222 | @@ -191,10 +193,19 @@ static struct { | ||
2223 | { "afstokenpassing", oUnsupported }, | ||
2224 | #if defined(GSSAPI) | ||
2225 | { "gssapiauthentication", oGssAuthentication }, | ||
2226 | + { "gssapikeyexchange", oGssKeyEx }, | ||
2227 | { "gssapidelegatecredentials", oGssDelegateCreds }, | ||
2228 | + { "gssapitrustdns", oGssTrustDns }, | ||
2229 | + { "gssapiclientidentity", oGssClientIdentity }, | ||
2230 | + { "gssapiserveridentity", oGssServerIdentity }, | ||
2231 | + { "gssapirenewalforcesrekey", oGssRenewalRekey }, | ||
2232 | #else | ||
2233 | { "gssapiauthentication", oUnsupported }, | ||
2234 | + { "gssapikeyexchange", oUnsupported }, | ||
2235 | { "gssapidelegatecredentials", oUnsupported }, | ||
2236 | + { "gssapitrustdns", oUnsupported }, | ||
2237 | + { "gssapiclientidentity", oUnsupported }, | ||
2238 | + { "gssapirenewalforcesrekey", oUnsupported }, | ||
2239 | #endif | ||
2240 | { "fallbacktorsh", oDeprecated }, | ||
2241 | { "usersh", oDeprecated }, | ||
2242 | @@ -892,10 +903,30 @@ parse_time: | ||
2243 | intptr = &options->gss_authentication; | ||
2244 | goto parse_flag; | ||
2245 | |||
2246 | + case oGssKeyEx: | ||
2247 | + intptr = &options->gss_keyex; | ||
2248 | + goto parse_flag; | ||
2249 | + | ||
2250 | case oGssDelegateCreds: | ||
2251 | intptr = &options->gss_deleg_creds; | ||
2252 | goto parse_flag; | ||
2253 | |||
2254 | + case oGssTrustDns: | ||
2255 | + intptr = &options->gss_trust_dns; | ||
2256 | + goto parse_flag; | ||
2257 | + | ||
2258 | + case oGssClientIdentity: | ||
2259 | + charptr = &options->gss_client_identity; | ||
2260 | + goto parse_string; | ||
2261 | + | ||
2262 | + case oGssServerIdentity: | ||
2263 | + charptr = &options->gss_server_identity; | ||
2264 | + goto parse_string; | ||
2265 | + | ||
2266 | + case oGssRenewalRekey: | ||
2267 | + intptr = &options->gss_renewal_rekey; | ||
2268 | + goto parse_flag; | ||
2269 | + | ||
2270 | case oBatchMode: | ||
2271 | intptr = &options->batch_mode; | ||
2272 | goto parse_flag; | ||
2273 | @@ -1601,7 +1632,12 @@ initialize_options(Options * options) | ||
2274 | options->pubkey_authentication = -1; | ||
2275 | options->challenge_response_authentication = -1; | ||
2276 | options->gss_authentication = -1; | ||
2277 | + options->gss_keyex = -1; | ||
2278 | options->gss_deleg_creds = -1; | ||
2279 | + options->gss_trust_dns = -1; | ||
2280 | + options->gss_renewal_rekey = -1; | ||
2281 | + options->gss_client_identity = NULL; | ||
2282 | + options->gss_server_identity = NULL; | ||
2283 | options->password_authentication = -1; | ||
2284 | options->kbd_interactive_authentication = -1; | ||
2285 | options->kbd_interactive_devices = NULL; | ||
2286 | @@ -1728,8 +1764,14 @@ fill_default_options(Options * options) | ||
2287 | options->challenge_response_authentication = 1; | ||
2288 | if (options->gss_authentication == -1) | ||
2289 | options->gss_authentication = 0; | ||
2290 | + if (options->gss_keyex == -1) | ||
2291 | + options->gss_keyex = 0; | ||
2292 | if (options->gss_deleg_creds == -1) | ||
2293 | options->gss_deleg_creds = 0; | ||
2294 | + if (options->gss_trust_dns == -1) | ||
2295 | + options->gss_trust_dns = 0; | ||
2296 | + if (options->gss_renewal_rekey == -1) | ||
2297 | + options->gss_renewal_rekey = 0; | ||
2298 | if (options->password_authentication == -1) | ||
2299 | options->password_authentication = 1; | ||
2300 | if (options->kbd_interactive_authentication == -1) | ||
2301 | diff --git a/readconf.h b/readconf.h | ||
2302 | index 576b9e3..ef39c4c 100644 | ||
2303 | --- a/readconf.h | ||
2304 | +++ b/readconf.h | ||
2305 | @@ -45,7 +45,12 @@ typedef struct { | ||
2306 | int challenge_response_authentication; | ||
2307 | /* Try S/Key or TIS, authentication. */ | ||
2308 | int gss_authentication; /* Try GSS authentication */ | ||
2309 | + int gss_keyex; /* Try GSS key exchange */ | ||
2310 | int gss_deleg_creds; /* Delegate GSS credentials */ | ||
2311 | + int gss_trust_dns; /* Trust DNS for GSS canonicalization */ | ||
2312 | + int gss_renewal_rekey; /* Credential renewal forces rekey */ | ||
2313 | + char *gss_client_identity; /* Principal to initiate GSSAPI with */ | ||
2314 | + char *gss_server_identity; /* GSSAPI target principal */ | ||
2315 | int password_authentication; /* Try password | ||
2316 | * authentication. */ | ||
2317 | int kbd_interactive_authentication; /* Try keyboard-interactive auth. */ | ||
2318 | diff --git a/servconf.c b/servconf.c | ||
2319 | index df93fc4..2f7f41e 100644 | ||
2320 | --- a/servconf.c | ||
2321 | +++ b/servconf.c | ||
2322 | @@ -115,8 +115,10 @@ initialize_server_options(ServerOptions *options) | ||
2323 | options->kerberos_ticket_cleanup = -1; | ||
2324 | options->kerberos_get_afs_token = -1; | ||
2325 | options->gss_authentication=-1; | ||
2326 | + options->gss_keyex = -1; | ||
2327 | options->gss_cleanup_creds = -1; | ||
2328 | options->gss_strict_acceptor = -1; | ||
2329 | + options->gss_store_rekey = -1; | ||
2330 | options->password_authentication = -1; | ||
2331 | options->kbd_interactive_authentication = -1; | ||
2332 | options->challenge_response_authentication = -1; | ||
2333 | @@ -275,10 +277,14 @@ fill_default_server_options(ServerOptions *options) | ||
2334 | options->kerberos_get_afs_token = 0; | ||
2335 | if (options->gss_authentication == -1) | ||
2336 | options->gss_authentication = 0; | ||
2337 | + if (options->gss_keyex == -1) | ||
2338 | + options->gss_keyex = 0; | ||
2339 | if (options->gss_cleanup_creds == -1) | ||
2340 | options->gss_cleanup_creds = 1; | ||
2341 | if (options->gss_strict_acceptor == -1) | ||
2342 | - options->gss_strict_acceptor = 0; | ||
2343 | + options->gss_strict_acceptor = 1; | ||
2344 | + if (options->gss_store_rekey == -1) | ||
2345 | + options->gss_store_rekey = 0; | ||
2346 | if (options->password_authentication == -1) | ||
2347 | options->password_authentication = 1; | ||
2348 | if (options->kbd_interactive_authentication == -1) | ||
2349 | @@ -401,6 +407,7 @@ typedef enum { | ||
2350 | sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes, | ||
2351 | sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile, | ||
2352 | sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor, | ||
2353 | + sGssKeyEx, sGssStoreRekey, | ||
2354 | sAcceptEnv, sPermitTunnel, | ||
2355 | sMatch, sPermitOpen, sForceCommand, sChrootDirectory, | ||
2356 | sUsePrivilegeSeparation, sAllowAgentForwarding, | ||
2357 | @@ -473,12 +480,20 @@ static struct { | ||
2358 | #ifdef GSSAPI | ||
2359 | { "gssapiauthentication", sGssAuthentication, SSHCFG_ALL }, | ||
2360 | { "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL }, | ||
2361 | + { "gssapicleanupcreds", sGssCleanupCreds, SSHCFG_GLOBAL }, | ||
2362 | { "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL }, | ||
2363 | + { "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL }, | ||
2364 | + { "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL }, | ||
2365 | #else | ||
2366 | { "gssapiauthentication", sUnsupported, SSHCFG_ALL }, | ||
2367 | { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL }, | ||
2368 | + { "gssapicleanupcreds", sUnsupported, SSHCFG_GLOBAL }, | ||
2369 | { "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL }, | ||
2370 | + { "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL }, | ||
2371 | + { "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL }, | ||
2372 | #endif | ||
2373 | + { "gssusesessionccache", sUnsupported, SSHCFG_GLOBAL }, | ||
2374 | + { "gssapiusesessioncredcache", sUnsupported, SSHCFG_GLOBAL }, | ||
2375 | { "passwordauthentication", sPasswordAuthentication, SSHCFG_ALL }, | ||
2376 | { "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_ALL }, | ||
2377 | { "challengeresponseauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, | ||
2378 | @@ -1214,6 +1229,10 @@ process_server_config_line(ServerOptions *options, char *line, | ||
2379 | intptr = &options->gss_authentication; | ||
2380 | goto parse_flag; | ||
2381 | |||
2382 | + case sGssKeyEx: | ||
2383 | + intptr = &options->gss_keyex; | ||
2384 | + goto parse_flag; | ||
2385 | + | ||
2386 | case sGssCleanupCreds: | ||
2387 | intptr = &options->gss_cleanup_creds; | ||
2388 | goto parse_flag; | ||
2389 | @@ -1222,6 +1241,10 @@ process_server_config_line(ServerOptions *options, char *line, | ||
2390 | intptr = &options->gss_strict_acceptor; | ||
2391 | goto parse_flag; | ||
2392 | |||
2393 | + case sGssStoreRekey: | ||
2394 | + intptr = &options->gss_store_rekey; | ||
2395 | + goto parse_flag; | ||
2396 | + | ||
2397 | case sPasswordAuthentication: | ||
2398 | intptr = &options->password_authentication; | ||
2399 | goto parse_flag; | ||
2400 | @@ -2229,7 +2252,10 @@ dump_config(ServerOptions *o) | ||
2401 | #endif | ||
2402 | #ifdef GSSAPI | ||
2403 | dump_cfg_fmtint(sGssAuthentication, o->gss_authentication); | ||
2404 | + dump_cfg_fmtint(sGssKeyEx, o->gss_keyex); | ||
2405 | dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds); | ||
2406 | + dump_cfg_fmtint(sGssStrictAcceptor, o->gss_strict_acceptor); | ||
2407 | + dump_cfg_fmtint(sGssStoreRekey, o->gss_store_rekey); | ||
2408 | #endif | ||
2409 | dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication); | ||
2410 | dump_cfg_fmtint(sKbdInteractiveAuthentication, | ||
2411 | diff --git a/servconf.h b/servconf.h | ||
2412 | index 606d80c..b99b270 100644 | ||
2413 | --- a/servconf.h | ||
2414 | +++ b/servconf.h | ||
2415 | @@ -117,8 +117,10 @@ typedef struct { | ||
2416 | int kerberos_get_afs_token; /* If true, try to get AFS token if | ||
2417 | * authenticated with Kerberos. */ | ||
2418 | int gss_authentication; /* If true, permit GSSAPI authentication */ | ||
2419 | + int gss_keyex; /* If true, permit GSSAPI key exchange */ | ||
2420 | int gss_cleanup_creds; /* If true, destroy cred cache on logout */ | ||
2421 | int gss_strict_acceptor; /* If true, restrict the GSSAPI acceptor name */ | ||
2422 | + int gss_store_rekey; | ||
2423 | int password_authentication; /* If true, permit password | ||
2424 | * authentication. */ | ||
2425 | int kbd_interactive_authentication; /* If true, permit */ | ||
2426 | diff --git a/ssh-gss.h b/ssh-gss.h | ||
2427 | index a99d7f0..914701b 100644 | ||
2428 | --- a/ssh-gss.h | ||
2429 | +++ b/ssh-gss.h | ||
2430 | @@ -1,6 +1,6 @@ | ||
2431 | /* $OpenBSD: ssh-gss.h,v 1.11 2014/02/26 20:28:44 djm Exp $ */ | ||
2432 | /* | ||
2433 | - * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | ||
2434 | + * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | ||
2435 | * | ||
2436 | * Redistribution and use in source and binary forms, with or without | ||
2437 | * modification, are permitted provided that the following conditions | ||
2438 | @@ -61,10 +61,22 @@ | ||
2439 | |||
2440 | #define SSH_GSS_OIDTYPE 0x06 | ||
2441 | |||
2442 | +#define SSH2_MSG_KEXGSS_INIT 30 | ||
2443 | +#define SSH2_MSG_KEXGSS_CONTINUE 31 | ||
2444 | +#define SSH2_MSG_KEXGSS_COMPLETE 32 | ||
2445 | +#define SSH2_MSG_KEXGSS_HOSTKEY 33 | ||
2446 | +#define SSH2_MSG_KEXGSS_ERROR 34 | ||
2447 | +#define SSH2_MSG_KEXGSS_GROUPREQ 40 | ||
2448 | +#define SSH2_MSG_KEXGSS_GROUP 41 | ||
2449 | +#define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-" | ||
2450 | +#define KEX_GSS_GRP14_SHA1_ID "gss-group14-sha1-" | ||
2451 | +#define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-" | ||
2452 | + | ||
2453 | typedef struct { | ||
2454 | char *filename; | ||
2455 | char *envvar; | ||
2456 | char *envval; | ||
2457 | + struct passwd *owner; | ||
2458 | void *data; | ||
2459 | } ssh_gssapi_ccache; | ||
2460 | |||
2461 | @@ -72,8 +84,11 @@ typedef struct { | ||
2462 | gss_buffer_desc displayname; | ||
2463 | gss_buffer_desc exportedname; | ||
2464 | gss_cred_id_t creds; | ||
2465 | + gss_name_t name; | ||
2466 | struct ssh_gssapi_mech_struct *mech; | ||
2467 | ssh_gssapi_ccache store; | ||
2468 | + int used; | ||
2469 | + int updated; | ||
2470 | } ssh_gssapi_client; | ||
2471 | |||
2472 | typedef struct ssh_gssapi_mech_struct { | ||
2473 | @@ -84,6 +99,7 @@ typedef struct ssh_gssapi_mech_struct { | ||
2474 | int (*userok) (ssh_gssapi_client *, char *); | ||
2475 | int (*localname) (ssh_gssapi_client *, char **); | ||
2476 | void (*storecreds) (ssh_gssapi_client *); | ||
2477 | + int (*updatecreds) (ssh_gssapi_ccache *, ssh_gssapi_client *); | ||
2478 | } ssh_gssapi_mech; | ||
2479 | |||
2480 | typedef struct { | ||
2481 | @@ -94,10 +110,11 @@ typedef struct { | ||
2482 | gss_OID oid; /* client */ | ||
2483 | gss_cred_id_t creds; /* server */ | ||
2484 | gss_name_t client; /* server */ | ||
2485 | - gss_cred_id_t client_creds; /* server */ | ||
2486 | + gss_cred_id_t client_creds; /* both */ | ||
2487 | } Gssctxt; | ||
2488 | |||
2489 | extern ssh_gssapi_mech *supported_mechs[]; | ||
2490 | +extern Gssctxt *gss_kex_context; | ||
2491 | |||
2492 | int ssh_gssapi_check_oid(Gssctxt *, void *, size_t); | ||
2493 | void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); | ||
2494 | @@ -119,16 +136,32 @@ void ssh_gssapi_build_ctx(Gssctxt **); | ||
2495 | void ssh_gssapi_delete_ctx(Gssctxt **); | ||
2496 | OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); | ||
2497 | void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); | ||
2498 | -int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *); | ||
2499 | +int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *, const char *); | ||
2500 | +OM_uint32 ssh_gssapi_client_identity(Gssctxt *, const char *); | ||
2501 | +int ssh_gssapi_credentials_updated(Gssctxt *); | ||
2502 | |||
2503 | /* In the server */ | ||
2504 | +typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *, | ||
2505 | + const char *); | ||
2506 | +char *ssh_gssapi_client_mechanisms(const char *, const char *); | ||
2507 | +char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *, | ||
2508 | + const char *); | ||
2509 | +gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int); | ||
2510 | +int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *, | ||
2511 | + const char *); | ||
2512 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); | ||
2513 | -int ssh_gssapi_userok(char *name); | ||
2514 | +int ssh_gssapi_userok(char *name, struct passwd *); | ||
2515 | OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); | ||
2516 | void ssh_gssapi_do_child(char ***, u_int *); | ||
2517 | void ssh_gssapi_cleanup_creds(void); | ||
2518 | void ssh_gssapi_storecreds(void); | ||
2519 | |||
2520 | +char *ssh_gssapi_server_mechanisms(void); | ||
2521 | +int ssh_gssapi_oid_table_ok(void); | ||
2522 | + | ||
2523 | +int ssh_gssapi_update_creds(ssh_gssapi_ccache *store); | ||
2524 | +void ssh_gssapi_rekey_creds(void); | ||
2525 | + | ||
2526 | #endif /* GSSAPI */ | ||
2527 | |||
2528 | #endif /* _SSH_GSS_H */ | ||
2529 | diff --git a/ssh_config b/ssh_config | ||
2530 | index 03a228f..228e5ab 100644 | ||
2531 | --- a/ssh_config | ||
2532 | +++ b/ssh_config | ||
2533 | @@ -26,6 +26,8 @@ | ||
2534 | # HostbasedAuthentication no | ||
2535 | # GSSAPIAuthentication no | ||
2536 | # GSSAPIDelegateCredentials no | ||
2537 | +# GSSAPIKeyExchange no | ||
2538 | +# GSSAPITrustDNS no | ||
2539 | # BatchMode no | ||
2540 | # CheckHostIP yes | ||
2541 | # AddressFamily any | ||
2542 | diff --git a/ssh_config.5 b/ssh_config.5 | ||
2543 | index 268a627..b840261 100644 | ||
2544 | --- a/ssh_config.5 | ||
2545 | +++ b/ssh_config.5 | ||
2546 | @@ -744,11 +744,43 @@ Specifies whether user authentication based on GSSAPI is allowed. | ||
2547 | The default is | ||
2548 | .Dq no . | ||
2549 | Note that this option applies to protocol version 2 only. | ||
2550 | +.It Cm GSSAPIKeyExchange | ||
2551 | +Specifies whether key exchange based on GSSAPI may be used. When using | ||
2552 | +GSSAPI key exchange the server need not have a host key. | ||
2553 | +The default is | ||
2554 | +.Dq no . | ||
2555 | +Note that this option applies to protocol version 2 only. | ||
2556 | +.It Cm GSSAPIClientIdentity | ||
2557 | +If set, specifies the GSSAPI client identity that ssh should use when | ||
2558 | +connecting to the server. The default is unset, which means that the default | ||
2559 | +identity will be used. | ||
2560 | +.It Cm GSSAPIServerIdentity | ||
2561 | +If set, specifies the GSSAPI server identity that ssh should expect when | ||
2562 | +connecting to the server. The default is unset, which means that the | ||
2563 | +expected GSSAPI server identity will be determined from the target | ||
2564 | +hostname. | ||
2565 | .It Cm GSSAPIDelegateCredentials | ||
2566 | Forward (delegate) credentials to the server. | ||
2567 | The default is | ||
2568 | .Dq no . | ||
2569 | -Note that this option applies to protocol version 2 only. | ||
2570 | +Note that this option applies to protocol version 2 connections using GSSAPI. | ||
2571 | +.It Cm GSSAPIRenewalForcesRekey | ||
2572 | +If set to | ||
2573 | +.Dq yes | ||
2574 | +then renewal of the client's GSSAPI credentials will force the rekeying of the | ||
2575 | +ssh connection. With a compatible server, this can delegate the renewed | ||
2576 | +credentials to a session on the server. | ||
2577 | +The default is | ||
2578 | +.Dq no . | ||
2579 | +.It Cm GSSAPITrustDns | ||
2580 | +Set to | ||
2581 | +.Dq yes to indicate that the DNS is trusted to securely canonicalize | ||
2582 | +the name of the host being connected to. If | ||
2583 | +.Dq no, the hostname entered on the | ||
2584 | +command line will be passed untouched to the GSSAPI library. | ||
2585 | +The default is | ||
2586 | +.Dq no . | ||
2587 | +This option only applies to protocol version 2 connections using GSSAPI. | ||
2588 | .It Cm HashKnownHosts | ||
2589 | Indicates that | ||
2590 | .Xr ssh 1 | ||
2591 | diff --git a/sshconnect2.c b/sshconnect2.c | ||
2592 | index fcaed6b..44c89e6 100644 | ||
2593 | --- a/sshconnect2.c | ||
2594 | +++ b/sshconnect2.c | ||
2595 | @@ -160,9 +160,34 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port) | ||
2596 | struct kex *kex; | ||
2597 | int r; | ||
2598 | |||
2599 | +#ifdef GSSAPI | ||
2600 | + char *orig = NULL, *gss = NULL; | ||
2601 | + char *gss_host = NULL; | ||
2602 | +#endif | ||
2603 | + | ||
2604 | xxx_host = host; | ||
2605 | xxx_hostaddr = hostaddr; | ||
2606 | |||
2607 | +#ifdef GSSAPI | ||
2608 | + if (options.gss_keyex) { | ||
2609 | + /* Add the GSSAPI mechanisms currently supported on this | ||
2610 | + * client to the key exchange algorithm proposal */ | ||
2611 | + orig = myproposal[PROPOSAL_KEX_ALGS]; | ||
2612 | + | ||
2613 | + if (options.gss_trust_dns) | ||
2614 | + gss_host = (char *)get_canonical_hostname(1); | ||
2615 | + else | ||
2616 | + gss_host = host; | ||
2617 | + | ||
2618 | + gss = ssh_gssapi_client_mechanisms(gss_host, options.gss_client_identity); | ||
2619 | + if (gss) { | ||
2620 | + debug("Offering GSSAPI proposal: %s", gss); | ||
2621 | + xasprintf(&myproposal[PROPOSAL_KEX_ALGS], | ||
2622 | + "%s,%s", gss, orig); | ||
2623 | + } | ||
2624 | + } | ||
2625 | +#endif | ||
2626 | + | ||
2627 | if (options.ciphers == (char *)-1) { | ||
2628 | logit("No valid ciphers for protocol version 2 given, using defaults."); | ||
2629 | options.ciphers = NULL; | ||
2630 | @@ -200,6 +225,17 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port) | ||
2631 | myproposal[PROPOSAL_KEX_ALGS] = compat_kex_proposal( | ||
2632 | myproposal[PROPOSAL_KEX_ALGS]); | ||
2633 | |||
2634 | +#ifdef GSSAPI | ||
2635 | + /* If we've got GSSAPI algorithms, then we also support the | ||
2636 | + * 'null' hostkey, as a last resort */ | ||
2637 | + if (options.gss_keyex && gss) { | ||
2638 | + orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]; | ||
2639 | + xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS], | ||
2640 | + "%s,null", orig); | ||
2641 | + free(gss); | ||
2642 | + } | ||
2643 | +#endif | ||
2644 | + | ||
2645 | if (options.rekey_limit || options.rekey_interval) | ||
2646 | packet_set_rekey_limits((u_int32_t)options.rekey_limit, | ||
2647 | (time_t)options.rekey_interval); | ||
2648 | @@ -218,10 +254,30 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port) | ||
2649 | # endif | ||
2650 | #endif | ||
2651 | kex->kex[KEX_C25519_SHA256] = kexc25519_client; | ||
2652 | +#ifdef GSSAPI | ||
2653 | + if (options.gss_keyex) { | ||
2654 | + kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_client; | ||
2655 | + kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_client; | ||
2656 | + kex->kex[KEX_GSS_GEX_SHA1] = kexgss_client; | ||
2657 | + } | ||
2658 | +#endif | ||
2659 | kex->client_version_string=client_version_string; | ||
2660 | kex->server_version_string=server_version_string; | ||
2661 | kex->verify_host_key=&verify_host_key_callback; | ||
2662 | |||
2663 | +#ifdef GSSAPI | ||
2664 | + if (options.gss_keyex) { | ||
2665 | + kex->gss_deleg_creds = options.gss_deleg_creds; | ||
2666 | + kex->gss_trust_dns = options.gss_trust_dns; | ||
2667 | + kex->gss_client = options.gss_client_identity; | ||
2668 | + if (options.gss_server_identity) { | ||
2669 | + kex->gss_host = options.gss_server_identity; | ||
2670 | + } else { | ||
2671 | + kex->gss_host = gss_host; | ||
2672 | + } | ||
2673 | + } | ||
2674 | +#endif | ||
2675 | + | ||
2676 | dispatch_run(DISPATCH_BLOCK, &kex->done, active_state); | ||
2677 | |||
2678 | if (options.use_roaming && !kex->roaming) { | ||
2679 | @@ -313,6 +369,7 @@ int input_gssapi_token(int type, u_int32_t, void *); | ||
2680 | int input_gssapi_hash(int type, u_int32_t, void *); | ||
2681 | int input_gssapi_error(int, u_int32_t, void *); | ||
2682 | int input_gssapi_errtok(int, u_int32_t, void *); | ||
2683 | +int userauth_gsskeyex(Authctxt *authctxt); | ||
2684 | #endif | ||
2685 | |||
2686 | void userauth(Authctxt *, char *); | ||
2687 | @@ -328,6 +385,11 @@ static char *authmethods_get(void); | ||
2688 | |||
2689 | Authmethod authmethods[] = { | ||
2690 | #ifdef GSSAPI | ||
2691 | + {"gssapi-keyex", | ||
2692 | + userauth_gsskeyex, | ||
2693 | + NULL, | ||
2694 | + &options.gss_authentication, | ||
2695 | + NULL}, | ||
2696 | {"gssapi-with-mic", | ||
2697 | userauth_gssapi, | ||
2698 | NULL, | ||
2699 | @@ -634,19 +696,31 @@ userauth_gssapi(Authctxt *authctxt) | ||
2700 | static u_int mech = 0; | ||
2701 | OM_uint32 min; | ||
2702 | int ok = 0; | ||
2703 | + const char *gss_host; | ||
2704 | + | ||
2705 | + if (options.gss_server_identity) | ||
2706 | + gss_host = options.gss_server_identity; | ||
2707 | + else if (options.gss_trust_dns) | ||
2708 | + gss_host = get_canonical_hostname(1); | ||
2709 | + else | ||
2710 | + gss_host = authctxt->host; | ||
2711 | |||
2712 | /* Try one GSSAPI method at a time, rather than sending them all at | ||
2713 | * once. */ | ||
2714 | |||
2715 | if (gss_supported == NULL) | ||
2716 | - gss_indicate_mechs(&min, &gss_supported); | ||
2717 | + if (GSS_ERROR(gss_indicate_mechs(&min, &gss_supported))) { | ||
2718 | + gss_supported = NULL; | ||
2719 | + return 0; | ||
2720 | + } | ||
2721 | |||
2722 | /* Check to see if the mechanism is usable before we offer it */ | ||
2723 | while (mech < gss_supported->count && !ok) { | ||
2724 | /* My DER encoding requires length<128 */ | ||
2725 | if (gss_supported->elements[mech].length < 128 && | ||
2726 | ssh_gssapi_check_mechanism(&gssctxt, | ||
2727 | - &gss_supported->elements[mech], authctxt->host)) { | ||
2728 | + &gss_supported->elements[mech], gss_host, | ||
2729 | + options.gss_client_identity)) { | ||
2730 | ok = 1; /* Mechanism works */ | ||
2731 | } else { | ||
2732 | mech++; | ||
2733 | @@ -743,8 +817,8 @@ input_gssapi_response(int type, u_int32_t plen, void *ctxt) | ||
2734 | { | ||
2735 | Authctxt *authctxt = ctxt; | ||
2736 | Gssctxt *gssctxt; | ||
2737 | - int oidlen; | ||
2738 | - char *oidv; | ||
2739 | + u_int oidlen; | ||
2740 | + u_char *oidv; | ||
2741 | |||
2742 | if (authctxt == NULL) | ||
2743 | fatal("input_gssapi_response: no authentication context"); | ||
2744 | @@ -857,6 +931,48 @@ input_gssapi_error(int type, u_int32_t plen, void *ctxt) | ||
2745 | free(lang); | ||
2746 | return 0; | ||
2747 | } | ||
2748 | + | ||
2749 | +int | ||
2750 | +userauth_gsskeyex(Authctxt *authctxt) | ||
2751 | +{ | ||
2752 | + Buffer b; | ||
2753 | + gss_buffer_desc gssbuf; | ||
2754 | + gss_buffer_desc mic = GSS_C_EMPTY_BUFFER; | ||
2755 | + OM_uint32 ms; | ||
2756 | + | ||
2757 | + static int attempt = 0; | ||
2758 | + if (attempt++ >= 1) | ||
2759 | + return (0); | ||
2760 | + | ||
2761 | + if (gss_kex_context == NULL) { | ||
2762 | + debug("No valid Key exchange context"); | ||
2763 | + return (0); | ||
2764 | + } | ||
2765 | + | ||
2766 | + ssh_gssapi_buildmic(&b, authctxt->server_user, authctxt->service, | ||
2767 | + "gssapi-keyex"); | ||
2768 | + | ||
2769 | + gssbuf.value = buffer_ptr(&b); | ||
2770 | + gssbuf.length = buffer_len(&b); | ||
2771 | + | ||
2772 | + if (GSS_ERROR(ssh_gssapi_sign(gss_kex_context, &gssbuf, &mic))) { | ||
2773 | + buffer_free(&b); | ||
2774 | + return (0); | ||
2775 | + } | ||
2776 | + | ||
2777 | + packet_start(SSH2_MSG_USERAUTH_REQUEST); | ||
2778 | + packet_put_cstring(authctxt->server_user); | ||
2779 | + packet_put_cstring(authctxt->service); | ||
2780 | + packet_put_cstring(authctxt->method->name); | ||
2781 | + packet_put_string(mic.value, mic.length); | ||
2782 | + packet_send(); | ||
2783 | + | ||
2784 | + buffer_free(&b); | ||
2785 | + gss_release_buffer(&ms, &mic); | ||
2786 | + | ||
2787 | + return (1); | ||
2788 | +} | ||
2789 | + | ||
2790 | #endif /* GSSAPI */ | ||
2791 | |||
2792 | int | ||
2793 | diff --git a/sshd.c b/sshd.c | ||
2794 | index 6f8c6f2..6b85e6c 100644 | ||
2795 | --- a/sshd.c | ||
2796 | +++ b/sshd.c | ||
2797 | @@ -125,6 +125,10 @@ | ||
2798 | #include "version.h" | ||
2799 | #include "ssherr.h" | ||
2800 | |||
2801 | +#ifdef USE_SECURITY_SESSION_API | ||
2802 | +#include <Security/AuthSession.h> | ||
2803 | +#endif | ||
2804 | + | ||
2805 | #ifndef O_NOCTTY | ||
2806 | #define O_NOCTTY 0 | ||
2807 | #endif | ||
2808 | @@ -1823,10 +1827,13 @@ main(int ac, char **av) | ||
2809 | logit("Disabling protocol version 1. Could not load host key"); | ||
2810 | options.protocol &= ~SSH_PROTO_1; | ||
2811 | } | ||
2812 | +#ifndef GSSAPI | ||
2813 | + /* The GSSAPI key exchange can run without a host key */ | ||
2814 | if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) { | ||
2815 | logit("Disabling protocol version 2. Could not load host key"); | ||
2816 | options.protocol &= ~SSH_PROTO_2; | ||
2817 | } | ||
2818 | +#endif | ||
2819 | if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) { | ||
2820 | logit("sshd: no hostkeys available -- exiting."); | ||
2821 | exit(1); | ||
2822 | @@ -2141,6 +2148,60 @@ main(int ac, char **av) | ||
2823 | remote_ip, remote_port, laddr, get_local_port()); | ||
2824 | free(laddr); | ||
2825 | |||
2826 | +#ifdef USE_SECURITY_SESSION_API | ||
2827 | + /* | ||
2828 | + * Create a new security session for use by the new user login if | ||
2829 | + * the current session is the root session or we are not launched | ||
2830 | + * by inetd (eg: debugging mode or server mode). We do not | ||
2831 | + * necessarily need to create a session if we are launched from | ||
2832 | + * inetd because Panther xinetd will create a session for us. | ||
2833 | + * | ||
2834 | + * The only case where this logic will fail is if there is an | ||
2835 | + * inetd running in a non-root session which is not creating | ||
2836 | + * new sessions for us. Then all the users will end up in the | ||
2837 | + * same session (bad). | ||
2838 | + * | ||
2839 | + * When the client exits, the session will be destroyed for us | ||
2840 | + * automatically. | ||
2841 | + * | ||
2842 | + * We must create the session before any credentials are stored | ||
2843 | + * (including AFS pags, which happens a few lines below). | ||
2844 | + */ | ||
2845 | + { | ||
2846 | + OSStatus err = 0; | ||
2847 | + SecuritySessionId sid = 0; | ||
2848 | + SessionAttributeBits sattrs = 0; | ||
2849 | + | ||
2850 | + err = SessionGetInfo(callerSecuritySession, &sid, &sattrs); | ||
2851 | + if (err) | ||
2852 | + error("SessionGetInfo() failed with error %.8X", | ||
2853 | + (unsigned) err); | ||
2854 | + else | ||
2855 | + debug("Current Session ID is %.8X / Session Attributes are %.8X", | ||
2856 | + (unsigned) sid, (unsigned) sattrs); | ||
2857 | + | ||
2858 | + if (inetd_flag && !(sattrs & sessionIsRoot)) | ||
2859 | + debug("Running in inetd mode in a non-root session... " | ||
2860 | + "assuming inetd created the session for us."); | ||
2861 | + else { | ||
2862 | + debug("Creating new security session..."); | ||
2863 | + err = SessionCreate(0, sessionHasTTY | sessionIsRemote); | ||
2864 | + if (err) | ||
2865 | + error("SessionCreate() failed with error %.8X", | ||
2866 | + (unsigned) err); | ||
2867 | + | ||
2868 | + err = SessionGetInfo(callerSecuritySession, &sid, | ||
2869 | + &sattrs); | ||
2870 | + if (err) | ||
2871 | + error("SessionGetInfo() failed with error %.8X", | ||
2872 | + (unsigned) err); | ||
2873 | + else | ||
2874 | + debug("New Session ID is %.8X / Session Attributes are %.8X", | ||
2875 | + (unsigned) sid, (unsigned) sattrs); | ||
2876 | + } | ||
2877 | + } | ||
2878 | +#endif | ||
2879 | + | ||
2880 | /* | ||
2881 | * We don't want to listen forever unless the other side | ||
2882 | * successfully authenticates itself. So we set up an alarm which is | ||
2883 | @@ -2570,6 +2631,48 @@ do_ssh2_kex(void) | ||
2884 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal( | ||
2885 | list_hostkey_types()); | ||
2886 | |||
2887 | +#ifdef GSSAPI | ||
2888 | + { | ||
2889 | + char *orig; | ||
2890 | + char *gss = NULL; | ||
2891 | + char *newstr = NULL; | ||
2892 | + orig = myproposal[PROPOSAL_KEX_ALGS]; | ||
2893 | + | ||
2894 | + /* | ||
2895 | + * If we don't have a host key, then there's no point advertising | ||
2896 | + * the other key exchange algorithms | ||
2897 | + */ | ||
2898 | + | ||
2899 | + if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0) | ||
2900 | + orig = NULL; | ||
2901 | + | ||
2902 | + if (options.gss_keyex) | ||
2903 | + gss = ssh_gssapi_server_mechanisms(); | ||
2904 | + else | ||
2905 | + gss = NULL; | ||
2906 | + | ||
2907 | + if (gss && orig) | ||
2908 | + xasprintf(&newstr, "%s,%s", gss, orig); | ||
2909 | + else if (gss) | ||
2910 | + newstr = gss; | ||
2911 | + else if (orig) | ||
2912 | + newstr = orig; | ||
2913 | + | ||
2914 | + /* | ||
2915 | + * If we've got GSSAPI mechanisms, then we've got the 'null' host | ||
2916 | + * key alg, but we can't tell people about it unless its the only | ||
2917 | + * host key algorithm we support | ||
2918 | + */ | ||
2919 | + if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0) | ||
2920 | + myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null"; | ||
2921 | + | ||
2922 | + if (newstr) | ||
2923 | + myproposal[PROPOSAL_KEX_ALGS] = newstr; | ||
2924 | + else | ||
2925 | + fatal("No supported key exchange algorithms"); | ||
2926 | + } | ||
2927 | +#endif | ||
2928 | + | ||
2929 | /* start key exchange */ | ||
2930 | if ((r = kex_setup(active_state, myproposal)) != 0) | ||
2931 | fatal("kex_setup: %s", ssh_err(r)); | ||
2932 | @@ -2584,6 +2687,13 @@ do_ssh2_kex(void) | ||
2933 | # endif | ||
2934 | #endif | ||
2935 | kex->kex[KEX_C25519_SHA256] = kexc25519_server; | ||
2936 | +#ifdef GSSAPI | ||
2937 | + if (options.gss_keyex) { | ||
2938 | + kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; | ||
2939 | + kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server; | ||
2940 | + kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server; | ||
2941 | + } | ||
2942 | +#endif | ||
2943 | kex->server = 1; | ||
2944 | kex->client_version_string=client_version_string; | ||
2945 | kex->server_version_string=server_version_string; | ||
2946 | diff --git a/sshd_config b/sshd_config | ||
2947 | index cf7d8e1..1dfd0f1 100644 | ||
2948 | --- a/sshd_config | ||
2949 | +++ b/sshd_config | ||
2950 | @@ -84,6 +84,8 @@ AuthorizedKeysFile .ssh/authorized_keys | ||
2951 | # GSSAPI options | ||
2952 | #GSSAPIAuthentication no | ||
2953 | #GSSAPICleanupCredentials yes | ||
2954 | +#GSSAPIStrictAcceptorCheck yes | ||
2955 | +#GSSAPIKeyExchange no | ||
2956 | |||
2957 | # Set this to 'yes' to enable PAM authentication, account processing, | ||
2958 | # and session processing. If this is enabled, PAM authentication will | ||
2959 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
2960 | index 5ab4318..68424f1 100644 | ||
2961 | --- a/sshd_config.5 | ||
2962 | +++ b/sshd_config.5 | ||
2963 | @@ -616,6 +616,12 @@ Specifies whether user authentication based on GSSAPI is allowed. | ||
2964 | The default is | ||
2965 | .Dq no . | ||
2966 | Note that this option applies to protocol version 2 only. | ||
2967 | +.It Cm GSSAPIKeyExchange | ||
2968 | +Specifies whether key exchange based on GSSAPI is allowed. GSSAPI key exchange | ||
2969 | +doesn't rely on ssh keys to verify host identity. | ||
2970 | +The default is | ||
2971 | +.Dq no . | ||
2972 | +Note that this option applies to protocol version 2 only. | ||
2973 | .It Cm GSSAPICleanupCredentials | ||
2974 | Specifies whether to automatically destroy the user's credentials cache | ||
2975 | on logout. | ||
2976 | @@ -637,6 +643,11 @@ machine's default store. | ||
2977 | This facility is provided to assist with operation on multi homed machines. | ||
2978 | The default is | ||
2979 | .Dq yes . | ||
2980 | +.It Cm GSSAPIStoreCredentialsOnRekey | ||
2981 | +Controls whether the user's GSSAPI credentials should be updated following a | ||
2982 | +successful connection rekeying. This option can be used to accepted renewed | ||
2983 | +or updated credentials from a compatible client. The default is | ||
2984 | +.Dq no . | ||
2985 | .It Cm HostbasedAcceptedKeyTypes | ||
2986 | Specifies the key types that will be accepted for hostbased authentication | ||
2987 | as a comma-separated pattern list. | ||
2988 | diff --git a/sshkey.c b/sshkey.c | ||
2989 | index cfe5980..2c87d80 100644 | ||
2990 | --- a/sshkey.c | ||
2991 | +++ b/sshkey.c | ||
2992 | @@ -116,6 +116,7 @@ static const struct keytype keytypes[] = { | ||
2993 | { "ssh-dss-cert-v00@openssh.com", "DSA-CERT-V00", | ||
2994 | KEY_DSA_CERT_V00, 0, 1 }, | ||
2995 | #endif /* WITH_OPENSSL */ | ||
2996 | + { "null", "null", KEY_NULL, 0, 0 }, | ||
2997 | { NULL, NULL, -1, -1, 0 } | ||
2998 | }; | ||
2999 | |||
3000 | @@ -204,7 +205,7 @@ key_alg_list(int certs_only, int plain_only) | ||
3001 | const struct keytype *kt; | ||
3002 | |||
3003 | for (kt = keytypes; kt->type != -1; kt++) { | ||
3004 | - if (kt->name == NULL) | ||
3005 | + if (kt->name == NULL || kt->type == KEY_NULL) | ||
3006 | continue; | ||
3007 | if ((certs_only && !kt->cert) || (plain_only && kt->cert)) | ||
3008 | continue; | ||
3009 | diff --git a/sshkey.h b/sshkey.h | ||
3010 | index cdac0e2..b010b8e 100644 | ||
3011 | --- a/sshkey.h | ||
3012 | +++ b/sshkey.h | ||
3013 | @@ -64,6 +64,7 @@ enum sshkey_types { | ||
3014 | KEY_ED25519_CERT, | ||
3015 | KEY_RSA_CERT_V00, | ||
3016 | KEY_DSA_CERT_V00, | ||
3017 | + KEY_NULL, | ||
3018 | KEY_UNSPEC | ||
3019 | }; | ||
3020 | |||
diff --git a/debian/patches/helpful-wait-terminate.patch b/debian/patches/helpful-wait-terminate.patch new file mode 100644 index 000000000..ac8630b4c --- /dev/null +++ b/debian/patches/helpful-wait-terminate.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | From 5496170cd67abb653e385277bd83b69f1b10905d Mon Sep 17 00:00:00 2001 | ||
2 | From: Matthew Vernon <matthew@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:09:56 +0000 | ||
4 | Subject: Mention ~& when waiting for forwarded connections to terminate | ||
5 | |||
6 | Bug-Debian: http://bugs.debian.org/50308 | ||
7 | Last-Update: 2010-02-27 | ||
8 | |||
9 | Patch-Name: helpful-wait-terminate.patch | ||
10 | --- | ||
11 | serverloop.c | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/serverloop.c b/serverloop.c | ||
15 | index 306ac36..68f0251 100644 | ||
16 | --- a/serverloop.c | ||
17 | +++ b/serverloop.c | ||
18 | @@ -687,7 +687,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg) | ||
19 | if (!channel_still_open()) | ||
20 | break; | ||
21 | if (!waiting_termination) { | ||
22 | - const char *s = "Waiting for forwarded connections to terminate...\r\n"; | ||
23 | + const char *s = "Waiting for forwarded connections to terminate... (press ~& to background)\r\n"; | ||
24 | char *cp; | ||
25 | waiting_termination = 1; | ||
26 | buffer_append(&stderr_buffer, s, strlen(s)); | ||
diff --git a/debian/patches/keepalive-extensions.patch b/debian/patches/keepalive-extensions.patch new file mode 100644 index 000000000..09c178db4 --- /dev/null +++ b/debian/patches/keepalive-extensions.patch | |||
@@ -0,0 +1,135 @@ | |||
1 | From 02a61bcb045503a5f3f7e274ac1f4524e30f87c8 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: 2015-08-19 | ||
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 85eea48..5c5890c 100644 | ||
30 | --- a/readconf.c | ||
31 | +++ b/readconf.c | ||
32 | @@ -159,6 +159,7 @@ typedef enum { | ||
33 | oCanonicalizeFallbackLocal, oCanonicalizePermittedCNAMEs, | ||
34 | oStreamLocalBindMask, oStreamLocalBindUnlink, oRevokedHostKeys, | ||
35 | oFingerprintHash, oUpdateHostkeys, oHostbasedKeyTypes, | ||
36 | + oProtocolKeepAlives, oSetupTimeOut, | ||
37 | oIgnoredUnknownOption, oDeprecated, oUnsupported | ||
38 | } OpCodes; | ||
39 | |||
40 | @@ -288,6 +289,8 @@ static struct { | ||
41 | { "updatehostkeys", oUpdateHostkeys }, | ||
42 | { "hostbasedkeytypes", oHostbasedKeyTypes }, | ||
43 | { "ignoreunknown", oIgnoreUnknown }, | ||
44 | + { "protocolkeepalives", oProtocolKeepAlives }, | ||
45 | + { "setuptimeout", oSetupTimeOut }, | ||
46 | |||
47 | { NULL, oBadOption } | ||
48 | }; | ||
49 | @@ -1299,6 +1302,8 @@ parse_int: | ||
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 | @@ -1858,8 +1863,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 f7510b6..21d3e94 100644 | ||
76 | --- a/ssh_config.5 | ||
77 | +++ b/ssh_config.5 | ||
78 | @@ -233,8 +233,12 @@ Valid arguments are | ||
79 | If set to | ||
80 | .Dq 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. | ||
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 | .Dq yes | ||
91 | or | ||
92 | @@ -1425,8 +1429,15 @@ 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. | ||
101 | This option applies to protocol version 2 only. | ||
102 | +.Cm ProtocolKeepAlives | ||
103 | +and | ||
104 | +.Cm SetupTimeOut | ||
105 | +are Debian-specific compatibility aliases for this option. | ||
106 | .It Cm StreamLocalBindMask | ||
107 | Sets the octal file creation mode mask | ||
108 | .Pq umask | ||
109 | @@ -1492,6 +1503,12 @@ Specifies whether the system should send TCP keepalive messages to the | ||
110 | other side. | ||
111 | If they are sent, death of the connection or crash of one | ||
112 | of the machines will be properly noticed. | ||
113 | +This option only uses TCP keepalives (as opposed to using ssh level | ||
114 | +keepalives), so takes a long time to notice when the connection dies. | ||
115 | +As such, you probably want | ||
116 | +the | ||
117 | +.Cm ServerAliveInterval | ||
118 | +option as well. | ||
119 | However, this means that | ||
120 | connections will die if the route is down temporarily, and some people | ||
121 | find it annoying. | ||
122 | diff --git a/sshd_config.5 b/sshd_config.5 | ||
123 | index 68424f1..1269bbd 100644 | ||
124 | --- a/sshd_config.5 | ||
125 | +++ b/sshd_config.5 | ||
126 | @@ -1443,6 +1443,9 @@ This avoids infinitely hanging sessions. | ||
127 | .Pp | ||
128 | To disable TCP keepalive messages, the value should be set to | ||
129 | .Dq no . | ||
130 | +.Pp | ||
131 | +This option was formerly called | ||
132 | +.Cm KeepAlive . | ||
133 | .It Cm TrustedUserCAKeys | ||
134 | Specifies a file containing public keys of certificate authorities that are | ||
135 | trusted to sign user certificates for authentication, or | ||
diff --git a/debian/patches/lintian-symlink-pickiness.patch b/debian/patches/lintian-symlink-pickiness.patch new file mode 100644 index 000000000..a285b4c69 --- /dev/null +++ b/debian/patches/lintian-symlink-pickiness.patch | |||
@@ -0,0 +1,32 @@ | |||
1 | From 1237c8b43799156af8972c53c9ccc6b27140a284 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:08 +0000 | ||
4 | Subject: Fix picky lintian errors about slogin symlinks | ||
5 | |||
6 | Apparently this breaks some SVR4 packaging systems, so upstream can't win | ||
7 | either way and opted to keep the status quo. We need this patch anyway. | ||
8 | |||
9 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1728 | ||
10 | Last-Update: 2013-09-14 | ||
11 | |||
12 | Patch-Name: lintian-symlink-pickiness.patch | ||
13 | --- | ||
14 | Makefile.in | 4 ++-- | ||
15 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/Makefile.in b/Makefile.in | ||
18 | index 37cb023..f52f903 100644 | ||
19 | --- a/Makefile.in | ||
20 | +++ b/Makefile.in | ||
21 | @@ -331,9 +331,9 @@ install-files: | ||
22 | $(INSTALL) -m 644 ssh-keysign.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8 | ||
23 | $(INSTALL) -m 644 ssh-pkcs11-helper.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8 | ||
24 | -rm -f $(DESTDIR)$(bindir)/slogin | ||
25 | - ln -s ./ssh$(EXEEXT) $(DESTDIR)$(bindir)/slogin | ||
26 | + ln -s ssh$(EXEEXT) $(DESTDIR)$(bindir)/slogin | ||
27 | -rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1 | ||
28 | - ln -s ./ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1 | ||
29 | + ln -s ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1 | ||
30 | |||
31 | install-sysconf: | ||
32 | if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \ | ||
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..84804481e --- /dev/null +++ b/debian/patches/mention-ssh-keygen-on-keychange.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | From f948cb2d089ebf70b70db3d483d09ad97a0cf371 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 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1843 | ||
7 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/686607 | ||
8 | Last-Update: 2013-09-14 | ||
9 | |||
10 | Patch-Name: mention-ssh-keygen-on-keychange.patch | ||
11 | --- | ||
12 | sshconnect.c | 7 ++++++- | ||
13 | 1 file changed, 6 insertions(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/sshconnect.c b/sshconnect.c | ||
16 | index 8adc943..0c9fc6c 100644 | ||
17 | --- a/sshconnect.c | ||
18 | +++ b/sshconnect.c | ||
19 | @@ -1078,9 +1078,12 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port, | ||
20 | error("%s. This could either mean that", key_msg); | ||
21 | error("DNS SPOOFING is happening or the IP address for the host"); | ||
22 | error("and its host key have changed at the same time."); | ||
23 | - if (ip_status != HOST_NEW) | ||
24 | + if (ip_status != HOST_NEW) { | ||
25 | error("Offending key for IP in %s:%lu", | ||
26 | ip_found->file, ip_found->line); | ||
27 | + error(" remove with: ssh-keygen -f \"%s\" -R %s", | ||
28 | + ip_found->file, ip); | ||
29 | + } | ||
30 | } | ||
31 | /* The host key has changed. */ | ||
32 | warn_changed_key(host_key); | ||
33 | @@ -1088,6 +1091,8 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port, | ||
34 | user_hostfiles[0]); | ||
35 | error("Offending %s key in %s:%lu", key_type(host_found->key), | ||
36 | host_found->file, host_found->line); | ||
37 | + error(" remove with: ssh-keygen -f \"%s\" -R %s", | ||
38 | + host_found->file, host); | ||
39 | |||
40 | /* | ||
41 | * If strict host key checking is in use, the user will have | ||
diff --git a/debian/patches/no-openssl-version-status.patch b/debian/patches/no-openssl-version-status.patch new file mode 100644 index 000000000..73b16a368 --- /dev/null +++ b/debian/patches/no-openssl-version-status.patch | |||
@@ -0,0 +1,62 @@ | |||
1 | From d3777c50b834493fcfbc3549e1dfb465c10abeec 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 63a660c..3f62403 100644 | ||
27 | --- a/openbsd-compat/openssl-compat.c | ||
28 | +++ b/openbsd-compat/openssl-compat.c | ||
29 | @@ -36,7 +36,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 | @@ -57,10 +57,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 5d019b5..5847487 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..97971707f --- /dev/null +++ b/debian/patches/openbsd-docs.patch | |||
@@ -0,0 +1,148 @@ | |||
1 | From 3303a9d037ae9b62e5af01f467d8053cbd9c8410 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: 2014-10-07 | ||
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 ef0de08..149846c 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 9b93666..19bed1e 100644 | ||
48 | --- a/ssh-keygen.1 | ||
49 | +++ b/ssh-keygen.1 | ||
50 | @@ -174,9 +174,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 | @@ -223,9 +221,7 @@ For each of the key types (rsa1, rsa, dsa, ecdsa and ed25519) | ||
62 | for which host keys | ||
63 | do not exist, generate the host keys with the default key file path, | ||
64 | an empty passphrase, default bits for the key type, and default comment. | ||
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 any SSH protocol | ||
71 | 2 key when the | ||
72 | @@ -638,7 +634,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 | @@ -837,7 +833,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 c84196f..c3e1266 100644 | ||
92 | --- a/ssh.1 | ||
93 | +++ b/ssh.1 | ||
94 | @@ -766,6 +766,10 @@ Protocol 1 is restricted to using only RSA keys, | ||
95 | but protocol 2 may use any. | ||
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 5afd10f..2f4d4f3 100644 | ||
107 | --- a/sshd.8 | ||
108 | +++ b/sshd.8 | ||
109 | @@ -67,7 +67,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 | @@ -864,7 +864,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 | The file format is described in | ||
126 | .Xr moduli 5 . | ||
127 | @@ -963,7 +963,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 a5afbc3..355b445 100644 | ||
137 | --- a/sshd_config.5 | ||
138 | +++ b/sshd_config.5 | ||
139 | @@ -374,8 +374,7 @@ This option is only available for protocol version 2. | ||
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 | .Dq 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..6eb7b7243 --- /dev/null +++ b/debian/patches/package-versioning.patch | |||
@@ -0,0 +1,65 @@ | |||
1 | From c3a4906692ddd85d8530d2fdb74822ae793f18db 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: 2013-09-14 | ||
13 | |||
14 | Patch-Name: package-versioning.patch | ||
15 | --- | ||
16 | sshconnect.c | 4 ++-- | ||
17 | sshd.c | 2 +- | ||
18 | version.h | 7 ++++++- | ||
19 | 3 files changed, 9 insertions(+), 4 deletions(-) | ||
20 | |||
21 | diff --git a/sshconnect.c b/sshconnect.c | ||
22 | index 0c9fc6c..988f4ef 100644 | ||
23 | --- a/sshconnect.c | ||
24 | +++ b/sshconnect.c | ||
25 | @@ -524,10 +524,10 @@ send_client_banner(int connection_out, int minor1) | ||
26 | /* Send our own protocol version identification. */ | ||
27 | if (compat20) { | ||
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 | } else { | ||
32 | xasprintf(&client_version_string, "SSH-%d.%d-%.100s\n", | ||
33 | - PROTOCOL_MAJOR_1, minor1, SSH_VERSION); | ||
34 | + PROTOCOL_MAJOR_1, minor1, SSH_RELEASE); | ||
35 | } | ||
36 | if (roaming_atomicio(vwrite, connection_out, client_version_string, | ||
37 | strlen(client_version_string)) != strlen(client_version_string)) | ||
38 | diff --git a/sshd.c b/sshd.c | ||
39 | index 9ff9e8b..96e75c6 100644 | ||
40 | --- a/sshd.c | ||
41 | +++ b/sshd.c | ||
42 | @@ -442,7 +442,7 @@ sshd_exchange_identification(int sock_in, int sock_out) | ||
43 | } | ||
44 | |||
45 | xasprintf(&server_version_string, "SSH-%d.%d-%.100s%s%s%s", | ||
46 | - major, minor, SSH_VERSION, | ||
47 | + major, minor, SSH_RELEASE, | ||
48 | *options.version_addendum == '\0' ? "" : " ", | ||
49 | options.version_addendum, newline); | ||
50 | |||
51 | diff --git a/version.h b/version.h | ||
52 | index b58fbe1..bff2b3b 100644 | ||
53 | --- a/version.h | ||
54 | +++ b/version.h | ||
55 | @@ -3,4 +3,9 @@ | ||
56 | #define SSH_VERSION "OpenSSH_6.9" | ||
57 | |||
58 | #define SSH_PORTABLE "p1" | ||
59 | -#define SSH_RELEASE SSH_VERSION SSH_PORTABLE | ||
60 | +#define SSH_RELEASE_MINIMUM SSH_VERSION SSH_PORTABLE | ||
61 | +#ifdef SSH_EXTRAVERSION | ||
62 | +#define SSH_RELEASE SSH_RELEASE_MINIMUM " " SSH_EXTRAVERSION | ||
63 | +#else | ||
64 | +#define SSH_RELEASE SSH_RELEASE_MINIMUM | ||
65 | +#endif | ||
diff --git a/debian/patches/quieter-signals.patch b/debian/patches/quieter-signals.patch new file mode 100644 index 000000000..ba16a9943 --- /dev/null +++ b/debian/patches/quieter-signals.patch | |||
@@ -0,0 +1,40 @@ | |||
1 | From 7c26c2f768c5d457c6645c1e1c077ba10a853626 Mon Sep 17 00:00:00 2001 | ||
2 | From: Peter Samuelson <peter@p12n.org> | ||
3 | Date: Sun, 9 Feb 2014 16:09:55 +0000 | ||
4 | Subject: Reduce severity of "Killed by signal %d" | ||
5 | |||
6 | This produces irritating messages when using ProxyCommand or other programs | ||
7 | that use ssh under the covers (e.g. Subversion). These messages are more | ||
8 | normally printed by the calling program, such as the shell. | ||
9 | |||
10 | According to the upstream bug, the right way to avoid this is to use the -q | ||
11 | option, so we may drop this patch after further investigation into whether | ||
12 | any software in Debian is still relying on it. | ||
13 | |||
14 | Author: Colin Watson <cjwatson@debian.org> | ||
15 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1118 | ||
16 | Bug-Debian: http://bugs.debian.org/313371 | ||
17 | Last-Update: 2013-09-14 | ||
18 | |||
19 | Patch-Name: quieter-signals.patch | ||
20 | --- | ||
21 | clientloop.c | 6 ++++-- | ||
22 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
23 | |||
24 | diff --git a/clientloop.c b/clientloop.c | ||
25 | index 964353d..65f90b8 100644 | ||
26 | --- a/clientloop.c | ||
27 | +++ b/clientloop.c | ||
28 | @@ -1720,8 +1720,10 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | ||
29 | exit_status = 0; | ||
30 | } | ||
31 | |||
32 | - if (received_signal) | ||
33 | - fatal("Killed by signal %d.", (int) received_signal); | ||
34 | + if (received_signal) { | ||
35 | + debug("Killed by signal %d.", (int) received_signal); | ||
36 | + cleanup_exit((int) received_signal + 128); | ||
37 | + } | ||
38 | |||
39 | /* | ||
40 | * In interactive mode (with pseudo tty) display a message indicating | ||
diff --git a/debian/patches/restore-tcp-wrappers.patch b/debian/patches/restore-tcp-wrappers.patch new file mode 100644 index 000000000..9e0435313 --- /dev/null +++ b/debian/patches/restore-tcp-wrappers.patch | |||
@@ -0,0 +1,172 @@ | |||
1 | From ace4bfab52b31a2833636a243ba150fdf0f48293 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 df21693..4d55c46 100644 | ||
32 | --- a/configure.ac | ||
33 | +++ b/configure.ac | ||
34 | @@ -1448,6 +1448,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 | @@ -4928,6 +4984,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 " Solaris process contract support: $SPC_MSG" | ||
105 | diff --git a/sshd.8 b/sshd.8 | ||
106 | index dcf20f0..5afd10f 100644 | ||
107 | --- a/sshd.8 | ||
108 | +++ b/sshd.8 | ||
109 | @@ -853,6 +853,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 | @@ -956,6 +962,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 6b85e6c..186ad55 100644 | ||
132 | --- a/sshd.c | ||
133 | +++ b/sshd.c | ||
134 | @@ -129,6 +129,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 | #ifndef O_NOCTTY | ||
146 | #define O_NOCTTY 0 | ||
147 | #endif | ||
148 | @@ -2141,6 +2148,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..fcf389dec --- /dev/null +++ b/debian/patches/scp-quoting.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | From 9921536f50f50eb283dea50c77753eb0773d4258 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 593fe89..e39294e 100644 | ||
21 | --- a/scp.c | ||
22 | +++ b/scp.c | ||
23 | @@ -190,8 +190,16 @@ do_local_cmd(arglist *a) | ||
24 | |||
25 | if (verbose_mode) { | ||
26 | fprintf(stderr, "Executing:"); | ||
27 | - for (i = 0; i < a->num; i++) | ||
28 | - fprintf(stderr, " %s", a->list[i]); | ||
29 | + for (i = 0; i < a->num; i++) { | ||
30 | + if (i == 0) | ||
31 | + fprintf(stderr, " %s", a->list[i]); | ||
32 | + else | ||
33 | + /* | ||
34 | + * TODO: misbehaves if a->list[i] contains a | ||
35 | + * single quote | ||
36 | + */ | ||
37 | + fprintf(stderr, " '%s'", a->list[i]); | ||
38 | + } | ||
39 | fprintf(stderr, "\n"); | ||
40 | } | ||
41 | if ((pid = fork()) == -1) | ||
diff --git a/debian/patches/selinux-role.patch b/debian/patches/selinux-role.patch new file mode 100644 index 000000000..617aa3b11 --- /dev/null +++ b/debian/patches/selinux-role.patch | |||
@@ -0,0 +1,504 @@ | |||
1 | From 8b3e4a6ddad01fef62d153ac3b033de61a02696e 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: 2015-08-19 | ||
13 | |||
14 | Patch-Name: selinux-role.patch | ||
15 | --- | ||
16 | auth.h | 1 + | ||
17 | auth1.c | 8 +++++++- | ||
18 | auth2.c | 10 ++++++++-- | ||
19 | monitor.c | 32 +++++++++++++++++++++++++++++--- | ||
20 | monitor.h | 2 ++ | ||
21 | monitor_wrap.c | 22 ++++++++++++++++++++-- | ||
22 | monitor_wrap.h | 3 ++- | ||
23 | openbsd-compat/port-linux.c | 27 ++++++++++++++++++++------- | ||
24 | openbsd-compat/port-linux.h | 4 ++-- | ||
25 | platform.c | 4 ++-- | ||
26 | platform.h | 2 +- | ||
27 | session.c | 10 +++++----- | ||
28 | session.h | 2 +- | ||
29 | sshd.c | 2 +- | ||
30 | sshpty.c | 4 ++-- | ||
31 | sshpty.h | 2 +- | ||
32 | 16 files changed, 104 insertions(+), 31 deletions(-) | ||
33 | |||
34 | diff --git a/auth.h b/auth.h | ||
35 | index 8b27575..3c2222f 100644 | ||
36 | --- a/auth.h | ||
37 | +++ b/auth.h | ||
38 | @@ -62,6 +62,7 @@ struct Authctxt { | ||
39 | char *service; | ||
40 | struct passwd *pw; /* set if 'valid' */ | ||
41 | char *style; | ||
42 | + char *role; | ||
43 | void *kbdintctxt; | ||
44 | char *info; /* Extra info for next auth_log */ | ||
45 | #ifdef BSD_AUTH | ||
46 | diff --git a/auth1.c b/auth1.c | ||
47 | index 5073c49..dd00648 100644 | ||
48 | --- a/auth1.c | ||
49 | +++ b/auth1.c | ||
50 | @@ -383,7 +383,7 @@ void | ||
51 | do_authentication(Authctxt *authctxt) | ||
52 | { | ||
53 | u_int ulen; | ||
54 | - char *user, *style = NULL; | ||
55 | + char *user, *style = NULL, *role = NULL; | ||
56 | |||
57 | /* Get the name of the user that we wish to log in as. */ | ||
58 | packet_read_expect(SSH_CMSG_USER); | ||
59 | @@ -392,11 +392,17 @@ do_authentication(Authctxt *authctxt) | ||
60 | user = packet_get_cstring(&ulen); | ||
61 | packet_check_eom(); | ||
62 | |||
63 | + if ((role = strchr(user, '/')) != NULL) | ||
64 | + *role++ = '\0'; | ||
65 | + | ||
66 | if ((style = strchr(user, ':')) != NULL) | ||
67 | *style++ = '\0'; | ||
68 | + else if (role && (style = strchr(role, ':')) != NULL) | ||
69 | + *style++ = '\0'; | ||
70 | |||
71 | authctxt->user = user; | ||
72 | authctxt->style = style; | ||
73 | + authctxt->role = role; | ||
74 | |||
75 | /* Verify that the user is a valid user. */ | ||
76 | if ((authctxt->pw = PRIVSEP(getpwnamallow(user))) != NULL) | ||
77 | diff --git a/auth2.c b/auth2.c | ||
78 | index 3f49bdc..6eb3cc7 100644 | ||
79 | --- a/auth2.c | ||
80 | +++ b/auth2.c | ||
81 | @@ -216,7 +216,7 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt) | ||
82 | { | ||
83 | Authctxt *authctxt = ctxt; | ||
84 | Authmethod *m = NULL; | ||
85 | - char *user, *service, *method, *style = NULL; | ||
86 | + char *user, *service, *method, *style = NULL, *role = NULL; | ||
87 | int authenticated = 0; | ||
88 | |||
89 | if (authctxt == NULL) | ||
90 | @@ -228,8 +228,13 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt) | ||
91 | debug("userauth-request for user %s service %s method %s", user, service, method); | ||
92 | debug("attempt %d failures %d", authctxt->attempt, authctxt->failures); | ||
93 | |||
94 | + if ((role = strchr(user, '/')) != NULL) | ||
95 | + *role++ = 0; | ||
96 | + | ||
97 | if ((style = strchr(user, ':')) != NULL) | ||
98 | *style++ = 0; | ||
99 | + else if (role && (style = strchr(role, ':')) != NULL) | ||
100 | + *style++ = '\0'; | ||
101 | |||
102 | if (authctxt->attempt++ == 0) { | ||
103 | /* setup auth context */ | ||
104 | @@ -253,8 +258,9 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt) | ||
105 | use_privsep ? " [net]" : ""); | ||
106 | authctxt->service = xstrdup(service); | ||
107 | authctxt->style = style ? xstrdup(style) : NULL; | ||
108 | + authctxt->role = role ? xstrdup(role) : NULL; | ||
109 | if (use_privsep) | ||
110 | - mm_inform_authserv(service, style); | ||
111 | + mm_inform_authserv(service, style, role); | ||
112 | userauth_banner(); | ||
113 | if (auth2_setup_methods_lists(authctxt) != 0) | ||
114 | packet_disconnect("no authentication methods enabled"); | ||
115 | diff --git a/monitor.c b/monitor.c | ||
116 | index bdc2972..3a3d2f0 100644 | ||
117 | --- a/monitor.c | ||
118 | +++ b/monitor.c | ||
119 | @@ -127,6 +127,7 @@ int mm_answer_sign(int, Buffer *); | ||
120 | int mm_answer_pwnamallow(int, Buffer *); | ||
121 | int mm_answer_auth2_read_banner(int, Buffer *); | ||
122 | int mm_answer_authserv(int, Buffer *); | ||
123 | +int mm_answer_authrole(int, Buffer *); | ||
124 | int mm_answer_authpassword(int, Buffer *); | ||
125 | int mm_answer_bsdauthquery(int, Buffer *); | ||
126 | int mm_answer_bsdauthrespond(int, Buffer *); | ||
127 | @@ -208,6 +209,7 @@ struct mon_table mon_dispatch_proto20[] = { | ||
128 | {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, | ||
129 | {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, | ||
130 | {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, | ||
131 | + {MONITOR_REQ_AUTHROLE, MON_ONCE, mm_answer_authrole}, | ||
132 | {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, | ||
133 | {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, | ||
134 | #ifdef USE_PAM | ||
135 | @@ -879,6 +881,7 @@ mm_answer_pwnamallow(int sock, Buffer *m) | ||
136 | else { | ||
137 | /* Allow service/style information on the auth context */ | ||
138 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); | ||
139 | + monitor_permit(mon_dispatch, MONITOR_REQ_AUTHROLE, 1); | ||
140 | monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); | ||
141 | } | ||
142 | #ifdef USE_PAM | ||
143 | @@ -909,14 +912,37 @@ mm_answer_authserv(int sock, Buffer *m) | ||
144 | |||
145 | authctxt->service = buffer_get_string(m, NULL); | ||
146 | authctxt->style = buffer_get_string(m, NULL); | ||
147 | - debug3("%s: service=%s, style=%s", | ||
148 | - __func__, authctxt->service, authctxt->style); | ||
149 | + authctxt->role = buffer_get_string(m, NULL); | ||
150 | + debug3("%s: service=%s, style=%s, role=%s", | ||
151 | + __func__, authctxt->service, authctxt->style, authctxt->role); | ||
152 | |||
153 | if (strlen(authctxt->style) == 0) { | ||
154 | free(authctxt->style); | ||
155 | authctxt->style = NULL; | ||
156 | } | ||
157 | |||
158 | + if (strlen(authctxt->role) == 0) { | ||
159 | + free(authctxt->role); | ||
160 | + authctxt->role = NULL; | ||
161 | + } | ||
162 | + | ||
163 | + return (0); | ||
164 | +} | ||
165 | + | ||
166 | +int | ||
167 | +mm_answer_authrole(int sock, Buffer *m) | ||
168 | +{ | ||
169 | + monitor_permit_authentications(1); | ||
170 | + | ||
171 | + authctxt->role = buffer_get_string(m, NULL); | ||
172 | + debug3("%s: role=%s", | ||
173 | + __func__, authctxt->role); | ||
174 | + | ||
175 | + if (strlen(authctxt->role) == 0) { | ||
176 | + free(authctxt->role); | ||
177 | + authctxt->role = NULL; | ||
178 | + } | ||
179 | + | ||
180 | return (0); | ||
181 | } | ||
182 | |||
183 | @@ -1544,7 +1570,7 @@ mm_answer_pty(int sock, Buffer *m) | ||
184 | res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty)); | ||
185 | if (res == 0) | ||
186 | goto error; | ||
187 | - pty_setowner(authctxt->pw, s->tty); | ||
188 | + pty_setowner(authctxt->pw, s->tty, authctxt->role); | ||
189 | |||
190 | buffer_put_int(m, 1); | ||
191 | buffer_put_cstring(m, s->tty); | ||
192 | diff --git a/monitor.h b/monitor.h | ||
193 | index bc50ade..2d82b8b 100644 | ||
194 | --- a/monitor.h | ||
195 | +++ b/monitor.h | ||
196 | @@ -68,6 +68,8 @@ enum monitor_reqtype { | ||
197 | MONITOR_REQ_GSSSIGN = 150, MONITOR_ANS_GSSSIGN = 151, | ||
198 | MONITOR_REQ_GSSUPCREDS = 152, MONITOR_ANS_GSSUPCREDS = 153, | ||
199 | |||
200 | + MONITOR_REQ_AUTHROLE = 154, | ||
201 | + | ||
202 | }; | ||
203 | |||
204 | struct mm_master; | ||
205 | diff --git a/monitor_wrap.c b/monitor_wrap.c | ||
206 | index 71e7c08..6ae72a0 100644 | ||
207 | --- a/monitor_wrap.c | ||
208 | +++ b/monitor_wrap.c | ||
209 | @@ -327,10 +327,10 @@ mm_auth2_read_banner(void) | ||
210 | return (banner); | ||
211 | } | ||
212 | |||
213 | -/* Inform the privileged process about service and style */ | ||
214 | +/* Inform the privileged process about service, style, and role */ | ||
215 | |||
216 | void | ||
217 | -mm_inform_authserv(char *service, char *style) | ||
218 | +mm_inform_authserv(char *service, char *style, char *role) | ||
219 | { | ||
220 | Buffer m; | ||
221 | |||
222 | @@ -339,12 +339,30 @@ mm_inform_authserv(char *service, char *style) | ||
223 | buffer_init(&m); | ||
224 | buffer_put_cstring(&m, service); | ||
225 | buffer_put_cstring(&m, style ? style : ""); | ||
226 | + buffer_put_cstring(&m, role ? role : ""); | ||
227 | |||
228 | mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHSERV, &m); | ||
229 | |||
230 | buffer_free(&m); | ||
231 | } | ||
232 | |||
233 | +/* Inform the privileged process about role */ | ||
234 | + | ||
235 | +void | ||
236 | +mm_inform_authrole(char *role) | ||
237 | +{ | ||
238 | + Buffer m; | ||
239 | + | ||
240 | + debug3("%s entering", __func__); | ||
241 | + | ||
242 | + buffer_init(&m); | ||
243 | + buffer_put_cstring(&m, role ? role : ""); | ||
244 | + | ||
245 | + mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHROLE, &m); | ||
246 | + | ||
247 | + buffer_free(&m); | ||
248 | +} | ||
249 | + | ||
250 | /* Do the password authentication */ | ||
251 | int | ||
252 | mm_auth_password(Authctxt *authctxt, char *password) | ||
253 | diff --git a/monitor_wrap.h b/monitor_wrap.h | ||
254 | index 9758290..57e740f 100644 | ||
255 | --- a/monitor_wrap.h | ||
256 | +++ b/monitor_wrap.h | ||
257 | @@ -41,7 +41,8 @@ void mm_log_handler(LogLevel, const char *, void *); | ||
258 | int mm_is_monitor(void); | ||
259 | DH *mm_choose_dh(int, int, int); | ||
260 | int mm_key_sign(Key *, u_char **, u_int *, const u_char *, u_int); | ||
261 | -void mm_inform_authserv(char *, char *); | ||
262 | +void mm_inform_authserv(char *, char *, char *); | ||
263 | +void mm_inform_authrole(char *); | ||
264 | struct passwd *mm_getpwnamallow(const char *); | ||
265 | char *mm_auth2_read_banner(void); | ||
266 | int mm_auth_password(struct Authctxt *, char *); | ||
267 | diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c | ||
268 | index 4637a7a..de6ad3f 100644 | ||
269 | --- a/openbsd-compat/port-linux.c | ||
270 | +++ b/openbsd-compat/port-linux.c | ||
271 | @@ -29,6 +29,12 @@ | ||
272 | #include <string.h> | ||
273 | #include <stdio.h> | ||
274 | |||
275 | +#ifdef WITH_SELINUX | ||
276 | +#include "key.h" | ||
277 | +#include "hostfile.h" | ||
278 | +#include "auth.h" | ||
279 | +#endif | ||
280 | + | ||
281 | #include "log.h" | ||
282 | #include "xmalloc.h" | ||
283 | #include "port-linux.h" | ||
284 | @@ -58,7 +64,7 @@ ssh_selinux_enabled(void) | ||
285 | |||
286 | /* Return the default security context for the given username */ | ||
287 | static security_context_t | ||
288 | -ssh_selinux_getctxbyname(char *pwname) | ||
289 | +ssh_selinux_getctxbyname(char *pwname, const char *role) | ||
290 | { | ||
291 | security_context_t sc = NULL; | ||
292 | char *sename = NULL, *lvl = NULL; | ||
293 | @@ -73,9 +79,16 @@ ssh_selinux_getctxbyname(char *pwname) | ||
294 | #endif | ||
295 | |||
296 | #ifdef HAVE_GET_DEFAULT_CONTEXT_WITH_LEVEL | ||
297 | - r = get_default_context_with_level(sename, lvl, NULL, &sc); | ||
298 | + if (role != NULL && role[0]) | ||
299 | + r = get_default_context_with_rolelevel(sename, role, lvl, NULL, | ||
300 | + &sc); | ||
301 | + else | ||
302 | + r = get_default_context_with_level(sename, lvl, NULL, &sc); | ||
303 | #else | ||
304 | - r = get_default_context(sename, NULL, &sc); | ||
305 | + if (role != NULL && role[0]) | ||
306 | + r = get_default_context_with_role(sename, role, NULL, &sc); | ||
307 | + else | ||
308 | + r = get_default_context(sename, NULL, &sc); | ||
309 | #endif | ||
310 | |||
311 | if (r != 0) { | ||
312 | @@ -105,7 +118,7 @@ ssh_selinux_getctxbyname(char *pwname) | ||
313 | |||
314 | /* Set the execution context to the default for the specified user */ | ||
315 | void | ||
316 | -ssh_selinux_setup_exec_context(char *pwname) | ||
317 | +ssh_selinux_setup_exec_context(char *pwname, const char *role) | ||
318 | { | ||
319 | security_context_t user_ctx = NULL; | ||
320 | |||
321 | @@ -114,7 +127,7 @@ ssh_selinux_setup_exec_context(char *pwname) | ||
322 | |||
323 | debug3("%s: setting execution context", __func__); | ||
324 | |||
325 | - user_ctx = ssh_selinux_getctxbyname(pwname); | ||
326 | + user_ctx = ssh_selinux_getctxbyname(pwname, role); | ||
327 | if (setexeccon(user_ctx) != 0) { | ||
328 | switch (security_getenforce()) { | ||
329 | case -1: | ||
330 | @@ -136,7 +149,7 @@ ssh_selinux_setup_exec_context(char *pwname) | ||
331 | |||
332 | /* Set the TTY context for the specified user */ | ||
333 | void | ||
334 | -ssh_selinux_setup_pty(char *pwname, const char *tty) | ||
335 | +ssh_selinux_setup_pty(char *pwname, const char *tty, const char *role) | ||
336 | { | ||
337 | security_context_t new_tty_ctx = NULL; | ||
338 | security_context_t user_ctx = NULL; | ||
339 | @@ -147,7 +160,7 @@ ssh_selinux_setup_pty(char *pwname, const char *tty) | ||
340 | |||
341 | debug3("%s: setting TTY context on %s", __func__, tty); | ||
342 | |||
343 | - user_ctx = ssh_selinux_getctxbyname(pwname); | ||
344 | + user_ctx = ssh_selinux_getctxbyname(pwname, role); | ||
345 | |||
346 | /* XXX: should these calls fatal() upon failure in enforcing mode? */ | ||
347 | |||
348 | diff --git a/openbsd-compat/port-linux.h b/openbsd-compat/port-linux.h | ||
349 | index e3d1004..80ce13a 100644 | ||
350 | --- a/openbsd-compat/port-linux.h | ||
351 | +++ b/openbsd-compat/port-linux.h | ||
352 | @@ -21,8 +21,8 @@ | ||
353 | |||
354 | #ifdef WITH_SELINUX | ||
355 | int ssh_selinux_enabled(void); | ||
356 | -void ssh_selinux_setup_pty(char *, const char *); | ||
357 | -void ssh_selinux_setup_exec_context(char *); | ||
358 | +void ssh_selinux_setup_pty(char *, const char *, const char *); | ||
359 | +void ssh_selinux_setup_exec_context(char *, const char *); | ||
360 | void ssh_selinux_change_context(const char *); | ||
361 | void ssh_selinux_setfscreatecon(const char *); | ||
362 | #endif | ||
363 | diff --git a/platform.c b/platform.c | ||
364 | index ee313da..f35ec39 100644 | ||
365 | --- a/platform.c | ||
366 | +++ b/platform.c | ||
367 | @@ -143,7 +143,7 @@ platform_setusercontext(struct passwd *pw) | ||
368 | * called if sshd is running as root. | ||
369 | */ | ||
370 | void | ||
371 | -platform_setusercontext_post_groups(struct passwd *pw) | ||
372 | +platform_setusercontext_post_groups(struct passwd *pw, const char *role) | ||
373 | { | ||
374 | #if !defined(HAVE_LOGIN_CAP) && defined(USE_PAM) | ||
375 | /* | ||
376 | @@ -184,7 +184,7 @@ platform_setusercontext_post_groups(struct passwd *pw) | ||
377 | } | ||
378 | #endif /* HAVE_SETPCRED */ | ||
379 | #ifdef WITH_SELINUX | ||
380 | - ssh_selinux_setup_exec_context(pw->pw_name); | ||
381 | + ssh_selinux_setup_exec_context(pw->pw_name, role); | ||
382 | #endif | ||
383 | } | ||
384 | |||
385 | diff --git a/platform.h b/platform.h | ||
386 | index 1c7a45d..436ae7c 100644 | ||
387 | --- a/platform.h | ||
388 | +++ b/platform.h | ||
389 | @@ -27,7 +27,7 @@ void platform_post_fork_parent(pid_t child_pid); | ||
390 | void platform_post_fork_child(void); | ||
391 | int platform_privileged_uidswap(void); | ||
392 | void platform_setusercontext(struct passwd *); | ||
393 | -void platform_setusercontext_post_groups(struct passwd *); | ||
394 | +void platform_setusercontext_post_groups(struct passwd *, const char *); | ||
395 | char *platform_get_krb5_client(const char *); | ||
396 | char *platform_krb5_get_principal_name(const char *); | ||
397 | int platform_sys_dir_uid(uid_t); | ||
398 | diff --git a/session.c b/session.c | ||
399 | index 5a64715..afac4a5 100644 | ||
400 | --- a/session.c | ||
401 | +++ b/session.c | ||
402 | @@ -1487,7 +1487,7 @@ safely_chroot(const char *path, uid_t uid) | ||
403 | |||
404 | /* Set login name, uid, gid, and groups. */ | ||
405 | void | ||
406 | -do_setusercontext(struct passwd *pw) | ||
407 | +do_setusercontext(struct passwd *pw, const char *role) | ||
408 | { | ||
409 | char *chroot_path, *tmp; | ||
410 | #ifdef USE_LIBIAF | ||
411 | @@ -1518,7 +1518,7 @@ do_setusercontext(struct passwd *pw) | ||
412 | endgrent(); | ||
413 | #endif | ||
414 | |||
415 | - platform_setusercontext_post_groups(pw); | ||
416 | + platform_setusercontext_post_groups(pw, role); | ||
417 | |||
418 | if (options.chroot_directory != NULL && | ||
419 | strcasecmp(options.chroot_directory, "none") != 0) { | ||
420 | @@ -1677,7 +1677,7 @@ do_child(Session *s, const char *command) | ||
421 | |||
422 | /* Force a password change */ | ||
423 | if (s->authctxt->force_pwchange) { | ||
424 | - do_setusercontext(pw); | ||
425 | + do_setusercontext(pw, s->authctxt->role); | ||
426 | child_close_fds(); | ||
427 | do_pwchange(s); | ||
428 | exit(1); | ||
429 | @@ -1704,7 +1704,7 @@ do_child(Session *s, const char *command) | ||
430 | /* When PAM is enabled we rely on it to do the nologin check */ | ||
431 | if (!options.use_pam) | ||
432 | do_nologin(pw); | ||
433 | - do_setusercontext(pw); | ||
434 | + do_setusercontext(pw, s->authctxt->role); | ||
435 | /* | ||
436 | * PAM session modules in do_setusercontext may have | ||
437 | * generated messages, so if this in an interactive | ||
438 | @@ -2115,7 +2115,7 @@ session_pty_req(Session *s) | ||
439 | tty_parse_modes(s->ttyfd, &n_bytes); | ||
440 | |||
441 | if (!use_privsep) | ||
442 | - pty_setowner(s->pw, s->tty); | ||
443 | + pty_setowner(s->pw, s->tty, s->authctxt->role); | ||
444 | |||
445 | /* Set window size from the packet. */ | ||
446 | pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); | ||
447 | diff --git a/session.h b/session.h | ||
448 | index 6a2f35e..ef6593c 100644 | ||
449 | --- a/session.h | ||
450 | +++ b/session.h | ||
451 | @@ -77,7 +77,7 @@ void session_pty_cleanup2(Session *); | ||
452 | Session *session_new(void); | ||
453 | Session *session_by_tty(char *); | ||
454 | void session_close(Session *); | ||
455 | -void do_setusercontext(struct passwd *); | ||
456 | +void do_setusercontext(struct passwd *, const char *); | ||
457 | void child_set_env(char ***envp, u_int *envsizep, const char *name, | ||
458 | const char *value); | ||
459 | |||
460 | diff --git a/sshd.c b/sshd.c | ||
461 | index 186ad55..9ff9e8b 100644 | ||
462 | --- a/sshd.c | ||
463 | +++ b/sshd.c | ||
464 | @@ -781,7 +781,7 @@ privsep_postauth(Authctxt *authctxt) | ||
465 | explicit_bzero(rnd, sizeof(rnd)); | ||
466 | |||
467 | /* Drop privileges */ | ||
468 | - do_setusercontext(authctxt->pw); | ||
469 | + do_setusercontext(authctxt->pw, authctxt->role); | ||
470 | |||
471 | skip: | ||
472 | /* It is safe now to apply the key state */ | ||
473 | diff --git a/sshpty.c b/sshpty.c | ||
474 | index 7bb7641..0e32b39 100644 | ||
475 | --- a/sshpty.c | ||
476 | +++ b/sshpty.c | ||
477 | @@ -187,7 +187,7 @@ pty_change_window_size(int ptyfd, u_int row, u_int col, | ||
478 | } | ||
479 | |||
480 | void | ||
481 | -pty_setowner(struct passwd *pw, const char *tty) | ||
482 | +pty_setowner(struct passwd *pw, const char *tty, const char *role) | ||
483 | { | ||
484 | struct group *grp; | ||
485 | gid_t gid; | ||
486 | @@ -209,7 +209,7 @@ pty_setowner(struct passwd *pw, const char *tty) | ||
487 | strerror(errno)); | ||
488 | |||
489 | #ifdef WITH_SELINUX | ||
490 | - ssh_selinux_setup_pty(pw->pw_name, tty); | ||
491 | + ssh_selinux_setup_pty(pw->pw_name, tty, role); | ||
492 | #endif | ||
493 | |||
494 | if (st.st_uid != pw->pw_uid || st.st_gid != gid) { | ||
495 | diff --git a/sshpty.h b/sshpty.h | ||
496 | index cfa3224..edf2436 100644 | ||
497 | --- a/sshpty.h | ||
498 | +++ b/sshpty.h | ||
499 | @@ -24,4 +24,4 @@ int pty_allocate(int *, int *, char *, size_t); | ||
500 | void pty_release(const char *); | ||
501 | void pty_make_controlling_tty(int *, const char *); | ||
502 | void pty_change_window_size(int, u_int, u_int, u_int, u_int); | ||
503 | -void pty_setowner(struct passwd *, const char *); | ||
504 | +void pty_setowner(struct passwd *, const char *, const char *); | ||
diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 000000000..188ec8abc --- /dev/null +++ b/debian/patches/series | |||
@@ -0,0 +1,33 @@ | |||
1 | gssapi.patch | ||
2 | restore-tcp-wrappers.patch | ||
3 | selinux-role.patch | ||
4 | ssh-vulnkey-compat.patch | ||
5 | ssh1-keepalive.patch | ||
6 | keepalive-extensions.patch | ||
7 | syslog-level-silent.patch | ||
8 | quieter-signals.patch | ||
9 | helpful-wait-terminate.patch | ||
10 | consolekit.patch | ||
11 | user-group-modes.patch | ||
12 | scp-quoting.patch | ||
13 | shell-path.patch | ||
14 | dnssec-sshfp.patch | ||
15 | auth-log-verbosity.patch | ||
16 | mention-ssh-keygen-on-keychange.patch | ||
17 | package-versioning.patch | ||
18 | debian-banner.patch | ||
19 | authorized-keys-man-symlink.patch | ||
20 | lintian-symlink-pickiness.patch | ||
21 | openbsd-docs.patch | ||
22 | ssh-argv0.patch | ||
23 | doc-hash-tab-completion.patch | ||
24 | doc-upstart.patch | ||
25 | ssh-agent-setgid.patch | ||
26 | no-openssl-version-status.patch | ||
27 | gnome-ssh-askpass2-icon.patch | ||
28 | sigstop.patch | ||
29 | debian-config.patch | ||
30 | backport-fix-pty-permissions.patch | ||
31 | backport-do-not-resend-username-to-pam.patch | ||
32 | backport-pam-use-after-free.patch | ||
33 | backport-kbdint-duplicates.patch | ||
diff --git a/debian/patches/shell-path.patch b/debian/patches/shell-path.patch new file mode 100644 index 000000000..c12d86132 --- /dev/null +++ b/debian/patches/shell-path.patch | |||
@@ -0,0 +1,39 @@ | |||
1 | From 865180de0e7d4735170faac2d584603fbe0530b2 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 f41960c..8adc943 100644 | ||
20 | --- a/sshconnect.c | ||
21 | +++ b/sshconnect.c | ||
22 | @@ -231,7 +231,7 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) | ||
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 | @@ -1471,7 +1471,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/sigstop.patch b/debian/patches/sigstop.patch new file mode 100644 index 000000000..ae65d8285 --- /dev/null +++ b/debian/patches/sigstop.patch | |||
@@ -0,0 +1,35 @@ | |||
1 | From b0b95d9689563856ac4992c90b65ed4fd8f3fae6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:10:17 +0000 | ||
4 | Subject: Support synchronisation with service supervisor using SIGSTOP | ||
5 | |||
6 | Author: Robie Basak <robie.basak@ubuntu.com> | ||
7 | Forwarded: no | ||
8 | Last-Update: 2014-04-14 | ||
9 | |||
10 | Patch-Name: sigstop.patch | ||
11 | --- | ||
12 | sshd.c | 10 ++++++++++ | ||
13 | 1 file changed, 10 insertions(+) | ||
14 | |||
15 | diff --git a/sshd.c b/sshd.c | ||
16 | index 7886d0e..cc8ecaf 100644 | ||
17 | --- a/sshd.c | ||
18 | +++ b/sshd.c | ||
19 | @@ -2038,6 +2038,16 @@ main(int ac, char **av) | ||
20 | } | ||
21 | } | ||
22 | |||
23 | + if (getenv("SSH_SIGSTOP")) { | ||
24 | + /* Tell service supervisor that we are ready. */ | ||
25 | + kill(getpid(), SIGSTOP); | ||
26 | + /* The service supervisor only ever expects a single | ||
27 | + * STOP signal, so do not ever signal it again, even | ||
28 | + * in the case of a re-exec or future children. | ||
29 | + */ | ||
30 | + unsetenv("SSH_SIGSTOP"); | ||
31 | + } | ||
32 | + | ||
33 | /* Accept a connection and return in a forked child */ | ||
34 | server_accept_loop(&sock_in, &sock_out, | ||
35 | &newsock, config_s); | ||
diff --git a/debian/patches/ssh-agent-setgid.patch b/debian/patches/ssh-agent-setgid.patch new file mode 100644 index 000000000..aa9fa7e4d --- /dev/null +++ b/debian/patches/ssh-agent-setgid.patch | |||
@@ -0,0 +1,40 @@ | |||
1 | From 95d0369e741776a0d18cffb2e4526dee37ebdbd6 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 d0aa712..2a940d9 100644 | ||
17 | --- a/ssh-agent.1 | ||
18 | +++ b/ssh-agent.1 | ||
19 | @@ -186,6 +186,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.\*(Ltppid\*(Gt | ||
diff --git a/debian/patches/ssh-argv0.patch b/debian/patches/ssh-argv0.patch new file mode 100644 index 000000000..fce893c91 --- /dev/null +++ b/debian/patches/ssh-argv0.patch | |||
@@ -0,0 +1,31 @@ | |||
1 | From abc6170edaed77f07694dd001c87077376157eaa 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 c3e1266..2178863 100644 | ||
22 | --- a/ssh.1 | ||
23 | +++ b/ssh.1 | ||
24 | @@ -1487,6 +1487,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..7af91e955 --- /dev/null +++ b/debian/patches/ssh-vulnkey-compat.patch | |||
@@ -0,0 +1,42 @@ | |||
1 | From dd02db02d322c9db67d42fe491727854f951c828 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 68dac76..85eea48 100644 | ||
21 | --- a/readconf.c | ||
22 | +++ b/readconf.c | ||
23 | @@ -180,6 +180,7 @@ static struct { | ||
24 | { "passwordauthentication", oPasswordAuthentication }, | ||
25 | { "kbdinteractiveauthentication", oKbdInteractiveAuthentication }, | ||
26 | { "kbdinteractivedevices", oKbdInteractiveDevices }, | ||
27 | + { "useblacklistedkeys", oDeprecated }, | ||
28 | { "rsaauthentication", oRSAAuthentication }, | ||
29 | { "pubkeyauthentication", oPubkeyAuthentication }, | ||
30 | { "dsaauthentication", oPubkeyAuthentication }, /* alias */ | ||
31 | diff --git a/servconf.c b/servconf.c | ||
32 | index 2f7f41e..8a5bd7b 100644 | ||
33 | --- a/servconf.c | ||
34 | +++ b/servconf.c | ||
35 | @@ -510,6 +510,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", sUseLogin, SSHCFG_GLOBAL }, | ||
diff --git a/debian/patches/ssh1-keepalive.patch b/debian/patches/ssh1-keepalive.patch new file mode 100644 index 000000000..48308bcff --- /dev/null +++ b/debian/patches/ssh1-keepalive.patch | |||
@@ -0,0 +1,74 @@ | |||
1 | From b3d7661669a0f5255ede81f82c25951aeba9576c Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Watson <cjwatson@debian.org> | ||
3 | Date: Sun, 9 Feb 2014 16:09:51 +0000 | ||
4 | Subject: Partial server keep-alive implementation for SSH1 | ||
5 | |||
6 | Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1712 | ||
7 | Last-Update: 2013-09-14 | ||
8 | |||
9 | Patch-Name: ssh1-keepalive.patch | ||
10 | --- | ||
11 | clientloop.c | 25 +++++++++++++++---------- | ||
12 | ssh_config.5 | 5 ++++- | ||
13 | 2 files changed, 19 insertions(+), 11 deletions(-) | ||
14 | |||
15 | diff --git a/clientloop.c b/clientloop.c | ||
16 | index 77d5498..964353d 100644 | ||
17 | --- a/clientloop.c | ||
18 | +++ b/clientloop.c | ||
19 | @@ -577,16 +577,21 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt) | ||
20 | static void | ||
21 | server_alive_check(void) | ||
22 | { | ||
23 | - if (packet_inc_alive_timeouts() > options.server_alive_count_max) { | ||
24 | - logit("Timeout, server %s not responding.", host); | ||
25 | - cleanup_exit(255); | ||
26 | + if (compat20) { | ||
27 | + if (packet_inc_alive_timeouts() > options.server_alive_count_max) { | ||
28 | + logit("Timeout, server %s not responding.", host); | ||
29 | + cleanup_exit(255); | ||
30 | + } | ||
31 | + packet_start(SSH2_MSG_GLOBAL_REQUEST); | ||
32 | + packet_put_cstring("keepalive@openssh.com"); | ||
33 | + packet_put_char(1); /* boolean: want reply */ | ||
34 | + packet_send(); | ||
35 | + /* Insert an empty placeholder to maintain ordering */ | ||
36 | + client_register_global_confirm(NULL, NULL); | ||
37 | + } else { | ||
38 | + packet_send_ignore(0); | ||
39 | + packet_send(); | ||
40 | } | ||
41 | - packet_start(SSH2_MSG_GLOBAL_REQUEST); | ||
42 | - packet_put_cstring("keepalive@openssh.com"); | ||
43 | - packet_put_char(1); /* boolean: want reply */ | ||
44 | - packet_send(); | ||
45 | - /* Insert an empty placeholder to maintain ordering */ | ||
46 | - client_register_global_confirm(NULL, NULL); | ||
47 | } | ||
48 | |||
49 | /* | ||
50 | @@ -648,7 +653,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, | ||
51 | */ | ||
52 | |||
53 | timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */ | ||
54 | - if (options.server_alive_interval > 0 && compat20) { | ||
55 | + if (options.server_alive_interval > 0) { | ||
56 | timeout_secs = options.server_alive_interval; | ||
57 | server_alive_time = now + options.server_alive_interval; | ||
58 | } | ||
59 | diff --git a/ssh_config.5 b/ssh_config.5 | ||
60 | index b840261..f7510b6 100644 | ||
61 | --- a/ssh_config.5 | ||
62 | +++ b/ssh_config.5 | ||
63 | @@ -1414,7 +1414,10 @@ If, for example, | ||
64 | .Cm ServerAliveCountMax | ||
65 | is left at the default, if the server becomes unresponsive, | ||
66 | ssh will disconnect after approximately 45 seconds. | ||
67 | -This option applies to protocol version 2 only. | ||
68 | +This option applies to protocol version 2 only; in protocol version | ||
69 | +1 there is no mechanism to request a response from the server to the | ||
70 | +server alive messages, so disconnection is the responsibility of the TCP | ||
71 | +stack. | ||
72 | .It Cm ServerAliveInterval | ||
73 | Sets a timeout interval in seconds after which if no data has been received | ||
74 | from the server, | ||
diff --git a/debian/patches/syslog-level-silent.patch b/debian/patches/syslog-level-silent.patch new file mode 100644 index 000000000..e829e50fd --- /dev/null +++ b/debian/patches/syslog-level-silent.patch | |||
@@ -0,0 +1,47 @@ | |||
1 | From 9e6bb8525886d99876eb43a3b39c96bdf3032146 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 32e1d2e..53e7b65 100644 | ||
25 | --- a/log.c | ||
26 | +++ b/log.c | ||
27 | @@ -94,6 +94,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 3fd5a94..d99f7ef 100644 | ||
37 | --- a/ssh.c | ||
38 | +++ b/ssh.c | ||
39 | @@ -1105,7 +1105,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/user-group-modes.patch b/debian/patches/user-group-modes.patch new file mode 100644 index 000000000..9213c1f29 --- /dev/null +++ b/debian/patches/user-group-modes.patch | |||
@@ -0,0 +1,266 @@ | |||
1 | From 209c51110996719eab04236d72f776eed6bd8226 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: 2013-09-14 | ||
17 | |||
18 | Patch-Name: user-group-modes.patch | ||
19 | --- | ||
20 | auth-rhosts.c | 6 ++---- | ||
21 | auth.c | 9 +++----- | ||
22 | misc.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- | ||
23 | misc.h | 2 ++ | ||
24 | platform.c | 16 -------------- | ||
25 | readconf.c | 5 +++-- | ||
26 | ssh.1 | 2 ++ | ||
27 | ssh_config.5 | 2 ++ | ||
28 | 8 files changed, 82 insertions(+), 29 deletions(-) | ||
29 | |||
30 | diff --git a/auth-rhosts.c b/auth-rhosts.c | ||
31 | index ee9e827..2ff2cff 100644 | ||
32 | --- a/auth-rhosts.c | ||
33 | +++ b/auth-rhosts.c | ||
34 | @@ -271,8 +271,7 @@ auth_rhosts2_raw(struct passwd *pw, const char *client_user, const char *hostnam | ||
35 | return 0; | ||
36 | } | ||
37 | if (options.strict_modes && | ||
38 | - ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || | ||
39 | - (st.st_mode & 022) != 0)) { | ||
40 | + !secure_permissions(&st, pw->pw_uid)) { | ||
41 | logit("Rhosts authentication refused for %.100s: " | ||
42 | "bad ownership or modes for home directory.", pw->pw_name); | ||
43 | auth_debug_add("Rhosts authentication refused for %.100s: " | ||
44 | @@ -298,8 +297,7 @@ auth_rhosts2_raw(struct passwd *pw, const char *client_user, const char *hostnam | ||
45 | * allowing access to their account by anyone. | ||
46 | */ | ||
47 | if (options.strict_modes && | ||
48 | - ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || | ||
49 | - (st.st_mode & 022) != 0)) { | ||
50 | + !secure_permissions(&st, pw->pw_uid)) { | ||
51 | logit("Rhosts authentication refused for %.100s: bad modes for %.200s", | ||
52 | pw->pw_name, buf); | ||
53 | auth_debug_add("Bad file modes for %.200s", buf); | ||
54 | diff --git a/auth.c b/auth.c | ||
55 | index e6c094d..a99c475 100644 | ||
56 | --- a/auth.c | ||
57 | +++ b/auth.c | ||
58 | @@ -422,8 +422,7 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host, | ||
59 | user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); | ||
60 | if (options.strict_modes && | ||
61 | (stat(user_hostfile, &st) == 0) && | ||
62 | - ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || | ||
63 | - (st.st_mode & 022) != 0)) { | ||
64 | + !secure_permissions(&st, pw->pw_uid)) { | ||
65 | logit("Authentication refused for %.100s: " | ||
66 | "bad owner or modes for %.200s", | ||
67 | pw->pw_name, user_hostfile); | ||
68 | @@ -485,8 +484,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir, | ||
69 | snprintf(err, errlen, "%s is not a regular file", buf); | ||
70 | return -1; | ||
71 | } | ||
72 | - if ((!platform_sys_dir_uid(stp->st_uid) && stp->st_uid != uid) || | ||
73 | - (stp->st_mode & 022) != 0) { | ||
74 | + if (!secure_permissions(stp, uid)) { | ||
75 | snprintf(err, errlen, "bad ownership or modes for file %s", | ||
76 | buf); | ||
77 | return -1; | ||
78 | @@ -501,8 +499,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir, | ||
79 | strlcpy(buf, cp, sizeof(buf)); | ||
80 | |||
81 | if (stat(buf, &st) < 0 || | ||
82 | - (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) || | ||
83 | - (st.st_mode & 022) != 0) { | ||
84 | + !secure_permissions(&st, uid)) { | ||
85 | snprintf(err, errlen, | ||
86 | "bad ownership or modes for directory %s", buf); | ||
87 | return -1; | ||
88 | diff --git a/misc.c b/misc.c | ||
89 | index ddd2b2d..1c063ea 100644 | ||
90 | --- a/misc.c | ||
91 | +++ b/misc.c | ||
92 | @@ -50,8 +50,9 @@ | ||
93 | #include <netdb.h> | ||
94 | #ifdef HAVE_PATHS_H | ||
95 | # include <paths.h> | ||
96 | -#include <pwd.h> | ||
97 | #endif | ||
98 | +#include <pwd.h> | ||
99 | +#include <grp.h> | ||
100 | #ifdef SSH_TUN_OPENBSD | ||
101 | #include <net/if.h> | ||
102 | #endif | ||
103 | @@ -60,6 +61,7 @@ | ||
104 | #include "misc.h" | ||
105 | #include "log.h" | ||
106 | #include "ssh.h" | ||
107 | +#include "platform.h" | ||
108 | |||
109 | /* remove newline at end of string */ | ||
110 | char * | ||
111 | @@ -644,6 +646,71 @@ read_keyfile_line(FILE *f, const char *filename, char *buf, size_t bufsz, | ||
112 | return -1; | ||
113 | } | ||
114 | |||
115 | +/* | ||
116 | + * return 1 if the specified uid is a uid that may own a system directory | ||
117 | + * otherwise 0. | ||
118 | + */ | ||
119 | +int | ||
120 | +platform_sys_dir_uid(uid_t uid) | ||
121 | +{ | ||
122 | + if (uid == 0) | ||
123 | + return 1; | ||
124 | +#ifdef PLATFORM_SYS_DIR_UID | ||
125 | + if (uid == PLATFORM_SYS_DIR_UID) | ||
126 | + return 1; | ||
127 | +#endif | ||
128 | + return 0; | ||
129 | +} | ||
130 | + | ||
131 | +int | ||
132 | +secure_permissions(struct stat *st, uid_t uid) | ||
133 | +{ | ||
134 | + if (!platform_sys_dir_uid(st->st_uid) && st->st_uid != uid) | ||
135 | + return 0; | ||
136 | + if ((st->st_mode & 002) != 0) | ||
137 | + return 0; | ||
138 | + if ((st->st_mode & 020) != 0) { | ||
139 | + /* If the file is group-writable, the group in question must | ||
140 | + * have exactly one member, namely the file's owner. | ||
141 | + * (Zero-member groups are typically used by setgid | ||
142 | + * binaries, and are unlikely to be suitable.) | ||
143 | + */ | ||
144 | + struct passwd *pw; | ||
145 | + struct group *gr; | ||
146 | + int members = 0; | ||
147 | + | ||
148 | + gr = getgrgid(st->st_gid); | ||
149 | + if (!gr) | ||
150 | + return 0; | ||
151 | + | ||
152 | + /* Check primary group memberships. */ | ||
153 | + while ((pw = getpwent()) != NULL) { | ||
154 | + if (pw->pw_gid == gr->gr_gid) { | ||
155 | + ++members; | ||
156 | + if (pw->pw_uid != uid) | ||
157 | + return 0; | ||
158 | + } | ||
159 | + } | ||
160 | + endpwent(); | ||
161 | + | ||
162 | + pw = getpwuid(st->st_uid); | ||
163 | + if (!pw) | ||
164 | + return 0; | ||
165 | + | ||
166 | + /* Check supplementary group memberships. */ | ||
167 | + if (gr->gr_mem[0]) { | ||
168 | + ++members; | ||
169 | + if (strcmp(pw->pw_name, gr->gr_mem[0]) || | ||
170 | + gr->gr_mem[1]) | ||
171 | + return 0; | ||
172 | + } | ||
173 | + | ||
174 | + if (!members) | ||
175 | + return 0; | ||
176 | + } | ||
177 | + return 1; | ||
178 | +} | ||
179 | + | ||
180 | int | ||
181 | tun_open(int tun, int mode) | ||
182 | { | ||
183 | diff --git a/misc.h b/misc.h | ||
184 | index 374c33c..89e1f75 100644 | ||
185 | --- a/misc.h | ||
186 | +++ b/misc.h | ||
187 | @@ -135,4 +135,6 @@ char *read_passphrase(const char *, int); | ||
188 | int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2))); | ||
189 | int read_keyfile_line(FILE *, const char *, char *, size_t, u_long *); | ||
190 | |||
191 | +int secure_permissions(struct stat *st, uid_t uid); | ||
192 | + | ||
193 | #endif /* _MISC_H */ | ||
194 | diff --git a/platform.c b/platform.c | ||
195 | index f35ec39..9a23e6e 100644 | ||
196 | --- a/platform.c | ||
197 | +++ b/platform.c | ||
198 | @@ -197,19 +197,3 @@ platform_krb5_get_principal_name(const char *pw_name) | ||
199 | return NULL; | ||
200 | #endif | ||
201 | } | ||
202 | - | ||
203 | -/* | ||
204 | - * return 1 if the specified uid is a uid that may own a system directory | ||
205 | - * otherwise 0. | ||
206 | - */ | ||
207 | -int | ||
208 | -platform_sys_dir_uid(uid_t uid) | ||
209 | -{ | ||
210 | - if (uid == 0) | ||
211 | - return 1; | ||
212 | -#ifdef PLATFORM_SYS_DIR_UID | ||
213 | - if (uid == PLATFORM_SYS_DIR_UID) | ||
214 | - return 1; | ||
215 | -#endif | ||
216 | - return 0; | ||
217 | -} | ||
218 | diff --git a/readconf.c b/readconf.c | ||
219 | index 5c5890c..5f6c37f 100644 | ||
220 | --- a/readconf.c | ||
221 | +++ b/readconf.c | ||
222 | @@ -39,6 +39,8 @@ | ||
223 | #include <stdio.h> | ||
224 | #include <string.h> | ||
225 | #include <unistd.h> | ||
226 | +#include <pwd.h> | ||
227 | +#include <grp.h> | ||
228 | #ifdef HAVE_UTIL_H | ||
229 | #include <util.h> | ||
230 | #endif | ||
231 | @@ -1579,8 +1581,7 @@ read_config_file(const char *filename, struct passwd *pw, const char *host, | ||
232 | |||
233 | if (fstat(fileno(f), &sb) == -1) | ||
234 | fatal("fstat %s: %s", filename, strerror(errno)); | ||
235 | - if (((sb.st_uid != 0 && sb.st_uid != getuid()) || | ||
236 | - (sb.st_mode & 022) != 0)) | ||
237 | + if (!secure_permissions(&sb, getuid())) | ||
238 | fatal("Bad owner or permissions on %s", filename); | ||
239 | } | ||
240 | |||
241 | diff --git a/ssh.1 b/ssh.1 | ||
242 | index df7ac86..c84196f 100644 | ||
243 | --- a/ssh.1 | ||
244 | +++ b/ssh.1 | ||
245 | @@ -1371,6 +1371,8 @@ The file format and configuration options are described in | ||
246 | .Xr ssh_config 5 . | ||
247 | Because of the potential for abuse, this file must have strict permissions: | ||
248 | read/write for the user, and not writable by others. | ||
249 | +It may be group-writable provided that the group in question contains only | ||
250 | +the user. | ||
251 | .Pp | ||
252 | .It Pa ~/.ssh/environment | ||
253 | Contains additional definitions for environment variables; see | ||
254 | diff --git a/ssh_config.5 b/ssh_config.5 | ||
255 | index 21d3e94..1d0c52b 100644 | ||
256 | --- a/ssh_config.5 | ||
257 | +++ b/ssh_config.5 | ||
258 | @@ -1706,6 +1706,8 @@ The format of this file is described above. | ||
259 | This file is used by the SSH client. | ||
260 | Because of the potential for abuse, this file must have strict permissions: | ||
261 | read/write for the user, and not accessible by others. | ||
262 | +It may be group-writable provided that the group in question contains only | ||
263 | +the user. | ||
264 | .It Pa /etc/ssh/ssh_config | ||
265 | Systemwide configuration file. | ||
266 | This file provides defaults for those | ||