From owner-freebsd-bugs@freebsd.org Sat Dec 23 08:37:26 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB47AE9FF62 for ; Sat, 23 Dec 2017 08:37:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F23A7B90F for ; Sat, 23 Dec 2017 08:37:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id vBN8bQxO069430 for ; Sat, 23 Dec 2017 08:37:26 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 224537] cron uses directory mtime to notice changes - not sufficient - file changes don't change dir mtime Date: Sat, 23 Dec 2017 08:37:26 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 11.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: jsellens@syonex.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Dec 2017 08:37:26 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D224537 Bug ID: 224537 Summary: cron uses directory mtime to notice changes - not sufficient - file changes don't change dir mtime Product: Base System Version: 11.1-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: freebsd-bugs@FreeBSD.org Reporter: jsellens@syonex.com /usr/sbin/cron allows multiple files in /etc/cron.d and /usr/local/etc/cron= .d and uses the mtime of the directory as an indicator of when to reload the c= ron files. In cron/database.c in load_database() at around line 100, the comment is: /* if spooldir's mtime has not changed, we don't need to fiddle with * the database. and the statbuf.st_mtime is compared to the previous version. If a file in a directory changes, the mtime on the directory does not chang= e, so changes to files in cron.d directories are often not noticed. Repeat by putting a cron file in /etc/cron.d, then using echo or cat to add= an additional entry and notice that the additional entry does not run. Simila= rly, use vi to edit the file, the directory's mtime does not change, and cron fi= le changes are not loaded. The cron(8) man page says: "Thus cron need not be restarted whenever a cron= tab file is modified." which is incorrect. It mentions that crontab(1) will up= date the directory time, but crontab(1) can't be used with /etc/cron.d or /usr/local/etc/cron.d files. Perhaps the code could compute and compare a checksum on the directory, or a checksum on the results of opendir() / readdir() , rather than looking only= at the directory mtime? (I ran into this when puppet was updating files in /etc/cron.d and the comm= ands being run were not changing.) Thanks! --=20 You are receiving this mail because: You are the assignee for the bug.=