From b11e8d8b4555479dce4054aca1feffb06c0066e6 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 15 Nov 2016 01:04:39 -0500 Subject: sys-process/cronbase: fix non-POSIX shell code #595492 --- sys-process/cronbase/cronbase-0.3.7-r5.ebuild | 33 --------------------------- sys-process/cronbase/cronbase-0.3.7-r6.ebuild | 33 +++++++++++++++++++++++++++ sys-process/cronbase/files/run-crons-0.3.7 | 13 ++++++++++- 3 files changed, 45 insertions(+), 34 deletions(-) delete mode 100644 sys-process/cronbase/cronbase-0.3.7-r5.ebuild create mode 100644 sys-process/cronbase/cronbase-0.3.7-r6.ebuild diff --git a/sys-process/cronbase/cronbase-0.3.7-r5.ebuild b/sys-process/cronbase/cronbase-0.3.7-r5.ebuild deleted file mode 100644 index d263aeb11e0e..000000000000 --- a/sys-process/cronbase/cronbase-0.3.7-r5.ebuild +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 1999-2015 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -EAPI="5" - -inherit user - -DESCRIPTION="base for all cron ebuilds" -HOMEPAGE="https://www.gentoo.org/" - -LICENSE="GPL-2" -SLOT="0" -KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd" -IUSE="" - -S=${WORKDIR} - -pkg_setup() { - enewgroup cron 16 - enewuser cron 16 -1 /var/spool/cron cron -} - -src_install() { - newsbin "${FILESDIR}"/run-crons-${PV} run-crons - - diropts -m0750 - keepdir /etc/cron.{hourly,daily,weekly,monthly} - - keepdir /var/spool/cron/lastrun - diropts -m0750 -o root -g cron - keepdir /var/spool/cron -} diff --git a/sys-process/cronbase/cronbase-0.3.7-r6.ebuild b/sys-process/cronbase/cronbase-0.3.7-r6.ebuild new file mode 100644 index 000000000000..d263aeb11e0e --- /dev/null +++ b/sys-process/cronbase/cronbase-0.3.7-r6.ebuild @@ -0,0 +1,33 @@ +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI="5" + +inherit user + +DESCRIPTION="base for all cron ebuilds" +HOMEPAGE="https://www.gentoo.org/" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd" +IUSE="" + +S=${WORKDIR} + +pkg_setup() { + enewgroup cron 16 + enewuser cron 16 -1 /var/spool/cron cron +} + +src_install() { + newsbin "${FILESDIR}"/run-crons-${PV} run-crons + + diropts -m0750 + keepdir /etc/cron.{hourly,daily,weekly,monthly} + + keepdir /var/spool/cron/lastrun + diropts -m0750 -o root -g cron + keepdir /var/spool/cron +} diff --git a/sys-process/cronbase/files/run-crons-0.3.7 b/sys-process/cronbase/files/run-crons-0.3.7 index 902794e19e6f..42c88100df1c 100755 --- a/sys-process/cronbase/files/run-crons-0.3.7 +++ b/sys-process/cronbase/files/run-crons-0.3.7 @@ -56,7 +56,18 @@ grab_lock() { # This is better than kill -0 because we can verify that it's really # another run-crons process. - if diff -qs /proc/{${cronpid},$$}/cmdline > /dev/null 2>&1; then + # We have to send stderr to /dev/null for two reasons: + # - If the process disappears, the cmdline file might not exist. + # - The cmdline file contains NUL bytes, but bash-4.4+ warns when + # you try to assign NUL bytes to variables. + # It'd be nice to not do it for a lot of code, but there's not easy + # alternative in shell code. We could `cat | tr`, but that'd waste + # a bit more than just a simple cat. + if ( + cmdline1=$(cat "/proc/${cronpid}/cmdline") || : + cmdline2=$(cat "/proc/$$/cmdline") + [ "${cmdline1}" = "${cmdline2}" ] + ) 2>/dev/null ; then # Whoa, another run-crons is really running. return 1 fi -- cgit v1.2.3-18-g5258