diff options
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | openbsd-compat/port-linux.c | 10 | ||||
-rw-r--r-- | openbsd-compat/port-linux.h | 1 |
3 files changed, 12 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog index 5609581f4..3f3d7a9c7 100644 --- a/debian/changelog +++ b/debian/changelog | |||
@@ -1,3 +1,10 @@ | |||
1 | openssh (1:5.1p1-6) UNRELEASED; urgency=low | ||
2 | |||
3 | * Open /proc/self/oom_adj with O_RDONLY or O_WRONLY as necessary, rather | ||
4 | than O_RDWR. | ||
5 | |||
6 | -- Colin Watson <cjwatson@debian.org> Wed, 14 Jan 2009 11:30:07 +0000 | ||
7 | |||
1 | openssh (1:5.1p1-5) unstable; urgency=low | 8 | openssh (1:5.1p1-5) unstable; urgency=low |
2 | 9 | ||
3 | * Backport from upstream CVS (Markus Friedl): | 10 | * Backport from upstream CVS (Markus Friedl): |
diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c index bc4924727..b7142ba90 100644 --- a/openbsd-compat/port-linux.c +++ b/openbsd-compat/port-linux.c | |||
@@ -197,10 +197,10 @@ ssh_selinux_setup_pty(char *pwname, const char *tty) | |||
197 | 197 | ||
198 | #ifdef OOM_ADJUST | 198 | #ifdef OOM_ADJUST |
199 | /* Get the out-of-memory adjustment file for the current process */ | 199 | /* Get the out-of-memory adjustment file for the current process */ |
200 | int | 200 | static int |
201 | oom_adj_open(void) | 201 | oom_adj_open(int oflag) |
202 | { | 202 | { |
203 | int fd = open("/proc/self/oom_adj", O_RDWR); | 203 | int fd = open("/proc/self/oom_adj", oflag); |
204 | if (fd < 0) | 204 | if (fd < 0) |
205 | logit("error opening /proc/self/oom_adj: %s", strerror(errno)); | 205 | logit("error opening /proc/self/oom_adj: %s", strerror(errno)); |
206 | return fd; | 206 | return fd; |
@@ -211,7 +211,7 @@ int | |||
211 | oom_adj_get(char *buf, size_t maxlen) | 211 | oom_adj_get(char *buf, size_t maxlen) |
212 | { | 212 | { |
213 | ssize_t n; | 213 | ssize_t n; |
214 | int fd = oom_adj_open(); | 214 | int fd = oom_adj_open(O_RDONLY); |
215 | if (fd < 0) | 215 | if (fd < 0) |
216 | return -1; | 216 | return -1; |
217 | n = read(fd, buf, maxlen); | 217 | n = read(fd, buf, maxlen); |
@@ -228,7 +228,7 @@ int | |||
228 | oom_adj_set(const char *buf) | 228 | oom_adj_set(const char *buf) |
229 | { | 229 | { |
230 | ssize_t n; | 230 | ssize_t n; |
231 | int fd = oom_adj_open(); | 231 | int fd = oom_adj_open(O_WRONLY); |
232 | if (fd < 0) | 232 | if (fd < 0) |
233 | return -1; | 233 | return -1; |
234 | n = write(fd, buf, strlen(buf)); | 234 | n = write(fd, buf, strlen(buf)); |
diff --git a/openbsd-compat/port-linux.h b/openbsd-compat/port-linux.h index 2a3271a93..6e6a8acfd 100644 --- a/openbsd-compat/port-linux.h +++ b/openbsd-compat/port-linux.h | |||
@@ -26,7 +26,6 @@ void ssh_selinux_setup_exec_context(char *); | |||
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #ifdef OOM_ADJUST | 28 | #ifdef OOM_ADJUST |
29 | int oom_adj_open(void); | ||
30 | int oom_adj_get(char *buf, size_t maxlen); | 29 | int oom_adj_get(char *buf, size_t maxlen); |
31 | int oom_adj_set(const char *buf); | 30 | int oom_adj_set(const char *buf); |
32 | #endif | 31 | #endif |