net-misc/bopm: fix security bug with pid file.
authorRaymond Jennings <shentino@gmail.com>
Thu, 12 Oct 2017 06:50:58 +0000 (23:50 -0700)
committerPatrice Clement <monsieurp@gentoo.org>
Sun, 15 Oct 2017 21:11:03 +0000 (23:11 +0200)
In theory, someone who explots a hacked bopm could then use it to
attack root owned processes.

This puts the bopm-written PID file into a disposable junk directory
and lets start-stop-daemon do all the grunt work.

Bug: https://bugs.gentoo.org/631882
Closes: https://github.com/gentoo/gentoo/pull/5924

net-misc/bopm/bopm-3.1.3-r4.ebuild [moved from net-misc/bopm/bopm-3.1.3-r3.ebuild with 93% similarity]
net-misc/bopm/files/bopm-3.1.3-quarantine-bad-pid-file.patch [new file with mode: 0644]
net-misc/bopm/files/bopm.init.d-r2 [moved from net-misc/bopm/files/bopm.init.d-r1 with 70% similarity]

similarity index 93%
rename from net-misc/bopm/bopm-3.1.3-r3.ebuild
rename to net-misc/bopm/bopm-3.1.3-r4.ebuild
index 5e306a502712a6f8fc2783024f2100b2b5cce256..5c2096926f29a407390f4792e263fc02d3f6f7dd 100644 (file)
@@ -20,6 +20,7 @@ DEPEND="${RDEPEND}"
 PATCHES=(
        "${FILESDIR}"/${P}-remove-njabl.patch
        "${FILESDIR}"/${P}-autotools.patch
+       "${FILESDIR}"/${P}-quarantine-bad-pid-file.patch
 )
 
 pkg_setup() {
@@ -52,7 +53,7 @@ src_install() {
        # If anybody wants libopm, please install net-libs/libopm
        rm -r "${ED}"usr/$(get_libdir) "${ED}"usr/include || die
 
-       newinitd "${FILESDIR}"/bopm.init.d-r1 ${PN}
+       newinitd "${FILESDIR}"/bopm.init.d-r2 ${PN}
        newconfd "${FILESDIR}"/bopm.conf.d-r1 ${PN}
 
        dodir /var/log/bopm
diff --git a/net-misc/bopm/files/bopm-3.1.3-quarantine-bad-pid-file.patch b/net-misc/bopm/files/bopm-3.1.3-quarantine-bad-pid-file.patch
new file mode 100644 (file)
index 0000000..fedcd09
--- /dev/null
@@ -0,0 +1,16 @@
+Bopm writes its own pid file, but this is handled by the init script via
+openrc-run.
+---
+diff --git a/bopm.conf.sample b/bopm.conf.sample
+index e26dc17..fa5ce1d 100644
+--- a/bopm.conf.sample
++++ b/bopm.conf.sample
+@@ -9,7 +9,7 @@ options {
+        * Full path and filename for storing the process ID of the running
+        * BOPM.
+        */
+-      pidfile = "/run/bopm/bopm.pid";
++      pidfile = "/run/bopm/junk/bopm.pid";
+ 
+       /*
+        * How many seconds to store the IP address of hosts which are
similarity index 70%
rename from net-misc/bopm/files/bopm.init.d-r1
rename to net-misc/bopm/files/bopm.init.d-r2
index 6a292f800be21fce5178339513235cfbcd61a754..de6d959b9f7416899688bbe70da442110100c408 100644 (file)
@@ -12,5 +12,7 @@ depend() {
 }
 
 start_pre() {
-       checkpath -o ${BOPM_UID} -d "$(dirname "${PIDFILE}")"
+       checkpath -o 0:0 -d /run/bopm
+       checkpath -o ${BOPM_UID} -d /run/bopm/junk
+       checkpath -o ${BOPM_UID} -f /run/bopm/junk/bopm.pid
 }