[gentoo-commits] repo/gentoo:master commit in: sys-process/cronbase/, sys-process/cronbase/files/

2016-11-14 Thread Mike Frysinger
commit: b11e8d8b4555479dce4054aca1feffb06c0066e6
Author: Mike Frysinger  gentoo  org>
AuthorDate: Tue Nov 15 06:04:39 2016 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Tue Nov 15 06:06:05 2016 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b11e8d8b

sys-process/cronbase: fix non-POSIX shell code #595492

 .../{cronbase-0.3.7-r5.ebuild => cronbase-0.3.7-r6.ebuild}  |  0
 sys-process/cronbase/files/run-crons-0.3.7  | 13 -
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/sys-process/cronbase/cronbase-0.3.7-r5.ebuild 
b/sys-process/cronbase/cronbase-0.3.7-r6.ebuild
similarity index 100%
rename from sys-process/cronbase/cronbase-0.3.7-r5.ebuild
rename to sys-process/cronbase/cronbase-0.3.7-r6.ebuild

diff --git a/sys-process/cronbase/files/run-crons-0.3.7 
b/sys-process/cronbase/files/run-crons-0.3.7
index 902794e..42c8810 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



[gentoo-commits] repo/gentoo:master commit in: sys-process/cronbase/, sys-process/cronbase/files/

2016-09-30 Thread Tobias Klausmann
commit: 7c266d7a1854b3b1b543fb35036d3e4e6c3135cf
Author: Tobias Klausmann  gentoo  org>
AuthorDate: Fri Sep 30 07:22:54 2016 +
Commit: Tobias Klausmann  gentoo  org>
CommitDate: Fri Sep 30 07:25:22 2016 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7c266d7a

sys-process/cronbase: avoid bash complaining about null bytes

Newer versions of bash warn about null bytes in command substitutions,
so run-crons would generate mails with messages like this:

/usr/sbin/run-crons: line 59: warning: command substitution: ignored null byte 
in input
/usr/sbin/run-crons: line 59: warning: command substitution: ignored null byte 
in input
/usr/sbin/run-crons: line 60: warning: command substitution: ignored null byte 
in input
/usr/sbin/run-crons: line 60: warning: command substitution: ignored null byte 
in input

Since the warning is not useful and the resultant string has its null
bytes deleted, we might as well delete them with tr and get rid of the
warning.

 .../cronbase/{cronbase-0.3.7-r1.ebuild => cronbase-0.3.7-r2.ebuild} | 0
 sys-process/cronbase/files/run-crons-0.3.7  | 6 --
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys-process/cronbase/cronbase-0.3.7-r1.ebuild 
b/sys-process/cronbase/cronbase-0.3.7-r2.ebuild
similarity index 100%
rename from sys-process/cronbase/cronbase-0.3.7-r1.ebuild
rename to sys-process/cronbase/cronbase-0.3.7-r2.ebuild

diff --git a/sys-process/cronbase/files/run-crons-0.3.7 
b/sys-process/cronbase/files/run-crons-0.3.7
index c661c77..c5f2d9c 100755
--- a/sys-process/cronbase/files/run-crons-0.3.7
+++ b/sys-process/cronbase/files/run-crons-0.3.7
@@ -56,8 +56,10 @@ grab_lock() {
 
# This is better than kill -0 because we can verify that it's 
really
# another run-crons process.
-   cmdline1=$(cat "/proc/${cronpid}/cmdline" 2>/dev/null) || :
-   cmdline2=$(cat /proc/$$/cmdline)
+   # The tr call deletes null bytes so newer bash versions do not 
complain
+   # about them.
+   cmdline1=$(tr -d '\0'  < "/proc/${cronpid}/cmdline" 
2>/dev/null) || :
+   cmdline2=$(tr -d '\0'  < /proc/$$/cmdline)
if [ "${cmdline1}" = "${cmdline2}" ] ; then
# Whoa, another run-crons is really running.
return 1