Package: cron
Version: 3.0pl1-116
Severity: normal

I ran into this on Ubuntu Natty initially, but I can reproduce this on
Debian Unstable, too.

It seems to be a more seldom and not yet fixed special case of the
otherwise fixed http://bugs.debian.org/555954. As parts of #555954
definitely have been fixed, I decided not to reopen #555954 but file a
new bug report and just refer to #555954.

Here's how to reproduce the issue manually (a script for automated
testing of the issue can be found later in this bug report):

Create two valid crontab files in /etc/cron.d/, e.g test1 and test2. (I
used "echo sometext `date` >> /tmp/cron-test" as command and changed the
string "sometext" every time I edited the file.

Then remove the final newline from test1. cron will spit out the
following warning via syslog:

  May 24 23:05:01 nemo cron.info /usr/sbin/cron[1474]: (*system*test1) ERROR 
(Missing newline before EOF, this crontab file will be ignored)

The cronjobs from test2 will continue to work, those in test1 won't.

Now fix the missing newline in test1 by adding it again. It still won't
run the cronjobs in there until you either:

  * Edit _another_ file in /etc/cron.d/, e.g. test2
  * Create a new in /etc/cron.d/, e.g. test3
  * Delete a file from /etc/cron.d/, e.g. test2
  * Restart cron.

If I produce a syntax error like in http://bugs.debian.org/555954
(e.g. by writing "syntax error" on a line of its own in test1 without a
leading "#"), the same applies.

So the "cron won't pick up new files in this directory" part of #555954
is fixed, but the "cron won't reload it" unfortunately isn't.

IMHO cron should at least stat files in /etc/cron.d with known syntax
errors every time and recheck their syntax if the mtime has changed, not
only if other (valid) files have changed, vanished or popped up.

The "mv local-test{~,}" pf Josip in [1] doesn't cover respectively
avoids this case as it also changes other files in the directory (it
removes "local-test~") which seems to trigger that cron checks _all_
files again.

  [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=555954#101

With regards to Xavier's tests as described at
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=555954#129 I can't
reproduce his results with the commands he gave for Squeeze. (I even
used vi as he did, but that may result in one out of idontknowhowmany
packages in Debian. Here it results in using nvi. :-) I suspect that
possibly other files in the directory have been touched accidentially,
too, or the bug has been reintroduced since then, but the cron package
in Sid is still the same as in Squeeze, so the changed would have to be
in another package then...

So to be sure that I run the test without the danger of collateral
changes, I fully automated it. See script, syslog and output below.

I monitored the syslog with "logread -f | fgrep -i --color cron" of the
installed busybox-syslogd package, but a "tail -F /var/log/syslog | grep
-i cron" or similar should work fine on systems with a normal syslog
daemon, too.

The script:

---snip---
#!/bin/sh

# Create the test crontabs
echo 'syntax error' > test1
echo '* * * * * root echo test2 `date` >> /tmp/cron-test' > test2

#  See what's all in /etc/cron.d/
ls -la --full-time /etc/cron.d/

# Sleep for two minutes. Now at least once, the syntax error should pop
# up in the syslog and test2 should be executed twice.
sleep 120

# Fix crontab file test1
echo '* * * * * root echo test1-fixed `date` >> /tmp/cron-test' > test1

# Sleep for another two minutes. Only test2 should be executed.
sleep 120

# Now change test2
echo '* * * * * root echo test2-changed `date` >> /tmp/cron-test' > test2

# Sleep for another two minutes. Both, test1 and test2 should be executed.
sleep 120
---snap---

Executing the script with "sh -x" yields the following output:

---snip---
+ echo syntax error
+ echo * * * * * root echo test2 `date` >> /tmp/cron-test
+ ls -la --full-time /etc/cron.d/
total 44
drwxr-xr-x   2 root root  4096 2011-05-25 00:16:08.000000000 +0200 .
drwxr-xr-x 197 root root 20480 2011-05-24 23:53:33.000000000 +0200 ..
-rw-r--r--   1 root root   244 2008-03-09 20:58:31.000000000 +0100 anacron
-rw-r--r--   1 root root   699 2009-10-11 15:27:58.000000000 +0200 dphys-config
-rw-r--r--   1 root root   102 2008-03-14 01:27:59.000000000 +0100 .placeholder
-rw-r--r--   1 root root    13 2011-05-25 00:16:08.000000000 +0200 test1
-rw-r--r--   1 root root    51 2011-05-25 00:16:08.000000000 +0200 test2
+ sleep 120
+ echo * * * * * root echo test1-fixed `date` >> /tmp/cron-test
+ sleep 120
+ echo * * * * * root echo test2-changed `date` >> /tmp/cron-test
+ sleep 120
---snap---

Syslog output filtered for cron entries during that time (line feeds
added manually after each one-minute block):

---snip---
May 25 00:17:01 nemo cron.err cron[1474]: Error: bad minute; while reading 
/etc/cron.d/test1
May 25 00:17:01 nemo cron.info /usr/sbin/cron[1474]: (*system*test1) ERROR 
(Syntax error, this crontab file will be ignored)
May 25 00:17:01 nemo authpriv.info CRON[32267]: pam_unix(cron:session): session 
opened for user root by (uid=0)
May 25 00:17:01 nemo authpriv.info CRON[32266]: pam_unix(cron:session): session 
opened for user root by (uid=0)
May 25 00:17:01 nemo authpriv.debug CRON[32267]: pam_limits(cron:session): 
Unknown kernel rlimit 'Max realtime timeout' ignored
May 25 00:17:01 nemo authpriv.debug CRON[32266]: pam_limits(cron:session): 
Unknown kernel rlimit 'Max realtime timeout' ignored
May 25 00:17:01 nemo cron.info /USR/SBIN/CRON[32268]: (root) CMD (echo test2 
`date` >> /tmp/cron-test)
May 25 00:17:01 nemo cron.info /USR/SBIN/CRON[32269]: (root) CMD (   cd / && 
run-parts --report /etc/cron.hourly)
May 25 00:17:01 nemo authpriv.info CRON[32266]: pam_unix(cron:session): session 
closed for user root
May 25 00:17:01 nemo authpriv.info CRON[32267]: pam_unix(cron:session): session 
closed for user root

May 25 00:18:01 nemo authpriv.info CRON[32284]: pam_unix(cron:session): session 
opened for user root by (uid=0)
May 25 00:18:01 nemo authpriv.debug CRON[32284]: pam_limits(cron:session): 
Unknown kernel rlimit 'Max realtime timeout' ignored
May 25 00:18:01 nemo cron.info /USR/SBIN/CRON[32285]: (root) CMD (echo test2 
`date` >> /tmp/cron-test)
May 25 00:18:01 nemo authpriv.info CRON[32284]: pam_unix(cron:session): session 
closed for user root

May 25 00:19:01 nemo authpriv.info CRON[32300]: pam_unix(cron:session): session 
opened for user root by (uid=0)
May 25 00:19:01 nemo authpriv.debug CRON[32300]: pam_limits(cron:session): 
Unknown kernel rlimit 'Max realtime timeout' ignored
May 25 00:19:01 nemo cron.info /USR/SBIN/CRON[32301]: (root) CMD (echo test2 
`date` >> /tmp/cron-test)
May 25 00:19:01 nemo authpriv.info CRON[32300]: pam_unix(cron:session): session 
closed for user root

May 25 00:20:01 nemo authpriv.info CRON[32326]: pam_unix(cron:session): session 
opened for user root by (uid=0)
May 25 00:20:01 nemo authpriv.debug CRON[32326]: pam_limits(cron:session): 
Unknown kernel rlimit 'Max realtime timeout' ignored
May 25 00:20:01 nemo cron.info /USR/SBIN/CRON[32327]: (root) CMD (echo test2 
`date` >> /tmp/cron-test)
May 25 00:20:01 nemo authpriv.info CRON[32326]: pam_unix(cron:session): session 
closed for user root

May 25 00:21:01 nemo cron.info /usr/sbin/cron[1474]: (*system*test2) RELOAD 
(/etc/cron.d/test2)
May 25 00:21:01 nemo authpriv.info CRON[32343]: pam_unix(cron:session): session 
opened for user root by (uid=0)
May 25 00:21:01 nemo authpriv.info CRON[32342]: pam_unix(cron:session): session 
opened for user root by (uid=0)
May 25 00:21:01 nemo authpriv.debug CRON[32343]: pam_limits(cron:session): 
Unknown kernel rlimit 'Max realtime timeout' ignored
May 25 00:21:01 nemo authpriv.debug CRON[32342]: pam_limits(cron:session): 
Unknown kernel rlimit 'Max realtime timeout' ignored
May 25 00:21:01 nemo cron.info /USR/SBIN/CRON[32344]: (root) CMD (echo 
test2-changed `date` >> /tmp/cron-test)
May 25 00:21:01 nemo cron.info /USR/SBIN/CRON[32345]: (root) CMD (echo 
test1-fixed `date` >> /tmp/cron-test)
May 25 00:21:01 nemo authpriv.info CRON[32343]: pam_unix(cron:session): session 
closed for user root
May 25 00:21:01 nemo authpriv.info CRON[32342]: pam_unix(cron:session): session 
closed for user root

May 25 00:22:01 nemo authpriv.info CRON[32361]: pam_unix(cron:session): session 
opened for user root by (uid=0)
May 25 00:22:01 nemo authpriv.debug CRON[32361]: pam_limits(cron:session): 
Unknown kernel rlimit 'Max realtime timeout' ignored
May 25 00:22:01 nemo authpriv.info CRON[32360]: pam_unix(cron:session): session 
opened for user root by (uid=0)
May 25 00:22:01 nemo authpriv.debug CRON[32360]: pam_limits(cron:session): 
Unknown kernel rlimit 'Max realtime timeout' ignored
May 25 00:22:01 nemo cron.info /USR/SBIN/CRON[32362]: (root) CMD (echo 
test2-changed `date` >> /tmp/cron-test)
May 25 00:22:01 nemo cron.info /USR/SBIN/CRON[32363]: (root) CMD (echo 
test1-fixed `date` >> /tmp/cron-test)
May 25 00:22:01 nemo authpriv.info CRON[32361]: pam_unix(cron:session): session 
closed for user root
May 25 00:22:01 nemo authpriv.info CRON[32360]: pam_unix(cron:session): session 
closed for user root
---snap---

Contents of /tmp/cron-test afterwards:

---snip---
test2 Wed May 25 00:17:01 CEST 2011
test2 Wed May 25 00:18:01 CEST 2011
test2 Wed May 25 00:19:01 CEST 2011
test2 Wed May 25 00:20:01 CEST 2011
test2-changed Wed May 25 00:21:01 CEST 2011
test1-fixed Wed May 25 00:21:01 CEST 2011
test2-changed Wed May 25 00:22:01 CEST 2011
test1-fixed Wed May 25 00:22:01 CEST 2011
---snap---

IMHO this shows that http://bugs.debian.org/555954 is definitely not
fully fixed.

-- Package-specific info:
--- EDITOR:

--- usr/bin/editor:
/usr/bin/zile

--- /usr/bin/crontab:
-rwxr-sr-x 1 root crontab 30248 Dec 19 00:46 /usr/bin/crontab

--- /var/spool/cron
drwxr-xr-x 3 root root 4096 May 11  2008 /var/spool/cron

--- /var/spool/cron/crontabs
drwx-wx--T 2 root crontab 4096 Mar 14  2008 /var/spool/cron/crontabs

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (600, 'stable'), (500, 'testing'), (400, 
'oldstable'), (110, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.39-1-686-pae (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages cron depends on:
ii  adduser                      3.112+nmu2  add and remove users and groups
ii  debianutils                  4           Miscellaneous utilities specific t
ii  dpkg                         1.16.0.3    Debian package management system
ii  libc6                        2.13-4      Embedded GNU C Library: Shared lib
ii  libpam-runtime               1.1.2-3     Runtime support for the PAM librar
ii  libpam0g                     1.1.2-3     Pluggable Authentication Modules l
ii  libselinux1                  2.0.98-1+b1 SELinux runtime shared libraries
ii  lsb-base                     3.2-27      Linux Standard Base 3.2 init scrip

Versions of packages cron recommends:
ii  lockfile-progs                0.1.15     Programs for locking and unlocking
ii  postfix [mail-transport-agent 2.8.3-1    High-performance mail transport ag

Versions of packages cron suggests:
ii  anacron                       2.3-14     cron-like program that doesn't go 
pn  checksecurity                 <none>     (no description available)
ii  logrotate                     3.7.8-6    Log rotation utility

Versions of packages cron is related to:
pn  libnss-ldap                   <none>     (no description available)
pn  libnss-ldapd                  <none>     (no description available)
pn  libpam-ldap                   <none>     (no description available)
pn  libpam-mount                  <none>     (no description available)
pn  nis                           <none>     (no description available)
pn  nscd                          <none>     (no description available)

-- no debconf information

Reply via email to