Package: cron
Version: 3.0pl1-137
Severity: normal
Tags: patch
X-Debbugs-Cc: stephan.marc.garl...@gmail.com

Dear Maintainer,

Please see the writeup for this bug at:
https://gist.github.com/stephanGarland/b7cdd963e0ac53ea42f8ed15e35b193d

In short, if the timezone for a system is changed while cron is running,
and the timezone change is _not_ due to a DST event, cron is unaware of
the change and will continue using the old `GMToff` value until it is
restarted.

While this seems like a bizarre edge case, and it is, it happened to me
via moving, booting up my server rack, realizing the timezone needed to
be modified, and then not restarting the server. I noticed afterwards
that a daily cronjob I have ran one hour late.

The supplied patch fixes this, although I am cognizant of the fact that
this may be intended behavior. I'm willing to modify it to include an
optional flag (default: false) to set this behavior.

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


--- /usr/bin/editor:
/usr/bin/nvim

--- /usr/bin/crontab:
-rwxr-sr-x 1 root crontab 43568 Feb 22  2021 /usr/bin/crontab

--- /var/spool/cron:
drwxr-xr-x 3 root root 4096 Dec 23  2021 /var/spool/cron

--- /var/spool/cron/crontabs:
drwx-wx--T 2 root crontab 4096 Sep 11 15:53 /var/spool/cron/crontabs

--- /etc/cron.d:
drwxr-xr-x 2 root root 4096 Sep 11 21:13 /etc/cron.d

--- /etc/cron.daily:
drwxr-xr-x 2 root root 4096 Sep 11 06:34 /etc/cron.daily

--- /etc/cron.hourly:
drwxr-xr-x 2 root root 4096 Dec 23  2021 /etc/cron.hourly

--- /etc/cron.monthly:
drwxr-xr-x 2 root root 4096 Dec 23  2021 /etc/cron.monthly

--- /etc/cron.weekly:
drwxr-xr-x 2 root root 4096 Dec 23  2021 /etc/cron.weekly


-- System Information:
Debian Release: 11.5
  APT prefers stable
  APT policy: (700, 'stable'), (650, 'testing'), (600, 'unstable'), (500, 
'stable-updates'), (500, 'stable-security')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-16-amd64 (SMP w/8 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages cron depends on:
ii  adduser              3.118
ii  debianutils          4.11.2
ii  init-system-helpers  1.60
ii  libc6                2.31-13+deb11u4
ii  libpam-runtime       1.4.0-9+deb11u1
ii  libpam0g             1.4.0-9+deb11u1
ii  libselinux1          3.1-3
ii  lsb-base             11.1.0
ii  sensible-utils       0.0.14

Versions of packages cron recommends:
pn  default-mta | mail-transport-agent  <none>

Versions of packages cron suggests:
pn  anacron        <none>
pn  checksecurity  <none>
ii  logrotate      3.18.0-2+deb11u1

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

-- no debconf information
diff --git a/cron.c b/cron.c
index 613e7bf..7b0b69c 100644
--- a/cron.c
+++ b/cron.c
@@ -372,9 +372,9 @@ set_time(int initialize)
 
     /* We adjust the time to GMT so we can catch DST changes. */
     tm = *localtime(&StartTime);
+    GMToff = get_gmtoff(&StartTime, &tm);
     if (initialize || tm.tm_isdst != isdst) {
        isdst = tm.tm_isdst;
-       GMToff = get_gmtoff(&StartTime, &tm);
        Debug(DSCH, ("[%d] GMToff=%ld\n",
            getpid(), (long)GMToff))
     }

Reply via email to