Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Mar 2008 18:50:30 +0100 (CET)
From:      "Frank W. Josellis" <frank@dynamical-systems.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   standards/121921: [patch] Add leap second support to at(1), atrun(8)
Message-ID:  <200803201750.m2KHoUbw002145@pollux.senax.net>
Resent-Message-ID: <200803201800.m2KI02aG013757@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         121921
>Category:       standards
>Synopsis:       [patch] Add leap second support to at(1), atrun(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 20 18:00:02 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Frank W. Josellis
>Release:        FreeBSD 5.5-STABLE i386
>Organization:
>Environment:
System: FreeBSD pollux.senax.net 5.5-STABLE FreeBSD 5.5-STABLE #21: Fri Feb 15 15:23:21 CET 2008 root@pollux.senax.net:/usr/obj/usr/src/sys/POLLUX i386


	
>Description:
The at(1) and atrun(8) commands make use of a timestamp format which can
be described as ``minutes since the Epoch''. For a given time_t variable t 
this value is determined by integer division t/60.  Conversely, minutes are
reverted to seconds by a factor 60. This is only suitable for a POSIX-style
system time where every minute has exactly 60 seconds. On a system with 
support for true UTC this approach gives undesired side effects. However,
this can easily be avoided by using the functionality of time2posix(3) and 
posix2time(3) as shown in the patch below. 

I don't see any reason why at/atrun should just support POSIX-style time. 
As a matter of fact, POSIX time is a poor concept which violates the
standards of civil timekeeping. Nonetheless, a patch doesn't hurt on
sytems where POSIX-style system time is mandatory. 


>How-To-Repeat:
	
>Fix:

	

--- at.patch begins here ---
diff -Nur src.orig/libexec/atrun/atrun.c src/libexec/atrun/atrun.c
--- src.orig/libexec/atrun/atrun.c	2007-06-15 14:01:53.000000000 +0200
+++ src/libexec/atrun/atrun.c	2008-03-20 16:32:55.000000000 +0100
@@ -526,7 +526,7 @@
 	if (sscanf(dirent->d_name,"%c%5lx%8lx",&queue,&jobno,&ctm) != 3)
 	    continue;
 
-	run_time = (time_t) ctm*60;
+	run_time = posix2time((time_t) ctm*60);
 
 	if ((S_IXUSR & buf.st_mode) && (run_time <=now)) {
 	    if (isupper(queue) && (strcmp(batch_name,dirent->d_name) > 0)) {
diff -Nur src.orig/usr.bin/at/at.c src/usr.bin/at/at.c
--- src.orig/usr.bin/at/at.c	2007-09-21 03:54:48.000000000 +0200
+++ src/usr.bin/at/at.c	2008-03-20 16:32:55.000000000 +0100
@@ -265,7 +265,7 @@
 	perr("cannot generate job number");
 
     sprintf(ppos, "%c%5lx%8lx", queue, 
-	    jobno, (unsigned long) (runtimer/60));
+	    jobno, (unsigned long) (time2posix(runtimer)/60));
 
     for(ap=ppos; *ap != '\0'; ap ++)
 	if (*ap == ' ')
@@ -507,7 +507,7 @@
 	if (atqueue && (queue != atqueue))
 	    continue;
 
-	runtimer = 60*(time_t) ctm;
+	runtimer = posix2time(60*(time_t) ctm);
 	runtime = *localtime(&runtimer);
 	strftime(timestr, TIMESIZE, "%+", &runtime);
 	if (first) {
--- at.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803201750.m2KHoUbw002145>