From owner-freebsd-standards Sun Dec 16 8: 0: 2 2001 Delivered-To: freebsd-standards@freebsd.org Received: from rwcrmhc53.attbi.com (rwcrmhc53.attbi.com [204.127.198.39]) by hub.freebsd.org (Postfix) with ESMTP id DDB5137B41C for ; Sun, 16 Dec 2001 07:59:59 -0800 (PST) Received: from attbi.com ([12.237.33.57]) by rwcrmhc53.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20011216155959.VMU10701.rwcrmhc53.attbi.com@attbi.com> for ; Sun, 16 Dec 2001 15:59:59 +0000 Message-ID: <3C1CC516.9AA6914B@attbi.com> Date: Sun, 16 Dec 2001 10:00:22 -0600 From: Joe Halpin X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: en MIME-Version: 1.0 To: "standards@FreeBSD.ORG" Subject: at utility and time format Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I don't have a copy of POSIX handy, so I've been going by the Single Unix Specification V2 (http://www.rdg.opengroup.org/onlinepubs/7908799/index.html), which I understand includes POSIX whole. I'd appreciate it if someone with a copy of POSIX could verify something for me though. I'm working on adding the -t option to the at utility. The SUS says that -t accepts a time spec in the same format as the touch utility. However, the touch utility described by the SUS (http://www.rdg.opengroup.org/onlinepubs/7908799/xcu/touch.html) has a different time format than the FreeBSD version of touch. It wants -t time Use the specified time instead of the current time. The option-argument will be a decimal number of the form: [[CC]YY]MMDDhhmm[.SS] where each two digits represents the following: MMThe month of the year [01-12]. DDThe day of the month [01-31]. hhThe hour of the day [00-23]. mmThe minute of the hour [00-59]. CCThe first two digits of the year (the century). YYThe second two digits of the year. SSThe second of the minute [00-61]. I'm looking to verify that this is the same as POSIX, because adding seconds to at will be a much bigger job than just allowing a different format. What I was planning on doing was to just convert the -t format into something at already understands, and then pass that on. If seconds are in the picture, then I'll have to figure out how to support them. Thanks Joe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sun Dec 16 10:28:37 2001 Delivered-To: freebsd-standards@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id 4A43F37B417 for ; Sun, 16 Dec 2001 10:28:36 -0800 (PST) Received: from attbi.com ([12.237.33.57]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20011216182831.DSRX403.rwcrmhc52.attbi.com@attbi.com> for ; Sun, 16 Dec 2001 18:28:31 +0000 Message-ID: <3C1CE7E6.F0D7B984@attbi.com> Date: Sun, 16 Dec 2001 12:28:54 -0600 From: Joe Halpin X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: en MIME-Version: 1.0 To: "standards@FreeBSD.ORG" Subject: Re: at utility and time format References: <3C1CC516.9AA6914B@attbi.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I just realized that my last question contains an inaccuracy. I probably should confess that I normally work on a Linux box, and telnet into my FreeBSD machine. When I made the comment about what FreeBSD's touch requires, I was reading the man page in the wrong window, so I got the Linux man page by mistake. Sorry. However, I'm still wondering about this. Given that atrun only gets called every five minutes, what's the point of trying to support seconds? On the other hand, the current version of at doesn't allow for a year specification either, so I'll still have to work that in. I'm trying to get a better understanding of how that all works, but I'd appreciate opinions about whether I need to work seconds into the mix somehow. Thanks Joe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Dec 17 4:25:33 2001 Delivered-To: freebsd-standards@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id D9BDE37B41A for ; Mon, 17 Dec 2001 04:25:19 -0800 (PST) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.6/8.11.2) id fBHCOWS84216; Mon, 17 Dec 2001 14:24:32 +0200 (EET) (envelope-from ru) Date: Mon, 17 Dec 2001 14:24:32 +0200 From: Ruslan Ermilov To: "Andrey A. Chernov" Cc: Guido van Rooij , standards@FreeBSD.org Subject: Re: Recent POSIX.1-2001 implementation of strtol(3) breaks POLA (was: Re: cvs commit: src/etc/periodic/security 550.ipfwlimit 650.ip6fwlimit) Message-ID: <20011217142432.A83850@sunbay.com> References: <200112140858.fBE8wL596075@freefall.freebsd.org> <20011214115711.A34932@gvr.gvr.org> <20011214135243.B64853@sunbay.com> <20011214125438.A35615@gvr.gvr.org> <20011214142928.A69958@sunbay.com> <20011214154506.A79266@sunbay.com> <20011214230229.GA14380@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20011214230229.GA14380@nagual.pp.ru> User-Agent: Mutt/1.3.23i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, Dec 15, 2001 at 02:02:30AM +0300, Andrey A. Chernov wrote: > On Fri, Dec 14, 2001 at 15:45:07 +0200, Ruslan Ermilov wrote: > > > > In NetBSD and OpenBSD, strtol() doesn't set errno to EINVAL if the > > subject is empty. In UnixWare, it does, but atoi(3), which is > > implemented there using strtol() too, has a special hack to not > > set errno to EINVAL in this case, and this is a documented > > behavior. > > It seems that UnixWare does it in the semi-right way, but I don't think > POSIX allows special atoi() errno handling, it just say that it is fullly > equivalent to strtol() call. > No, it says "except for error handling". > > Linux's strtol() doesn't set errno to EINVAL too, but their > > test(1) utility works like this: > > > > $ /usr/bin/test "" -eq 0 > > /usr/bin/test: integer expression expected before -eq > > It seems that Linux test does it in the right way. Good news is that > strtol()'s POSIX change find the bug. > I checked "test" article in POSIX, and the latter doesn't say anything about this case. Obviously, "" shouldn't be treated as a zero. > > What's really broken in FreeBSD now is that the following: > > > > errno = 0; > > atoi(""); > > > > sets errno to [EINVAL], while it shouldn't. I think this > > may break many things. > > I don't think so, just otherwise, it find the bugs in many things. If > application is smart enough to handle errno, it MUST assume the POSIX > "MAY" clause CAN happens. > Agreed. > > So while the current behavior of strtol() is accepted by > > POSIX, I suggest that we don't return [EINVAL] for an > > empty subject case, as it's not required, and as could > > be seen from the above in against POLA. This should > > fix it. > > I disagree. Look at this from different perspective. F.e. 'test' will > remains unfixed without strtol()'s change forever. strtol() position > itself as input checking function and already does it in some ways. Adding > yet one way seems logical, really " " is not "0". Moreover, if POSIX says > MAY, any application which assumes otherwise is broken in portability > sense and must be fixed. I mean 'test' or anything else will be found. > OK, I now agree with you; treating "" as zero is bogus, and should be fixed whenever hit. Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Dec 17 10:55:19 2001 Delivered-To: freebsd-standards@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id E249C37C2A5 for ; Mon, 17 Dec 2001 10:53:14 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.11.4/8.11.4) id fBHIrBb35950; Mon, 17 Dec 2001 13:53:11 -0500 (EST) (envelope-from wollman) Date: Mon, 17 Dec 2001 13:53:11 -0500 (EST) From: Garrett Wollman Message-Id: <200112171853.fBHIrBb35950@khavrinen.lcs.mit.edu> To: Joe Halpin Cc: "standards@FreeBSD.ORG" Subject: Re: at utility and time format In-Reply-To: <3C1CE7E6.F0D7B984@attbi.com> References: <3C1CC516.9AA6914B@attbi.com> <3C1CE7E6.F0D7B984@attbi.com> Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG < said: > However, I'm still wondering about this. Given that atrun only gets > called every five minutes, what's the point of trying to support > seconds? POSIX provides sufficient scheduling weasel-words to allow for rounding up to the nearest five-minute boundary. All it's requiring you is to accept the format, not actually schedule the event so precisely. -GAWollman -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Dec 18 19:38:25 2001 Delivered-To: freebsd-standards@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id 30DEE37B417 for ; Tue, 18 Dec 2001 19:38:13 -0800 (PST) Received: from attbi.com ([12.237.33.57]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20011219033811.BDQA6450.rwcrmhc52.attbi.com@attbi.com> for ; Wed, 19 Dec 2001 03:38:11 +0000 Message-ID: <3C200BBA.9D26ED93@attbi.com> Date: Tue, 18 Dec 2001 21:38:34 -0600 From: Joe Halpin X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: en MIME-Version: 1.0 To: "standards@FreeBSD.ORG" Subject: at utility changes Content-Type: multipart/mixed; boundary="------------1404D5B0AB57096BE52ABD8D" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --------------1404D5B0AB57096BE52ABD8D Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I'm attaching the diff file for the changes I made to the at utility, in order to add the -r and -t options. Thanks to Mike for his help in getting my head into the procedures. Joe --------------1404D5B0AB57096BE52ABD8D Content-Type: text/plain; charset=us-ascii; name="at.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="at.diff" ? at/at ? at/at.1 ? at/at.1.gz ? at/newcode Index: at/at.c =================================================================== RCS file: /home/ncvs/src/usr.bin/at/at.c,v retrieving revision 1.23 diff -u -r1.23 at.c --- at/at.c 2001/12/10 21:13:01 1.23 +++ at/at.c 2001/12/19 03:30:02 @@ -121,6 +121,8 @@ static void writefile(time_t runtimer, char queue); static void list_jobs(void); static long nextjob(void); +static time_t ttime(const char *argtime); +static inline int checkint(const char *numstr); /* Signal catching functions */ @@ -592,6 +594,134 @@ } } /* delete_jobs */ + +static inline int checkint(const char *numstr) +{ + if((!isdigit(numstr[0])) || (!isdigit(numstr[1]))) + panic("non-numeric character(s) in date"); + + return (int) strtol(numstr, 0, 10); +} + +static time_t ttime(const char *argtime) +{ + /* + * -t format: [[CC]YY]MMDDhhmm[.SS] + */ + + time_t nowtimer, runtimer; + struct tm nowtime, runtime; + int arglen; + char *cp; + char workstr[16]; + int C = -1; + int Y = -1; + int M = -1; + int D = -1; + int h = -1; + int m = -1; + int s = 0; + + arglen = strlen(argtime); + if(arglen < 8 || arglen > 15) + panic("Invalid time format"); + + strcpy(workstr, argtime); + if((cp = strchr(workstr, '.')) != NULL) + ++cp; + + if(cp) { + if(arglen < 11) + panic("invalid time format"); + + s = checkint(cp); *(--cp) = 0; cp -= 2; + m = checkint(cp); *cp = 0; cp -= 2; + h = checkint(cp); *cp = 0; cp -= 2; + D = checkint(cp); *cp = 0; cp -= 2; + M = checkint(cp); *cp = 0; + + if(arglen == 12) + panic("invalid time format"); + + if(arglen >= 13) { + cp -= 2; + Y = checkint(cp); + *cp = 0; + } + + if(arglen == 14) + panic("invalid time format"); + + if(arglen == 15) { + cp -= 2; + C = checkint(cp); + } + } + + else { + if(arglen < 8) + panic("invalid date format"); + + cp = workstr + arglen - 2; + m = checkint(cp); *cp = 0; cp -= 2; + h = checkint(cp); *cp = 0; cp -= 2; + D = checkint(cp); *cp = 0; cp -= 2; + M = checkint(cp); *cp = 0; + + if(arglen == 9) + panic("invalid time format"); + + if(arglen >= 10) { + cp -= 2; + Y = checkint(cp); + *cp = 0; + } + + if(arglen == 11) + panic("invalid time format"); + + if(arglen == 12) { + cp -= 2; + C = checkint(cp); + } + } + + if(Y > -1) { + /* Since we're past Y2K now, add 100 to the year (or whatever the + * century given is). + */ + if(C > -1) + Y = ((C * 100) + Y) - 1900; + else + Y += 100; + } + + nowtimer = time(NULL); + nowtime = *localtime(&nowtimer); + + runtime = nowtime; + runtime.tm_sec = s; + runtime.tm_min = m; + runtime.tm_hour = h; + runtime.tm_mday = D; + runtime.tm_mon = M - 1; + runtime.tm_year = Y >= 0 ? Y : runtime.tm_year; + runtime.tm_wday = -1; + runtime.tm_yday = -1; + runtime.tm_isdst = -1; + + runtimer = mktime(&runtime); + + if(runtimer < 0) + panic("invalid time"); + + if(nowtimer > runtimer) + panic("trying to travel back in time"); + + return runtimer; +} + + int main(int argc, char **argv) { @@ -601,9 +731,9 @@ char *pgm; int program = AT; /* our default program */ - const char *options = "q:f:mvldbVc";/* default options for at */ + const char *options = "q:f:t:mvlrdbVc";/* default options for at */ int disp_version = 0; - time_t timer; + time_t timer = (time_t) -1; RELINQUISH_PRIVS @@ -660,6 +790,9 @@ break; case 'd': + warnx("-d is deprecated; you should use -r in the future"); + /* fall through to 'r' */ + case 'r': if (program != AT) usage(); @@ -667,6 +800,12 @@ options = "V"; break; + case 't': + program = AT; + options = "V"; + timer = ttime(optarg); + break; + case 'l': if (program != AT) usage(); @@ -729,7 +868,13 @@ break; case AT: - timer = parsetime(argc, argv); + /* + * If timer is > -1, then the user gave the time with -t. + * In that case, it's already been set. If not, set it now. + */ + if(timer == (time_t) -1) + timer = parsetime(argc, argv); + if (atverify) { struct tm *tm = localtime(&timer); Index: at/at.man =================================================================== RCS file: /home/ncvs/src/usr.bin/at/at.man,v retrieving revision 1.22 diff -u -r1.22 at.man --- at/at.man 2001/11/20 15:43:25 1.22 +++ at/at.man 2001/12/19 03:30:03 @@ -115,6 +115,8 @@ and to run a job at 1am tomorrow, you would do .Nm at Ar 1am tomorrow . .Pp +You may also use the POSIX time format (see -t argument) +.Pp For both .Nm and @@ -214,7 +216,7 @@ .Nm atq . .It Fl d Is an alias for -.Nm atrm . +.Nm atrm (this option is deprecated; use -r instead) . .It Fl b Is an alias for .Nm batch . @@ -225,6 +227,12 @@ shows the time the job will be executed. .It Fl c Cat the jobs listed on the command line to standard output. +.It Fl r +Remove specified job(s). +.It Fl t +Give the job time using the POSIX time format, which is described in the +touch(1) man page. +Note that giving a date past 2038 may not work on 32-bit systems. .El .Sh FILES .Bl -tag -width _ATJOB_DIR/_LOCKFILE -compact @@ -272,3 +280,5 @@ .An Thomas Koenig Aq ig25@rz.uni-karlsruhe.de . The time parsing routines are by .An David Parsons Aq orc@pell.chi.il.us . +and +.An Joe Halpin Aq joe.halpin@attbi.com . --------------1404D5B0AB57096BE52ABD8D-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message