NetBSD Problem Report #53986

From www@NetBSD.org  Sat Feb 16 16:26:56 2019
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id AF5837A177
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 16 Feb 2019 16:26:56 +0000 (UTC)
Message-Id: <20190216162655.8869A7A1DF@mollari.NetBSD.org>
Date: Sat, 16 Feb 2019 16:26:55 +0000 (UTC)
From: naddy@mips.inka.de
Reply-To: naddy@mips.inka.de
To: gnats-bugs@NetBSD.org
Subject: at(1) HH:MM fails to assume next day
X-Send-Pr-Version: www-1.0

>Number:         53986
>Category:       bin
>Synopsis:       at(1) HH:MM fails to assume next day
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 16 16:30:00 +0000 2019
>Closed-Date:    Mon Mar 18 08:42:28 +0000 2019
>Last-Modified:  Mon Mar 18 08:42:28 +0000 2019
>Originator:     Christian Weisgerber
>Release:        
>Organization:
>Environment:
>Description:
I ran into an ancient at(1) bug on FreeBSD and OpenBSD, but NetBSD shares the same code.

The at(1) man page says:
at allows some moderately complex time specifications.  It accepts times of the form HHMM or HH:MM to run a job at a specific time of day.  (If that time is already past, the next day is assumed.)

This only works if the hour is past.  It fails if we are still within the same hour but the minutes are past.

>How-To-Repeat:
$ date
Sat Feb 16 16:56:28 CET 2019
$ echo dummy | at 15:00
Job 42 will be executed using /bin/sh
$ echo dummy | at 16:00
at: trying to travel back in time

>Fix:
Index: parsetime.c
===================================================================
RCS file: /cvsroot/src/usr.bin/at/parsetime.c,v
retrieving revision 1.19
diff -u -r1.19 parsetime.c
--- parsetime.c 18 Jan 2009 01:02:31 -0000      1.19
+++ parsetime.c 16 Feb 2019 16:13:56 -0000
@@ -405,7 +405,8 @@
         * if we've gone past that time - but if we're specifying a time plus
         * a relative offset, it's okay to bump things
         */
-       if ((sc_tokid == TOKEOF || sc_tokid == PLUS) && tm->tm_hour > hour) {
+       if ((sc_tokid == TOKEOF || sc_tokid == PLUS) && (tm->tm_hour > hour ||
+           (tm->tm_hour == hour && tm->tm_min > minute))) {
                tm->tm_mday++;
                tm->tm_wday++;
        }

>Release-Note:

>Audit-Trail:
From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53986 CVS commit: src/usr.bin/at
Date: Sat, 16 Feb 2019 17:56:57 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Sat Feb 16 17:56:57 UTC 2019

 Modified Files:
 	src/usr.bin/at: parsetime.c

 Log Message:
 PR bin/53986 from Christian Weisgerber

 Skip forward to tomorrow to run a command earlier in the current
 hour than now (as well as during an earlier hour of the day).


 To generate a diff of this commit:
 cvs rdiff -u -r1.19 -r1.20 src/usr.bin/at/parsetime.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: kre@NetBSD.org
State-Changed-When: Tue, 12 Mar 2019 23:58:52 +0000
State-Changed-Why:
The correction you requested was made a few weeks ago in NetBSD HEAD.
Is that sufficient to resolve this issue?


From: Christian Weisgerber <naddy@mips.inka.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/53986 (at(1) HH:MM fails to assume next day)
Date: Sun, 17 Mar 2019 18:53:51 +0100

 kre@NetBSD.org:

 > The correction you requested was made a few weeks ago in NetBSD HEAD.
 > Is that sufficient to resolve this issue?

 Yes, as far as I am concerned.

 -- 
 Christian "naddy" Weisgerber                          naddy@mips.inka.de

State-Changed-From-To: feedback->closed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Mon, 18 Mar 2019 08:42:28 +0000
State-Changed-Why:
Submitter confirms that problem is fixed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.