From nobody Thu Jan 09 19:00:32 2025 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YTYyS70j7z5jq3f for ; Thu, 09 Jan 2025 19:00:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YTYyS32DFz4gCt for ; Thu, 9 Jan 2025 19:00:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736449232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QkF5YfYMXeFr3iN53X1UfmMOLdx74rpjMtcgG8zG7UU=; b=uordH5DTdkxZjPqLKif8gxCAA7sWM9iI1wNnRuk6rwf1X66mKBVNjjoj9Yp2jngL4uowGi SWTMsVmszoh2BuYfoZ6PH5E2l+H6FTNrXTlevSR6AqI/I0/7Z8pkCMdHkgaRawQZNKQM4W TcU5NioviUzMYOfE7BNDhmlnrZ0Y63sTwkeGn3e02g9JnbKgHpzdYNiCI9h7ybcOZZ6THU no52oMRBXrTHoPw/9wI9g2FaG1dgzeKm5H4yM/OAXTBS8xZbgg2IKRKpbBuauitMGVe8p6 ubWd4ng/tyeZ4nB5dZs/DYTnqs1KYJar4uLkQKhZOxbRvicRuKrYn43hq9sqVw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736449232; a=rsa-sha256; cv=none; b=CSlq9TpTrKfubkJrMblEbFBplQY3VvQ7kipiuEKo3eHSHeENAKVFeickTyxeK7HXawsrzx Swv0HleOEjAgRnWnq+FUWqyqBiWU461fpSF9YOiuXmfdbnJXeviZb6F8YrYmKlZ9OX+dzY Q3JCXitIFIOYvXBAZzRMkCLxDivQnGB+IPzOjqzq1H9RMYii21wjOexGIXauzzb9puLVNy xSCEdPnRRIPGr5Md2VkfzJ80KZn9iwrkSz3SrZKNmHWTwCpygX/7Jx/Vq11TKZmmOZowF7 gu3GgWHwoaOjH6UftKss8Q/ykkVHqZsBQeFKLk4d9JWlAsj0aGbHurQfycw1XA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YTYyS2GNJzf45 for ; Thu, 09 Jan 2025 19:00:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 509J0WCG044209 for ; Thu, 9 Jan 2025 19:00:32 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 509J0W3p044207 for bugs@FreeBSD.org; Thu, 9 Jan 2025 19:00:32 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 283964] cron processing logic flawed with cron.d configs Date: Thu, 09 Jan 2025 19:00:32 +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: 14.2-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: matthew.l.dailey@dartmouth.edu X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: 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 attachments.created Message-ID: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D283964 Bug ID: 283964 Summary: cron processing logic flawed with cron.d configs Product: Base System Version: 14.2-STABLE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: matthew.l.dailey@dartmouth.edu Created attachment 256589 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D256589&action= =3Dedit Potential patch The way that cron processes crontabs in cron.d is flawed such that jobs can= be duplicated, old jobs can continue to run after a file is deleted, and jobs = can be skipped entirely. The easiest way to illustrate is to create three cron jobs: echo "*/1 * * * * root /usr/bin/true a" > /etc/cron.d/a.conf echo "*/1 * * * * root /usr/bin/true b" > /etc/cron.d/b.conf echo "*/1 * * * * root /usr/bin/true c" > /etc/cron.d/c.conf Touch the files so they all have identical timestamps: touch /etc/cron.d/a.conf /etc/cron.d/b.conf /etc/cron.d/c.conf Start cron and/or let it run for more than a minute to verify all three jobs run. Remove a.conf: rm /etc/cron.d/a.conf At this point, cron will continue to run jobs a and b and skip c, even thou= gh it should only be running jobs b and c. The problem seems to be with the implementation of the cron.d parsing and i= ts interaction with find_user(). Vixie cron has no notion of cron.d, so the internal database expects a single entry for each user. However, the additi= on of cron.d logic adds additional "*system* entries in the database for each = of the files in cron.d. find_user() simply then advances the pointer to the ne= xt entry for this user, regardless of which cron.d file is being processed. If= the mtime of this matches the entry in the old database, it is copied over with potentially incorrect data. I've attached a possible fix for this that works in limited testing, adding= the actual filename to the internal database and using this, along with the username for lookup. One disadvantage of this approach is that it takes the code further away from Vixie cron. An alternate solution would be to append additional crontabs from cron.d to the existing "*system" entry in the database, but this would be a much more substantial change. --=20 You are receiving this mail because: You are the assignee for the bug.=