From f41a3bd7ad4ba9e803ab66c2cbbc87ece8a99df6 Mon Sep 17 00:00:00 2001
From: Rene Luria <rene.luria@infomaniak.com>
Date: Sun, 9 Dec 2018 21:51:54 +0100
Subject: [PATCH] Apply patch to fix pthread_atfork

---
 debian/changelog                           |  7 +++++++
 debian/patches/03_fix_pthread_atfork.patch | 16 ++++++++++++++++
 debian/patches/series                      |  2 ++
 3 files changed, 25 insertions(+)
 create mode 100644 debian/patches/03_fix_pthread_atfork.patch

diff --git a/debian/changelog b/debian/changelog
index f05084d..ef188e4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+libcap-ng (0.7.9-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Apply patch to fix pthread_atfork as Simon McVittie suggests
+
+ -- Rene Luria <rene.luria@infomaniak.com>  Sun, 09 Dec 2018 21:50:47 +0100
+
 libcap-ng (0.7.9-1) unstable; urgency=medium
 
   * New upstream version 0.7.9 (Closes: #896314, #725926)
diff --git a/debian/patches/03_fix_pthread_atfork.patch b/debian/patches/03_fix_pthread_atfork.patch
new file mode 100644
index 0000000..6282965
--- /dev/null
+++ b/debian/patches/03_fix_pthread_atfork.patch
@@ -0,0 +1,16 @@
+Description: Fix mark the DSOs as unloadable
+ as suggested by Simon McVittie in https://github.com/stevegrubb/libcap-ng/issues/5
+ and Carlos O'Donell at https://sourceware.org/bugzilla/show_bug.cgi?id=13502
+ mark the DSOs as unloadable with -z nodelete to prevent crashes at fork
+ .
+Author: Rene Luria <rene.luria@infomaniak.com>
+
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -34,5 +34,5 @@
+ libcap_ng_la_SOURCES = cap-ng.c lookup_table.c
+ libcap_ng_la_LIBADD =
+ libcap_ng_la_DEPENDENCIES = $(libcap_ng_la_SOURCES) ../config.h
+-libcap_ng_la_LDFLAGS = -Wl,-z,relro
++libcap_ng_la_LDFLAGS = -Wl,-z,relro -Wl,-z,nodelete
+ 
diff --git a/debian/patches/series b/debian/patches/series
index ce335cb..e0521c3 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,4 @@
 01_manpage_description.patch
 02_fix_armel_segfault_memset.patch
+03_fix_pthread_atfork.patch
+
-- 
2.11.0

