summaryrefslogtreecommitdiff
path: root/openbsd-compat/port-linux.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2011-01-24 12:43:25 +0000
committerColin Watson <cjwatson@debian.org>2011-01-24 12:43:25 +0000
commit626f1d986ff72aa514da63e34744e1de9cf21b9a (patch)
treed215a5280bc2e57251e4a9e08bfd3674ad824a94 /openbsd-compat/port-linux.c
parent6ed622cb6fe8f71bbe0d998cdd12280410bfb420 (diff)
parent0970072c89b079b022538e3c366fbfa2c53fc821 (diff)
* New upstream release (http://www.openssh.org/txt/release-5.7):
- Implement Elliptic Curve Cryptography modes for key exchange (ECDH) and host/user keys (ECDSA) as specified by RFC5656. ECDH and ECDSA offer better performance than plain DH and DSA at the same equivalent symmetric key length, as well as much shorter keys. - sftp(1)/sftp-server(8): add a protocol extension to support a hard link operation. It is available through the "ln" command in the client. The old "ln" behaviour of creating a symlink is available using its "-s" option or through the preexisting "symlink" command. - scp(1): Add a new -3 option to scp: Copies between two remote hosts are transferred through the local host (closes: #508613). - ssh(1): "atomically" create the listening mux socket by binding it on a temporary name and then linking it into position after listen() has succeeded. This allows the mux clients to determine that the server socket is either ready or stale without races (closes: #454784). Stale server sockets are now automatically removed (closes: #523250). - ssh(1): install a SIGCHLD handler to reap expired child process (closes: #594687). - ssh(1)/ssh-agent(1): honour $TMPDIR for client xauth and ssh-agent temporary directories (closes: #357469, although only if you arrange for ssh-agent to actually see $TMPDIR since the setgid bit will cause it to be stripped off).
Diffstat (limited to 'openbsd-compat/port-linux.c')
-rw-r--r--openbsd-compat/port-linux.c57
1 files changed, 37 insertions, 20 deletions
diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c
index c0ac9065e..86a7146a6 100644
--- a/openbsd-compat/port-linux.c
+++ b/openbsd-compat/port-linux.c
@@ -1,4 +1,4 @@
1/* $Id: port-linux.c,v 1.8 2010/03/01 04:52:50 dtucker Exp $ */ 1/* $Id: port-linux.c,v 1.11 2011/01/17 07:50:24 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com> 4 * Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com>
@@ -53,7 +53,7 @@ ssh_selinux_enabled(void)
53 static int enabled = -1; 53 static int enabled = -1;
54 54
55 if (enabled == -1) { 55 if (enabled == -1) {
56 enabled = is_selinux_enabled(); 56 enabled = (is_selinux_enabled() == 1);
57 debug("SELinux support %s", enabled ? "enabled" : "disabled"); 57 debug("SELinux support %s", enabled ? "enabled" : "disabled");
58 } 58 }
59 59
@@ -225,14 +225,22 @@ ssh_selinux_change_context(const char *newname)
225#endif /* WITH_SELINUX */ 225#endif /* WITH_SELINUX */
226 226
227#ifdef LINUX_OOM_ADJUST 227#ifdef LINUX_OOM_ADJUST
228#define OOM_ADJ_PATH "/proc/self/oom_adj"
229/* 228/*
230 * The magic "don't kill me", as documented in eg: 229 * The magic "don't kill me" values, old and new, as documented in eg:
231 * http://lxr.linux.no/#linux+v2.6.32/Documentation/filesystems/proc.txt 230 * http://lxr.linux.no/#linux+v2.6.32/Documentation/filesystems/proc.txt
231 * http://lxr.linux.no/#linux+v2.6.36/Documentation/filesystems/proc.txt
232 */ 232 */
233#define OOM_ADJ_NOKILL -17
234 233
235static int oom_adj_save = INT_MIN; 234static int oom_adj_save = INT_MIN;
235static char *oom_adj_path = NULL;
236struct {
237 char *path;
238 int value;
239} oom_adjust[] = {
240 {"/proc/self/oom_score_adj", -1000}, /* kernels >= 2.6.36 */
241 {"/proc/self/oom_adj", -17}, /* kernels <= 2.6.35 */
242 {NULL, 0},
243};
236 244
237/* 245/*
238 * Tell the kernel's out-of-memory killer to avoid sshd. 246 * Tell the kernel's out-of-memory killer to avoid sshd.
@@ -241,23 +249,31 @@ static int oom_adj_save = INT_MIN;
241void 249void
242oom_adjust_setup(void) 250oom_adjust_setup(void)
243{ 251{
252 int i, value;
244 FILE *fp; 253 FILE *fp;
245 254
246 debug3("%s", __func__); 255 debug3("%s", __func__);
247 if ((fp = fopen(OOM_ADJ_PATH, "r+")) != NULL) { 256 for (i = 0; oom_adjust[i].path != NULL; i++) {
248 if (fscanf(fp, "%d", &oom_adj_save) != 1) 257 oom_adj_path = oom_adjust[i].path;
249 verbose("error reading %s: %s", OOM_ADJ_PATH, strerror(errno)); 258 value = oom_adjust[i].value;
250 else { 259 if ((fp = fopen(oom_adj_path, "r+")) != NULL) {
251 rewind(fp); 260 if (fscanf(fp, "%d", &oom_adj_save) != 1)
252 if (fprintf(fp, "%d\n", OOM_ADJ_NOKILL) <= 0) 261 verbose("error reading %s: %s", oom_adj_path,
253 verbose("error writing %s: %s", 262 strerror(errno));
254 OOM_ADJ_PATH, strerror(errno)); 263 else {
255 else 264 rewind(fp);
256 verbose("Set %s from %d to %d", 265 if (fprintf(fp, "%d\n", value) <= 0)
257 OOM_ADJ_PATH, oom_adj_save, OOM_ADJ_NOKILL); 266 verbose("error writing %s: %s",
267 oom_adj_path, strerror(errno));
268 else
269 verbose("Set %s from %d to %d",
270 oom_adj_path, oom_adj_save, value);
271 }
272 fclose(fp);
273 return;
258 } 274 }
259 fclose(fp);
260 } 275 }
276 oom_adj_path = NULL;
261} 277}
262 278
263/* Restore the saved OOM adjustment */ 279/* Restore the saved OOM adjustment */
@@ -267,13 +283,14 @@ oom_adjust_restore(void)
267 FILE *fp; 283 FILE *fp;
268 284
269 debug3("%s", __func__); 285 debug3("%s", __func__);
270 if (oom_adj_save == INT_MIN || (fp = fopen(OOM_ADJ_PATH, "w")) == NULL) 286 if (oom_adj_save == INT_MIN || oom_adj_path == NULL ||
287 (fp = fopen(oom_adj_path, "w")) == NULL)
271 return; 288 return;
272 289
273 if (fprintf(fp, "%d\n", oom_adj_save) <= 0) 290 if (fprintf(fp, "%d\n", oom_adj_save) <= 0)
274 verbose("error writing %s: %s", OOM_ADJ_PATH, strerror(errno)); 291 verbose("error writing %s: %s", oom_adj_path, strerror(errno));
275 else 292 else
276 verbose("Set %s to %d", OOM_ADJ_PATH, oom_adj_save); 293 verbose("Set %s to %d", oom_adj_path, oom_adj_save);
277 294
278 fclose(fp); 295 fclose(fp);
279 return; 296 return;