diff options
author | Colin Watson <cjwatson@debian.org> | 2007-06-12 16:16:35 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2007-06-12 16:16:35 +0000 |
commit | b7e40fa9da0b5491534a429dadb321eab5a77558 (patch) | |
tree | bed1da11e9f829925797aa093e379fc0b5868ecd /openbsd-compat/port-linux.c | |
parent | 4f84beedf1005e44ff33c854abd6b711ffc0adb7 (diff) | |
parent | 086ea76990b1e6287c24b6db74adffd4605eb3b0 (diff) |
* New upstream release (closes: #395507, #397961, #420035). Important
changes not previously backported to 4.3p2:
- 4.4/4.4p1 (http://www.openssh.org/txt/release-4.4):
+ On portable OpenSSH, fix a GSSAPI authentication abort that could be
used to determine the validity of usernames on some platforms.
+ Implemented conditional configuration in sshd_config(5) using the
"Match" directive. This allows some configuration options to be
selectively overridden if specific criteria (based on user, group,
hostname and/or address) are met. So far a useful subset of
post-authentication options are supported and more are expected to
be added in future releases.
+ Add support for Diffie-Hellman group exchange key agreement with a
final hash of SHA256.
+ Added a "ForceCommand" directive to sshd_config(5). Similar to the
command="..." option accepted in ~/.ssh/authorized_keys, this forces
the execution of the specified command regardless of what the user
requested. This is very useful in conjunction with the new "Match"
option.
+ Add a "PermitOpen" directive to sshd_config(5). This mirrors the
permitopen="..." authorized_keys option, allowing fine-grained
control over the port-forwardings that a user is allowed to
establish.
+ Add optional logging of transactions to sftp-server(8).
+ ssh(1) will now record port numbers for hosts stored in
~/.ssh/known_hosts when a non-standard port has been requested
(closes: #50612).
+ Add an "ExitOnForwardFailure" option to cause ssh(1) to exit (with a
non-zero exit code) when requested port forwardings could not be
established.
+ Extend sshd_config(5) "SubSystem" declarations to allow the
specification of command-line arguments.
+ Replacement of all integer overflow susceptible invocations of
malloc(3) and realloc(3) with overflow-checking equivalents.
+ Many manpage fixes and improvements.
+ Add optional support for OpenSSL hardware accelerators (engines),
enabled using the --with-ssl-engine configure option.
+ Tokens in configuration files may be double-quoted in order to
contain spaces (closes: #319639).
+ Move a debug() call out of a SIGCHLD handler, fixing a hang when the
session exits very quickly (closes: #307890).
+ Fix some incorrect buffer allocation calculations (closes: #410599).
+ ssh-add doesn't ask for a passphrase if key file permissions are too
liberal (closes: #103677).
+ Likewise, ssh doesn't ask either (closes: #99675).
- 4.6/4.6p1 (http://www.openssh.org/txt/release-4.6):
+ sshd now allows the enabling and disabling of authentication methods
on a per user, group, host and network basis via the Match directive
in sshd_config.
+ Fixed an inconsistent check for a terminal when displaying scp
progress meter (closes: #257524).
+ Fix "hang on exit" when background processes are running at the time
of exit on a ttyful/login session (closes: #88337).
* Update to current GSSAPI patch from
http://www.sxw.org.uk/computing/patches/openssh-4.6p1-gsskex-20070312.patch;
install ChangeLog.gssapi.
Diffstat (limited to 'openbsd-compat/port-linux.c')
-rw-r--r-- | openbsd-compat/port-linux.c | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c new file mode 100644 index 000000000..d153f8fb5 --- /dev/null +++ b/openbsd-compat/port-linux.c | |||
@@ -0,0 +1,178 @@ | |||
1 | /* $Id: port-linux.c,v 1.3 2006/09/01 05:38:41 djm Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com> | ||
5 | * Copyright (c) 2006 Damien Miller <djm@openbsd.org> | ||
6 | * | ||
7 | * Permission to use, copy, modify, and distribute this software for any | ||
8 | * purpose with or without fee is hereby granted, provided that the above | ||
9 | * copyright notice and this permission notice appear in all copies. | ||
10 | * | ||
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
18 | */ | ||
19 | |||
20 | /* | ||
21 | * Linux-specific portability code - just SELinux support at present | ||
22 | */ | ||
23 | |||
24 | #include "includes.h" | ||
25 | |||
26 | #include <errno.h> | ||
27 | #include <stdarg.h> | ||
28 | #include <string.h> | ||
29 | |||
30 | #ifdef WITH_SELINUX | ||
31 | #include "log.h" | ||
32 | #include "port-linux.h" | ||
33 | |||
34 | #include <selinux/selinux.h> | ||
35 | #include <selinux/flask.h> | ||
36 | #include <selinux/get_context_list.h> | ||
37 | |||
38 | /* Wrapper around is_selinux_enabled() to log its return value once only */ | ||
39 | static int | ||
40 | ssh_selinux_enabled(void) | ||
41 | { | ||
42 | static int enabled = -1; | ||
43 | |||
44 | if (enabled == -1) { | ||
45 | enabled = is_selinux_enabled(); | ||
46 | debug("SELinux support %s", enabled ? "enabled" : "disabled"); | ||
47 | } | ||
48 | |||
49 | return (enabled); | ||
50 | } | ||
51 | |||
52 | /* Return the default security context for the given username */ | ||
53 | static security_context_t | ||
54 | ssh_selinux_getctxbyname(char *pwname) | ||
55 | { | ||
56 | security_context_t sc; | ||
57 | char *sename = NULL, *role = NULL, *lvl = NULL; | ||
58 | int r; | ||
59 | |||
60 | #ifdef HAVE_GETSEUSERBYNAME | ||
61 | if (getseuserbyname(pwname, &sename, &lvl) != 0) | ||
62 | return NULL; | ||
63 | #else | ||
64 | sename = pwname; | ||
65 | lvl = NULL; | ||
66 | #endif | ||
67 | if (the_authctxt) | ||
68 | role = the_authctxt->role; | ||
69 | |||
70 | #ifdef HAVE_GET_DEFAULT_CONTEXT_WITH_LEVEL | ||
71 | if (role != NULL && role[0]) | ||
72 | r = get_default_context_with_rolelevel(sename, role, lvl, NULL, | ||
73 | &sc); | ||
74 | else | ||
75 | r = get_default_context_with_level(sename, lvl, NULL, &sc); | ||
76 | #else | ||
77 | if (role != NULL && role[0]) | ||
78 | r = get_default_context_with_role(sename, role, NULL, &sc); | ||
79 | else | ||
80 | r = get_default_context(sename, NULL, &sc); | ||
81 | #endif | ||
82 | |||
83 | if (r != 0) { | ||
84 | switch (security_getenforce()) { | ||
85 | case -1: | ||
86 | fatal("%s: ssh_selinux_getctxbyname: " | ||
87 | "security_getenforce() failed", __func__); | ||
88 | case 0: | ||
89 | error("%s: Failed to get default SELinux security " | ||
90 | "context for %s", __func__, pwname); | ||
91 | default: | ||
92 | fatal("%s: Failed to get default SELinux security " | ||
93 | "context for %s (in enforcing mode)", | ||
94 | __func__, pwname); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | #ifdef HAVE_GETSEUSERBYNAME | ||
99 | if (sename != NULL) | ||
100 | xfree(sename); | ||
101 | if (lvl != NULL) | ||
102 | xfree(lvl); | ||
103 | #endif | ||
104 | |||
105 | return (sc); | ||
106 | } | ||
107 | |||
108 | /* Set the execution context to the default for the specified user */ | ||
109 | void | ||
110 | ssh_selinux_setup_exec_context(char *pwname) | ||
111 | { | ||
112 | security_context_t user_ctx = NULL; | ||
113 | |||
114 | if (!ssh_selinux_enabled()) | ||
115 | return; | ||
116 | |||
117 | debug3("%s: setting execution context", __func__); | ||
118 | |||
119 | user_ctx = ssh_selinux_getctxbyname(pwname); | ||
120 | if (setexeccon(user_ctx) != 0) { | ||
121 | switch (security_getenforce()) { | ||
122 | case -1: | ||
123 | fatal("%s: security_getenforce() failed", __func__); | ||
124 | case 0: | ||
125 | error("%s: Failed to set SELinux execution " | ||
126 | "context for %s", __func__, pwname); | ||
127 | default: | ||
128 | fatal("%s: Failed to set SELinux execution context " | ||
129 | "for %s (in enforcing mode)", __func__, pwname); | ||
130 | } | ||
131 | } | ||
132 | if (user_ctx != NULL) | ||
133 | freecon(user_ctx); | ||
134 | |||
135 | debug3("%s: done", __func__); | ||
136 | } | ||
137 | |||
138 | /* Set the TTY context for the specified user */ | ||
139 | void | ||
140 | ssh_selinux_setup_pty(char *pwname, const char *tty) | ||
141 | { | ||
142 | security_context_t new_tty_ctx = NULL; | ||
143 | security_context_t user_ctx = NULL; | ||
144 | security_context_t old_tty_ctx = NULL; | ||
145 | |||
146 | if (!ssh_selinux_enabled()) | ||
147 | return; | ||
148 | |||
149 | debug3("%s: setting TTY context on %s", __func__, tty); | ||
150 | |||
151 | user_ctx = ssh_selinux_getctxbyname(pwname); | ||
152 | |||
153 | /* XXX: should these calls fatal() upon failure in enforcing mode? */ | ||
154 | |||
155 | if (getfilecon(tty, &old_tty_ctx) == -1) { | ||
156 | error("%s: getfilecon: %s", __func__, strerror(errno)); | ||
157 | goto out; | ||
158 | } | ||
159 | |||
160 | if (security_compute_relabel(user_ctx, old_tty_ctx, | ||
161 | SECCLASS_CHR_FILE, &new_tty_ctx) != 0) { | ||
162 | error("%s: security_compute_relabel: %s", | ||
163 | __func__, strerror(errno)); | ||
164 | goto out; | ||
165 | } | ||
166 | |||
167 | if (setfilecon(tty, new_tty_ctx) != 0) | ||
168 | error("%s: setfilecon: %s", __func__, strerror(errno)); | ||
169 | out: | ||
170 | if (new_tty_ctx != NULL) | ||
171 | freecon(new_tty_ctx); | ||
172 | if (old_tty_ctx != NULL) | ||
173 | freecon(old_tty_ctx); | ||
174 | if (user_ctx != NULL) | ||
175 | freecon(user_ctx); | ||
176 | debug3("%s: done", __func__); | ||
177 | } | ||
178 | #endif /* WITH_SELINUX */ | ||