Mail archive
alpine-aports

[alpine-aports] [PATCH] testing/slock: use safer OOM killer disablement upstream patch

From: Sören Tempel <soeren+git_at_soeren-tempel.net>
Date: Fri, 14 Aug 2015 08:49:56 +0200

---
 testing/slock/APKBUILD                           | 16 ++++++++-----
 testing/slock/safer-oom-killer-disablement.patch | 30 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 6 deletions(-)
 create mode 100644 testing/slock/safer-oom-killer-disablement.patch
diff --git a/testing/slock/APKBUILD b/testing/slock/APKBUILD
index 16a86ee..c05f619 100644
--- a/testing/slock/APKBUILD
+++ b/testing/slock/APKBUILD
_at_@ -2,16 +2,17 @@
 # Maintainer: Sören Tempel <soeren+alpine_at_soeren-tempel.net>
 pkgname=slock
 pkgver=1.2
-pkgrel=0
+pkgrel=1
 pkgdesc="A simple screen locker for X"
 url="http://tools.suckless.org/slock/"
 arch="all"
 license="MIT"
 depends=""
 depends_dev="libxext-dev"
-makedepends="$depends_dev"
+makedepends="$depends_dev linux-headers"
 install=""
-source="http://git.suckless.org/$pkgname/snapshot/$pkgname-$pkgver.tar.gz"
+source="http://dl.suckless.org/tools/$pkgname-$pkgver.tar.gz
+	safer-oom-killer-disablement.patch"
 options="suid"
 
 _builddir="$srcdir/$pkgname-$pkgver"
_at_@ -36,6 +37,9 @@ package() {
 		-C "$_builddir" install
 }
 
-md5sums="8c260816e20298e7d08f59e96b740465  slock-1.2.tar.gz"
-sha256sums="0229b2440970cd32bb626c583283646a6adf2684a18ba91d2e72a08b9075d7f4  slock-1.2.tar.gz"
-sha512sums="8b403da254cf9802de760fcd39a3c848c4d6b0022f0200efd6210ed14b6d65a2978a4a9c89c661f4a386a17e5d871c531278e4240a3af0a2e42c0ffc95d0ad10  slock-1.2.tar.gz"
+md5sums="ee65f6e9f5ce71f3a6088d53b2485430  slock-1.2.tar.gz
+5ce27461215d35614b7c7697ae827e1f  safer-oom-killer-disablement.patch"
+sha256sums="3402658f890a88da3f34db04fca1783ed549ade45c2ebb8d8f0cd2b549f633b3  slock-1.2.tar.gz
+65eee712e2f07d9d5b6b241a703a9340d2456579ed253a73bf354ba37d2e900a  safer-oom-killer-disablement.patch"
+sha512sums="0e66c5451c72a5df391a61eefa6b1a1493705fc9c0b04d9db934a56c11852c284ecca8706f47ceb1d1c8cfc5241c818c6026afb30fc9cf3938e44ea282338bee  slock-1.2.tar.gz
+60583375fcfeff3d5d16a39f0fc010a57e251988e58fef47c9a65f062cebaab7fa9f2e9c3ce019d9918398ee86448fdc8dcf15bc25a8cbda830f686b5f3840f1  safer-oom-killer-disablement.patch"
diff --git a/testing/slock/safer-oom-killer-disablement.patch b/testing/slock/safer-oom-killer-disablement.patch
new file mode 100644
index 0000000..276e7d5
--- /dev/null
+++ b/testing/slock/safer-oom-killer-disablement.patch
_at_@ -0,0 +1,30 @@
+--- slock-1.2.orig/slock.c
++++ slock-1.2/slock.c
+_at_@ -48,15 +48,26 @@
+ 
+ #ifdef __linux__
+ #include <fcntl.h>
++#include <linux/oom.h>
+ 
+ static void
+ dontkillme(void) {
+ 	int fd;
++	int length;
++	char value[64];
+ 
+ 	fd = open("/proc/self/oom_score_adj", O_WRONLY);
+ 	if (fd < 0 && errno == ENOENT)
+ 		return;
+-	if (fd < 0 || write(fd, "-1000\n", 6) != 6 || close(fd) != 0)
++
++	/* convert OOM_SCORE_ADJ_MIN to string for writing */
++	length = snprintf(value, sizeof(value), "%d\n", OOM_SCORE_ADJ_MIN);
++
++	/* bail on truncation */
++	if (length >= sizeof(value))
++		die("buffer too small\n");
++
++	if (fd < 0 || write(fd, value, length) != length || close(fd) != 0)
+ 		die("cannot disable the out-of-memory killer for this process\n");
+ }
+ #endif
-- 
2.5.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Fri Aug 14 2015 - 08:49:56 GMT