From 17c1bf6665a5134932295fee184599bdf568765db2c00cc371b4ca6c60e2a9d0 Mon Sep 17 00:00:00 2001 From: Ruediger Oertel Date: Thu, 18 Nov 2010 16:45:04 +0000 Subject: [PATCH] Accepting request 53215 from Base:System Accepted submit request 53215 from user dirkmueller OBS-URL: https://build.opensuse.org/request/show/53215 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/openssh?expand=0&rev=56 --- openssh-deprecated-oom_adj.patch | 17 ------ openssh-linux-new-oomkill.patch | 94 ++++++++++++++++++++++++++++++++ openssh.changes | 5 ++ openssh.spec | 2 +- 4 files changed, 100 insertions(+), 18 deletions(-) delete mode 100644 openssh-deprecated-oom_adj.patch create mode 100644 openssh-linux-new-oomkill.patch diff --git a/openssh-deprecated-oom_adj.patch b/openssh-deprecated-oom_adj.patch deleted file mode 100644 index 051e1d3..0000000 --- a/openssh-deprecated-oom_adj.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- openbsd-compat/port-linux.c.orig -+++ openbsd-compat/port-linux.c -@@ -208,12 +208,12 @@ ssh_selinux_change_context(const char *n - #endif /* WITH_SELINUX */ - - #ifdef LINUX_OOM_ADJUST --#define OOM_ADJ_PATH "/proc/self/oom_adj" -+#define OOM_ADJ_PATH "/proc/self/oom_score_adj" - /* - * The magic "don't kill me", as documented in eg: - * http://lxr.linux.no/#linux+v2.6.32/Documentation/filesystems/proc.txt - */ --#define OOM_ADJ_NOKILL -17 -+#define OOM_ADJ_NOKILL -1000 - - static int oom_adj_save = INT_MIN; - diff --git a/openssh-linux-new-oomkill.patch b/openssh-linux-new-oomkill.patch new file mode 100644 index 0000000..fee09c3 --- /dev/null +++ b/openssh-linux-new-oomkill.patch @@ -0,0 +1,94 @@ +Index: openbsd-compat/port-linux.c +=================================================================== +RCS file: /home/dtucker/openssh/cvs/openssh/openbsd-compat/port-linux.c,v +retrieving revision 1.9 +diff -u -p -r1.9 port-linux.c +--- openbsd-compat/port-linux.c 10 Sep 2010 00:30:25 -0000 1.9 ++++ openbsd-compat/port-linux.c 16 Nov 2010 05:10:13 -0000 +@@ -208,14 +208,21 @@ ssh_selinux_change_context(const char *n + #endif /* WITH_SELINUX */ + + #ifdef LINUX_OOM_ADJUST +-#define OOM_ADJ_PATH "/proc/self/oom_adj" + /* +- * The magic "don't kill me", as documented in eg: ++ * The magic "don't kill me" values, old and new, as documented in eg: + * http://lxr.linux.no/#linux+v2.6.32/Documentation/filesystems/proc.txt ++ * http://lxr.linux.no/#linux+v2.6.36/Documentation/filesystems/proc.txt + */ +-#define OOM_ADJ_NOKILL -17 + + static int oom_adj_save = INT_MIN; ++static char *oom_adj_path = NULL; ++struct { ++ char *path; ++ int value; ++} oom_adjust[] = { ++ {"/proc/self/oom_score_adj", -1000}, /* new values, 2.6.36 and up */ ++ {"/proc/self/oom_adj", -17}, /* old values, 2.6.35 and down */ ++}; + + /* + * Tell the kernel's out-of-memory killer to avoid sshd. +@@ -224,23 +231,31 @@ static int oom_adj_save = INT_MIN; + void + oom_adjust_setup(void) + { ++ int i, value; + FILE *fp; + + debug3("%s", __func__); +- if ((fp = fopen(OOM_ADJ_PATH, "r+")) != NULL) { +- if (fscanf(fp, "%d", &oom_adj_save) != 1) +- verbose("error reading %s: %s", OOM_ADJ_PATH, strerror(errno)); +- else { +- rewind(fp); +- if (fprintf(fp, "%d\n", OOM_ADJ_NOKILL) <= 0) +- verbose("error writing %s: %s", +- OOM_ADJ_PATH, strerror(errno)); +- else +- verbose("Set %s from %d to %d", +- OOM_ADJ_PATH, oom_adj_save, OOM_ADJ_NOKILL); ++ for (i = 0; i < 2; i++) { ++ oom_adj_path = oom_adjust[i].path; ++ value = oom_adjust[i].value; ++ if ((fp = fopen(oom_adj_path, "r+")) != NULL) { ++ if (fscanf(fp, "%d", &oom_adj_save) != 1) ++ verbose("error reading %s: %s", oom_adj_path, ++ strerror(errno)); ++ else { ++ rewind(fp); ++ if (fprintf(fp, "%d\n", value) <= 0) ++ verbose("error writing %s: %s", ++ oom_adj_path, strerror(errno)); ++ else ++ verbose("Set %s from %d to %d", ++ oom_adj_path, oom_adj_save, value); ++ } ++ fclose(fp); ++ return; + } +- fclose(fp); + } ++ oom_adj_path = NULL; + } + + /* Restore the saved OOM adjustment */ +@@ -250,13 +265,14 @@ oom_adjust_restore(void) + FILE *fp; + + debug3("%s", __func__); +- if (oom_adj_save == INT_MIN || (fp = fopen(OOM_ADJ_PATH, "w")) == NULL) ++ if (oom_adj_save == INT_MIN || oom_adj_save == NULL || ++ (fp = fopen(oom_adj_path, "w")) == NULL) + return; + + if (fprintf(fp, "%d\n", oom_adj_save) <= 0) +- verbose("error writing %s: %s", OOM_ADJ_PATH, strerror(errno)); ++ verbose("error writing %s: %s", oom_adj_path, strerror(errno)); + else +- verbose("Set %s to %d", OOM_ADJ_PATH, oom_adj_save); ++ verbose("Set %s to %d", oom_adj_path, oom_adj_save); + + fclose(fp); + return; diff --git a/openssh.changes b/openssh.changes index 0dc6971..6504eea 100644 --- a/openssh.changes +++ b/openssh.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Nov 16 14:45:14 UTC 2010 - cristian.rodriguez@opensuse.org + +- Use upstream oom_adj is deprecated patch + ------------------------------------------------------------------- Tue Nov 2 13:25:19 UTC 2010 - coolo@novell.com diff --git a/openssh.spec b/openssh.spec index 5bc0da5..88e0868 100644 --- a/openssh.spec +++ b/openssh.spec @@ -63,7 +63,7 @@ Patch16: %{name}-%{version}-pts.diff Patch17: %{name}-%{version}-homechroot.patch Patch18: %{name}-%{version}-sshconfig-knownhostschanges.diff Patch19: %{name}-%{version}-host_ident.diff -Patch20: openssh-deprecated-oom_adj.patch +Patch20: openssh-linux-new-oomkill.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %package askpass