diff options
author | Aron Griffis <agriffis@gentoo.org> | 2004-05-25 03:55:27 +0000 |
---|---|---|
committer | Aron Griffis <agriffis@gentoo.org> | 2004-05-25 03:55:27 +0000 |
commit | c33d62a8a623a4dff3bfe0d01f3010a4b2a5ff5d (patch) | |
tree | aec3a099daf3f3f25ef4d2515db311afb77e5031 | |
parent | Change doins to newins for Muttrc.mbox (diff) | |
download | historical-c33d62a8a623a4dff3bfe0d01f3010a4b2a5ff5d.tar.gz historical-c33d62a8a623a4dff3bfe0d01f3010a4b2a5ff5d.tar.bz2 historical-c33d62a8a623a4dff3bfe0d01f3010a4b2a5ff5d.zip |
Fix bug 45155 (run-crons and /var/spool/cron/lastrun/lock problems) by re-writing the locking code to be non-racy
-rw-r--r-- | sys-apps/cronbase/ChangeLog | 9 | ||||
-rw-r--r-- | sys-apps/cronbase/Manifest | 13 | ||||
-rw-r--r-- | sys-apps/cronbase/cronbase-0.2.1-r3.ebuild | 8 | ||||
-rw-r--r-- | sys-apps/cronbase/cronbase-0.3.ebuild (renamed from sys-apps/cronbase/cronbase-0.2.1-r2.ebuild) | 12 | ||||
-rw-r--r-- | sys-apps/cronbase/files/digest-cronbase-0.3 (renamed from sys-apps/cronbase/files/digest-cronbase-0.2.1-r2) | 0 | ||||
-rw-r--r-- | sys-apps/cronbase/files/run-crons-0.2.1 (renamed from sys-apps/cronbase/files/run-crons) | 2 | ||||
-rw-r--r-- | sys-apps/cronbase/files/run-crons-0.3 | 96 |
7 files changed, 124 insertions, 16 deletions
diff --git a/sys-apps/cronbase/ChangeLog b/sys-apps/cronbase/ChangeLog index d318aa666923..43b1094bf8b9 100644 --- a/sys-apps/cronbase/ChangeLog +++ b/sys-apps/cronbase/ChangeLog @@ -1,6 +1,13 @@ # ChangeLog for sys-apps/cronbase # Copyright 2002-2004 Gentoo Technologies, Inc.; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/ChangeLog,v 1.26 2004/04/08 04:44:41 kumba Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/ChangeLog,v 1.27 2004/05/25 03:55:25 agriffis Exp $ + +*cronbase-0.3 (24 May 2004) + + 24 May 2004; Aron Griffis <agriffis@gentoo.org> -files/run-crons, + -cronbase-0.2.1-r2.ebuild, cronbase-0.2.1-r3.ebuild, +cronbase-0.3.ebuild: + Fix bug 45155 (run-crons and /var/spool/cron/lastrun/lock problems) by + re-writing the locking code to be non-racy 08 Apr 2004; Joshua Kinard <kumba@gentoo.org> cronbase-0.2.1-r2.ebuild, cronbase-0.2.1-r3.ebuild: diff --git a/sys-apps/cronbase/Manifest b/sys-apps/cronbase/Manifest index a683bcfe88cf..10f23bf84dac 100644 --- a/sys-apps/cronbase/Manifest +++ b/sys-apps/cronbase/Manifest @@ -1,8 +1,9 @@ -MD5 b623d985fb0301525f25c8c13d91710b files/run-crons 1951 +MD5 9831e938cfb8c07c2f0ed7afc672bfe7 cronbase-0.3.ebuild 813 +MD5 3f60b43d2b553f9ff47d8c40f3daf446 cronbase-0.2.1-r3.ebuild 808 +MD5 6d1288cefbbe22530e1ce88f8121546b ChangeLog 2879 +MD5 9a09f8d531c582e78977dbfd96edc1f2 metadata.xml 164 +MD5 e57466a831c0bad43576d0452c921917 files/run-crons-0.3 2642 +MD5 18a8bf5cbbe01783a4c45861b01387ff files/run-crons-0.2.1 1961 MD5 7485f1f027858d0866f3556990d24ea9 files/README 2859 -MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-cronbase-0.2.1-r2 0 +MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-cronbase-0.3 0 MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-cronbase-0.2.1-r3 0 -MD5 88fd0f45880a2c818514d4b3aedb9bdc ChangeLog 2583 -MD5 429c3dc88e7bd4509a3878005226a8ab cronbase-0.2.1-r2.ebuild 768 -MD5 b91f22c0fa3c139ebe347ca42b5c0b36 cronbase-0.2.1-r3.ebuild 781 -MD5 9a09f8d531c582e78977dbfd96edc1f2 metadata.xml 164 diff --git a/sys-apps/cronbase/cronbase-0.2.1-r3.ebuild b/sys-apps/cronbase/cronbase-0.2.1-r3.ebuild index ed7cc29d69d3..5ebe49d892df 100644 --- a/sys-apps/cronbase/cronbase-0.2.1-r3.ebuild +++ b/sys-apps/cronbase/cronbase-0.2.1-r3.ebuild @@ -1,17 +1,19 @@ # Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/cronbase-0.2.1-r3.ebuild,v 1.12 2004/04/24 08:42:39 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/cronbase-0.2.1-r3.ebuild,v 1.13 2004/05/25 03:55:25 agriffis Exp $ + +IUSE="" DESCRIPTION="base for all cron ebuilds" HOMEPAGE="http://www.gentoo.org/" LICENSE="GPL-2" SLOT="0" -KEYWORDS="x86 ppc ppc64 sparc mips alpha arm hppa amd64 ~ia64 s390" +KEYWORDS="x86 ppc ppc64 sparc mips alpha arm hppa amd64 ia64 s390" src_install() { exeinto /usr/sbin - doexe ${FILESDIR}/run-crons || die + newexe ${FILESDIR}/run-crons-${PV} run-crons || die diropts -m0750; keepdir /etc/cron.hourly diropts -m0750; keepdir /etc/cron.daily diff --git a/sys-apps/cronbase/cronbase-0.2.1-r2.ebuild b/sys-apps/cronbase/cronbase-0.3.ebuild index 251bcf10cc94..9eac33a45580 100644 --- a/sys-apps/cronbase/cronbase-0.2.1-r2.ebuild +++ b/sys-apps/cronbase/cronbase-0.3.ebuild @@ -1,17 +1,19 @@ # Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/cronbase-0.2.1-r2.ebuild,v 1.8 2004/04/08 04:44:41 kumba Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/cronbase-0.3.ebuild,v 1.1 2004/05/25 03:55:25 agriffis Exp $ -DESCRIPTION="The is the base for all cron ebuilds." +IUSE="" + +DESCRIPTION="base for all cron ebuilds" HOMEPAGE="http://www.gentoo.org/" -KEYWORDS="x86 amd64 ppc sparc alpha mips hppa ia64" -SLOT="0" LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~x86 ~ppc ~ppc64 ~sparc ~mips ~alpha ~arm ~hppa ~amd64 ~ia64 ~s390" src_install() { exeinto /usr/sbin - doexe ${FILESDIR}/run-crons + newexe ${FILESDIR}/run-crons-${PV} run-crons || die diropts -m0750; keepdir /etc/cron.hourly diropts -m0750; keepdir /etc/cron.daily diff --git a/sys-apps/cronbase/files/digest-cronbase-0.2.1-r2 b/sys-apps/cronbase/files/digest-cronbase-0.3 index e69de29bb2d1..e69de29bb2d1 100644 --- a/sys-apps/cronbase/files/digest-cronbase-0.2.1-r2 +++ b/sys-apps/cronbase/files/digest-cronbase-0.3 diff --git a/sys-apps/cronbase/files/run-crons b/sys-apps/cronbase/files/run-crons-0.2.1 index 84b1410436bb..af756a5942ef 100644 --- a/sys-apps/cronbase/files/run-crons +++ b/sys-apps/cronbase/files/run-crons-0.2.1 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/files/run-crons,v 1.9 2003/11/19 06:31:23 prez Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/files/run-crons-0.2.1,v 1.1 2004/05/25 03:55:27 agriffis Exp $ # # 23 Jun 2002; Jon Nelson <jnelson@gentoo.org> run-crons: # diff --git a/sys-apps/cronbase/files/run-crons-0.3 b/sys-apps/cronbase/files/run-crons-0.3 new file mode 100644 index 000000000000..316c3398b17d --- /dev/null +++ b/sys-apps/cronbase/files/run-crons-0.3 @@ -0,0 +1,96 @@ +#!/bin/bash +# +# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/files/run-crons-0.3,v 1.1 2004/05/25 03:55:27 agriffis Exp $ +# +# +# 06 May 2004; Aron Griffis <agriffis@gentoo.org> run-crons: +# Make the locking actually work. The old code was racy. +# Thanks to Mathias Gumz in bug 45155 for some cleanups. +# +# 23 Jun 2002; Jon Nelson <jnelson@gentoo.org> run-crons: +# fixed a race condition, where cron jobs and run-crons wanted to +# delete touch files +# +# 20 Apr 2002; Thilo Bangert <bangert@gentoo.org> run-crons: +# moved lastrun directory to /var/spool/cron/lastrun +# +# Author: Achim Gottinger <achim@gentoo.org> +# +# Mostly copied from SuSE +# +# this script looks into /etc/cron.[hourly|daily|weekly|monthly] +# for scripts to be executed. The info about last run is stored in +# /var/spool/cron/lastrun + +LOCKDIR=/var/spool/cron/lastrun +LOCKFILE=${LOCKDIR}/lock + +mkdir -p ${LOCKDIR} + +# Make sure we're not running multiple instances at once. +# Try twice to lock, otherwise give up. +for ((i = 0; i -lt 2; i = i + 1)); do + ln -sn $$ ${LOCKFILE} 2>/dev/null + if [[ $? != 0 ]]; then + # lock failed, check for a running process. + # handle both old- and new-style locking. + cronpid=$(readlink ${LOCKFILE} 2>/dev/null || + cat ${LOCKFILE} 2>/dev/null) + if [[ $? == 0 ]]; then + if kill -0 ${cronpid} 2>/dev/null; then + # whoa, another process is really running + exit 0 + else + rm -f ${LOCKFILE} + fi + fi + fi +done + +# Set a trap to remove the lockfile when we're finished +trap "rm -f ${LOCKFILE}" 0 1 2 3 15 + + +for BASE in hourly daily weekly monthly +do + CRONDIR=/etc/cron.${BASE} + + test -d $CRONDIR || continue + + if [ -e ${LOCKDIR}/cron.$BASE ] + then + case $BASE in + hourly) + #>= 1 hour, 5 min -=> +65 min + TIME="-cmin +65" ;; + daily) + #>= 1 day, 5 min -=> +1445 min + TIME="-cmin +1445" ;; + weekly) + #>= 1 week, 5 min -=> +10085 min + TIME="-cmin +10085" ;; + monthly) + #>= 31 days, 5 min -=> +44645 min + TIME="-cmin +44645" ;; + esac + find ${LOCKDIR} -name cron.$BASE $TIME -exec rm {} \; + fi + + # if there is no touch file, make one then run the scripts + if [ ! -e ${LOCKDIR}/cron.$BASE ] + then + touch ${LOCKDIR}/cron.$BASE + + set +e + for SCRIPT in $CRONDIR/* + do + if [[ -x $SCRIPT && ! -d $SCRIPT ]]; then + $SCRIPT + fi + done + fi +done + +# Clean out bogus cron.$BASE files with future times +touch ${LOCKDIR} +find ${LOCKDIR} -newer ${LOCKDIR} -exec /bin/rm -f {} \; |