From owner-freebsd-audit Sun Mar 17 2:58:50 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mass.dis.org (dhcp45-24.dis.org [216.240.45.24]) by hub.freebsd.org (Postfix) with ESMTP id 9B84237B404; Sun, 17 Mar 2002 02:58:45 -0800 (PST) Received: from mass.dis.org (localhost [127.0.0.1]) by mass.dis.org (8.11.6/8.11.6) with ESMTP id g2HAw1920599; Sun, 17 Mar 2002 02:58:01 -0800 (PST) (envelope-from msmith@mass.dis.org) Message-Id: <200203171058.g2HAw1920599@mass.dis.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Maxim Sobolev Cc: hackers@FreeBSD.org, audit@FreeBSD.org, re@FreeBSD.org Subject: Re: Extending loader(8) for loading kerels/modules split across several disks In-reply-to: Your message of "Fri, 15 Mar 2002 21:12:15 +0200." <3C92478F.2B7C11DB@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 17 Mar 2002 02:58:01 -0800 From: Michael Smith Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > At any rate, my key point is that the splitting should be invisible, and > > *definitely* not pushed up into the loader. > > Ok, attached is the path, which does exactly what described. Please > review and if there are no objections I would like to commit it > shortly, so that our re@ team would be able to consider it for the > forthcoming 5.0-DP1 release. Sorry that it's taken so long to get you a reply - this is exactly what I had in mind, thanks! -- To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public. - Theodore Roosevelt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Mar 18 4: 8: 3 2002 Delivered-To: freebsd-audit@freebsd.org Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by hub.freebsd.org (Postfix) with ESMTP id ACDDD37B400; Mon, 18 Mar 2002 04:07:58 -0800 (PST) Received: from bremen.shuttle.de (localhost [127.0.0.1]) by bremen.shuttle.de (Postfix) with ESMTP id 4231817D54; Mon, 18 Mar 2002 13:07:55 +0100 (CET) Received: (from uucp@localhost) by bremen.shuttle.de (8.12.1/8.12.1/Debian -5) with UUCP id g2IC7tah022068; Mon, 18 Mar 2002 13:07:55 +0100 Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.12.2/8.11.6) id g2IC94t0003893; Mon, 18 Mar 2002 13:09:04 +0100 (CET) (envelope-from schweikh) Date: Mon, 18 Mar 2002 13:09:04 +0100 From: Jens Schweikhardt To: freebsd-audit@freebsd.org Cc: joerg@freebsd.org Subject: crontab changes for PR bin/22612; please comment Message-ID: <20020318130904.A3869@schweikhardt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG hello, world\n please comment on this patch (slightly different from the one in the PR http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/22612) Currently, checking for modification of the tmp file just looks at the mtime and gives a false "no modification" if the edit took less than 1 second. This is solved by simply comparing the whole struct stat. Regards, Jens Index: crontab.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/cron/crontab/crontab.c,v retrieving revision 1.18 diff -u -r1.18 crontab.c --- crontab.c 9 Jul 2001 09:23:57 -0000 1.18 +++ crontab.c 18 Mar 2002 11:51:13 -0000 @@ -44,6 +44,7 @@ # include #endif +#include #define NHEADER_LINES 3 @@ -304,8 +305,7 @@ char n[MAX_FNAME], q[MAX_TEMPSTR], *editor; FILE *f; int ch, t, x; - struct stat statbuf, fsbuf; - time_t mtime; + struct stat fsbuf, statbuf; WAIT_T waiter; PID_T pid, xpid; mode_t um; @@ -380,7 +380,6 @@ } if (statbuf.st_dev != fsbuf.st_dev || statbuf.st_ino != fsbuf.st_ino) errx(ERROR_EXIT, "temp file must be edited in place"); - mtime = statbuf.st_mtime; if ((!(editor = getenv("VISUAL"))) && (!(editor = getenv("EDITOR"))) @@ -446,7 +445,11 @@ } if (statbuf.st_dev != fsbuf.st_dev || statbuf.st_ino != fsbuf.st_ino) errx(ERROR_EXIT, "temp file must be edited in place"); - if (mtime == statbuf.st_mtime) { + /* + * Compare the whole struct stat instead of just the mtime; this + * avoids ugly #ifdefs because struct stat changes with _POSIX_SOURCE. + */ + if (memcmp(&fsbuf, &statbuf, sizeof(fsbuf)) == 0) { warnx("no changes made to crontab"); goto remove; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Mar 18 13: 9:21 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id BDC8A37B4BC; Mon, 18 Mar 2002 13:08:08 -0800 (PST) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.12.1/8.12.1) with ESMTP id g2IL81C8158380; Mon, 18 Mar 2002 16:08:02 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: <20020318130904.A3869@schweikhardt.net> References: <20020318130904.A3869@schweikhardt.net> Date: Mon, 18 Mar 2002 16:08:04 -0500 To: Jens Schweikhardt , freebsd-audit@FreeBSD.ORG From: Garance A Drosihn Subject: Re: crontab changes for PR bin/22612; please comment Cc: joerg@FreeBSD.ORG Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At 1:09 PM +0100 3/18/02, Jens Schweikhardt wrote: >hello, world\n > >please comment on this patch (slightly different from the >one in the PR >http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/22612) > >Currently, checking for modification of the tmp file just >looks at the mtime and gives a false "no modification" if >the edit took less than 1 second. This is solved by simply >comparing the whole struct stat. I don't think you should blindly compare the entire struct. You don't know what fields are in there, so you don't know if some field has changed even though the contents of the file has not changed. If you do try this, you should at least zero out the entire struct-stat before each call to stat(), just in case there are unused fields in the record. Just MO. Stupid brain-dead alternative fix: Create the file. stat the file. sleep a second. *Then* open the file in the user's editor. Any change that they make will have to have been done more than a second later. -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 5:41:49 2002 Delivered-To: freebsd-audit@freebsd.org Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.139.170]) by hub.freebsd.org (Postfix) with ESMTP id 59DC637B426 for ; Wed, 20 Mar 2002 05:40:28 -0800 (PST) Received: (from uucp@localhost) by storm.FreeBSD.org.uk (8.11.6/8.11.6) with UUCP id g2KDeQG46177 for audit@freebsd.org; Wed, 20 Mar 2002 13:40:26 GMT (envelope-from root@grimreaper.grondar.za) Received: from grimreaper (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.2/8.12.2) with ESMTP id g2KDZL4j025080 for ; Wed, 20 Mar 2002 13:35:21 GMT (envelope-from root@grimreaper.grondar.za) Message-Id: <200203201335.g2KDZL4j025080@grimreaper.grondar.org> To: audit@freebsd.org Subject: Make find(1) standalone - commit candidate From: markm@freebsd.org Date: Wed, 20 Mar 2002 13:35:20 +0000 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Index: Makefile =================================================================== RCS file: /home/ncvs/src/usr.bin/find/Makefile,v retrieving revision 1.12 diff -u -d -r1.12 Makefile --- Makefile 27 Feb 2002 17:57:00 -0000 1.12 +++ Makefile 20 Mar 2002 09:36:58 -0000 @@ -2,9 +2,7 @@ # $FreeBSD: src/usr.bin/find/Makefile,v 1.12 2002/02/27 17:57:00 dwmalone Exp $ PROG= find -SRCS= find.c function.c ls.c main.c misc.c operator.c option.c getdate.y -CLEANFILES+= getdate.c y.tab.h -CFLAGS+= -I${.CURDIR}/../../gnu/usr.bin/cvs/lib -DHAVE_CONFIG_H -.PATH: ${.CURDIR}/../../contrib/cvs/lib +SRCS= find.c function.c ls.c main.c misc.c operator.c option.c parsedate.y +CLEANFILES+= parsedate.c y.tab.h .include Index: extern.h =================================================================== RCS file: /home/ncvs/src/usr.bin/find/extern.h,v retrieving revision 1.16 diff -u -d -r1.16 extern.h --- extern.h 20 Mar 2002 10:32:05 -0000 1.16 +++ extern.h 20 Mar 2002 10:50:45 -0000 @@ -43,6 +43,8 @@ PLAN *not_squish(PLAN *); PLAN *or_squish(PLAN *); PLAN *paren_squish(PLAN *); +struct timeb; +time_t parsedate(char *, struct timeb *); struct stat; void printlong(char *, char *, struct stat *); int queryuser(char **); Index: function.c =================================================================== RCS file: /home/ncvs/src/usr.bin/find/function.c,v retrieving revision 1.37 diff -u -d -r1.37 function.c --- function.c 20 Mar 2002 10:32:05 -0000 1.37 +++ function.c 20 Mar 2002 10:51:23 -0000 @@ -69,7 +69,6 @@ static long long find_parsenum(PLAN *, const char *, char *, char *); static long long find_parsetime(PLAN *, const char *, char *); static char *nextarg(OPTION *, char ***); -time_t get_date(char *, struct timeb *); #define COMPARE(a, b) do { \ switch (plan->flags & F_ELG_MASK) { \ @@ -999,7 +998,7 @@ new = palloc(option); /* compare against what */ if (option->flags & F_TIME2_T) { - new->t_data = get_date(fn_or_tspec, (struct timeb *) 0); + new->t_data = parsedate(fn_or_tspec, (struct timeb *) 0); if (new->t_data == (time_t) -1) errx(1, "Can't parse date/time: %s", fn_or_tspec); } else { Index: parsedate.y =================================================================== RCS file: parsedate.y diff -N parsedate.y --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ parsedate.y 20 Mar 2002 12:00:46 -0000 @@ -0,0 +1,906 @@ +%{ +/* $Id: parsedate.y,v 1.9.2.1 2000/12/26 08:39:49 kondou Exp $ +** +** Originally written by Steven M. Bellovin while +** at the University of North Carolina at Chapel Hill. Later tweaked by +** a couple of people on Usenet. Completely overhauled by Rich $alz +** and Jim Berets in August, 1990. +** Further revised (removed obsolete constructs and cleaned up timezone +** names) in August, 1991, by Rich. Paul Eggert +** helped in September, 1992. +** +** This grammar has six shift/reduce conflicts. +** +** This code is in the public domain and has no copyright. +*/ +/* SUPPRESS 530 *//* Empty body for statement */ +/* SUPPRESS 593 on yyerrlab *//* Label was not used */ +/* SUPPRESS 593 on yynewstate *//* Label was not used */ +/* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */ + +#include +#include +#include +#include +#include + +#include "find.h" + +#define CTYPE(isXXXXX, c) (isXXXXX((c))) +#define SIZEOF(array) (sizeof array / sizeof array[0]) +#define ENDOF(array) (&array[SIZEOF(array)]) + +typedef const char *STRING; +typedef struct timeb TIMEINFO; + +#define yylhs date_yylhs +#define yylen date_yylen +#define yydefred date_yydefred +#define yydgoto date_yydgoto +#define yysindex date_yysindex +#define yyrindex date_yyrindex +#define yygindex date_yygindex +#define yytable date_yytable +#define yycheck date_yycheck +#define yyparse date_parse +#define yylex date_lex +#define yyerror date_error + + +static int date_lex(void); + + + /* See the LeapYears table in Convert. */ +#define EPOCH 1970 +#define END_OF_TIME 2038 + /* Constants for general time calculations. */ +#define DST_OFFSET 1 +#define SECSPERDAY (24L * 60L * 60L) + /* Readability for TABLE stuff. */ +#define HOUR(x) (x * 60) + +#define LPAREN '(' +#define RPAREN ')' +#define IS7BIT(x) ((unsigned int)(x) < 0200) + + +/* +** An entry in the lexical lookup table. +*/ +typedef struct _TABLE { + STRING name; + int type; + time_t value; +} TABLE; + +/* +** Daylight-savings mode: on, off, or not yet known. +*/ +typedef enum _DSTMODE { + DSTon, DSToff, DSTmaybe +} DSTMODE; + +/* +** Meridian: am, pm, or 24-hour style. +*/ +typedef enum _MERIDIAN { + MERam, MERpm, MER24 +} MERIDIAN; + + +/* +** Global variables. We could get rid of most of them by using a yacc +** union, but this is more efficient. (This routine predates the +** yacc %union construct.) +*/ +static char *yyInput; +static DSTMODE yyDSTmode; +static int yyHaveDate; +static int yyHaveRel; +static int yyHaveTime; +static time_t yyTimezone; +static time_t yyDay; +static time_t yyHour; +static time_t yyMinutes; +static time_t yyMonth; +static time_t yySeconds; +static time_t yyYear; +static MERIDIAN yyMeridian; +static time_t yyRelMonth; +static time_t yyRelSeconds; + + +extern struct tm *localtime(); + +static void date_error(); +%} + +%union { + time_t Number; + enum _MERIDIAN Meridian; +} + +%token tDAY tDAYZONE tMERIDIAN tMONTH tMONTH_UNIT tSEC_UNIT tSNUMBER +%token tUNUMBER tZONE + +%type tDAYZONE tMONTH tMONTH_UNIT tSEC_UNIT +%type tSNUMBER tUNUMBER tZONE numzone zone +%type tMERIDIAN o_merid + +%% + +spec : /* NULL */ + | spec item + ; + +item : time { + yyHaveTime++; +#if defined(lint) + /* I am compulsive about lint natterings... */ + if (yyHaveTime == -1) { + YYERROR; + } +#endif /* defined(lint) */ + } + | time zone { + yyHaveTime++; + yyTimezone = $2; + } + | date { + yyHaveDate++; + } + | rel { + yyHaveRel = 1; + } + ; + +time : tUNUMBER o_merid { + if ($1 < 100) { + yyHour = $1; + yyMinutes = 0; + } + else { + yyHour = $1 / 100; + yyMinutes = $1 % 100; + } + yySeconds = 0; + yyMeridian = $2; + } + | tUNUMBER ':' tUNUMBER o_merid { + yyHour = $1; + yyMinutes = $3; + yySeconds = 0; + yyMeridian = $4; + } + | tUNUMBER ':' tUNUMBER numzone { + yyHour = $1; + yyMinutes = $3; + yyTimezone = $4; + yyMeridian = MER24; + yyDSTmode = DSToff; + } + | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid { + yyHour = $1; + yyMinutes = $3; + yySeconds = $5; + yyMeridian = $6; + } + | tUNUMBER ':' tUNUMBER ':' tUNUMBER numzone { + yyHour = $1; + yyMinutes = $3; + yySeconds = $5; + yyTimezone = $6; + yyMeridian = MER24; + yyDSTmode = DSToff; + } + ; + +zone : tZONE { + $$ = $1; + yyDSTmode = DSToff; + } + | tDAYZONE { + $$ = $1; + yyDSTmode = DSTon; + } + | tZONE numzone { + /* Only allow "GMT+300" and "GMT-0800" */ + if ($1 != 0) { + YYABORT; + } + $$ = $2; + yyDSTmode = DSToff; + } + | numzone { + $$ = $1; + yyDSTmode = DSToff; + } + ; + +numzone : tSNUMBER { + int i; + + /* Unix and GMT and numeric timezones -- a little confusing. */ + if ($1 < 0) { + /* Don't work with negative modulus. */ + $1 = -$1; + if ($1 > 9999 || (i = $1 % 100) >= 60) { + YYABORT; + } + $$ = ($1 / 100) * 60 + i; + } + else { + if ($1 > 9999 || (i = $1 % 100) >= 60) { + YYABORT; + } + $$ = -(($1 / 100) * 60 + i); + } + } + ; + +date : tUNUMBER '/' tUNUMBER { + yyMonth = $1; + yyDay = $3; + } + | tUNUMBER '/' tUNUMBER '/' tUNUMBER { + if ($1 > 100) { + /* assume YYYY/MM/DD format, so need not to add 1900 */ + if ($1 > 999) { + yyYear = $1; + } else { + yyYear = 1900 + $1; + } + yyMonth = $3; + yyDay = $5; + } + else { + /* assume MM/DD/YY* format */ + yyMonth = $1; + yyDay = $3; + if ($5 > 999) { + /* assume year is YYYY format, so need not to add 1900 */ + yyYear = $5; + } else if ($5 < 100) { + /* assume year is YY format, so need to add 1900 */ + yyYear = $5 + (yyYear / 100 + (yyYear % 100 - $5) / 50) * 100; + } else { + yyYear = 1900 + $5; + } + } + } + | tMONTH tUNUMBER { + yyMonth = $1; + yyDay = $2; + } + | tMONTH tUNUMBER ',' tUNUMBER { + yyMonth = $1; + yyDay = $2; + if ($4 > 999) { + /* assume year is YYYY format, so need not to add 1900 */ + yyYear = $4; + } else if ($4 < 100) { + /* assume year is YY format, so need to add 1900 */ + yyYear = $4 + (yyYear / 100 + (yyYear % 100 - $4) / 50) * 100; + } else { + yyYear = 1900 + $4; + } + } + | tUNUMBER tMONTH { + yyDay = $1; + yyMonth = $2; + } + | tUNUMBER tMONTH tUNUMBER { + yyDay = $1; + yyMonth = $2; + if ($3 > 999) { + /* assume year is YYYY format, so need not to add 1900 */ + yyYear = $3; + } else if ($3 < 100) { + /* assume year is YY format, so need to add 1900 */ + yyYear = $3 + (yyYear / 100 + (yyYear % 100 - $3) / 50) * 100; + } else { + yyYear = 1900 + $3; + } + } + | tDAY ',' tUNUMBER tMONTH tUNUMBER { + yyDay = $3; + yyMonth = $4; + if ($5 > 999) { + /* assume year is YYYY format, so need not to add 1900 */ + yyYear = $5; + } else if ($5 < 100) { + /* assume year is YY format, so need to add 1900 */ + yyYear = $5 + (yyYear / 100 + (yyYear % 100 - $5) / 50) * 100; + } else { + yyYear = 1900 + $5; + } + } + ; + +rel : tSNUMBER tSEC_UNIT { + yyRelSeconds += $1 * $2; + } + | tUNUMBER tSEC_UNIT { + yyRelSeconds += $1 * $2; + } + | tSNUMBER tMONTH_UNIT { + yyRelMonth += $1 * $2; + } + | tUNUMBER tMONTH_UNIT { + yyRelMonth += $1 * $2; + } + ; + +o_merid : /* NULL */ { + $$ = MER24; + } + | tMERIDIAN { + $$ = $1; + } + ; + +%% + +/* Month and day table. */ +static TABLE MonthDayTable[] = { + { "january", tMONTH, 1 }, + { "february", tMONTH, 2 }, + { "march", tMONTH, 3 }, + { "april", tMONTH, 4 }, + { "may", tMONTH, 5 }, + { "june", tMONTH, 6 }, + { "july", tMONTH, 7 }, + { "august", tMONTH, 8 }, + { "september", tMONTH, 9 }, + { "october", tMONTH, 10 }, + { "november", tMONTH, 11 }, + { "december", tMONTH, 12 }, + /* The value of the day isn't used... */ + { "sunday", tDAY, 0 }, + { "monday", tDAY, 0 }, + { "tuesday", tDAY, 0 }, + { "wednesday", tDAY, 0 }, + { "thursday", tDAY, 0 }, + { "friday", tDAY, 0 }, + { "saturday", tDAY, 0 }, +}; + +/* Time units table. */ +static TABLE UnitsTable[] = { + { "year", tMONTH_UNIT, 12 }, + { "month", tMONTH_UNIT, 1 }, + { "week", tSEC_UNIT, 7 * 24 * 60 * 60 }, + { "day", tSEC_UNIT, 1 * 24 * 60 * 60 }, + { "hour", tSEC_UNIT, 60 * 60 }, + { "minute", tSEC_UNIT, 60 }, + { "min", tSEC_UNIT, 60 }, + { "second", tSEC_UNIT, 1 }, + { "sec", tSEC_UNIT, 1 }, +}; + +/* Timezone table. */ +static TABLE TimezoneTable[] = { + { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ + { "ut", tZONE, HOUR( 0) }, /* Universal */ + { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */ + { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */ + { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */ + { "wet", tZONE, HOUR( 0) }, /* Western European */ + { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ + { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */ + { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */ + { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */ + { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */ + { "est", tZONE, HOUR( 5) }, /* Eastern Standard */ + { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */ + { "cst", tZONE, HOUR( 6) }, /* Central Standard */ + { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */ + { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */ + { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */ + { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */ + { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */ + { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */ + { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */ + { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */ + { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */ + { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */ + { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */ + { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */ + { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */ + { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */ + { "mez", tZONE, -HOUR(1) }, /* Middle European */ + { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */ + { "cet", tZONE, -HOUR(1) }, /* Central European */ + { "met", tZONE, -HOUR(1) }, /* Middle European */ + { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */ + { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */ + { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */ + { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */ + { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */ + { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */ + { "cct", tZONE, -HOUR(8) }, /* China Coast */ + { "jst", tZONE, -HOUR(9) }, /* Japan Standard */ + { "kst", tZONE, -HOUR(9) }, /* Korean Standard */ + { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */ + { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */ + { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */ + { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */ + { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */ + { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ + { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ + + /* For completeness we include the following entries. */ +#if 0 + + /* Duplicate names. Either they conflict with a zone listed above + * (which is either more likely to be seen or just been in circulation + * longer), or they conflict with another zone in this section and + * we could not reasonably choose one over the other. */ + { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */ + { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */ + { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */ + { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */ + { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */ + { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */ + { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */ + { "cst", tZONE, HOUR( 5) }, /* Chile Standard */ + { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */ + { "ast", tZONE, HOUR( 5) }, /* Acre Standard */ + { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */ + { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */ + { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */ + { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */ + { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */ + { "sst", tZONE, HOUR(11) }, /* Samoa Standard */ + { "ist", tZONE, -HOUR(2) }, /* Israel Standard */ + { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */ + { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */ + { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */ + { "cst", tZONE, -HOUR(8) }, /* China Standard */ + { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */ + { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */ + + /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */ + { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */ + { "wat", tZONE, -HOUR(1) }, /* West Africa */ + { "at", tZONE, HOUR( 2) }, /* Azores */ + { "gst", tZONE, -HOUR(10) }, /* Guam Standard */ + { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */ + { "idlw", tZONE, HOUR(12) }, /* International Date Line West */ + { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */ + { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */ + { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */ + { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */ + { "fwt", tZONE, -HOUR(1) }, /* French Winter */ + { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */ + { "bt", tZONE, -HOUR(3) }, /* Baghdad */ + { "it", tZONE, -(HOUR(3)+30) }, /* Iran */ + { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */ + { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */ + { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */ + { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */ + { "nst", tZONE, -HOUR(7) }, /* North Sumatra */ + { "sst", tZONE, -HOUR(7) }, /* South Sumatra */ + { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */ + { "nzt", tZONE, -HOUR(12) }, /* New Zealand */ + { "idle", tZONE, -HOUR(12) }, /* International Date Line East */ + { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */ + { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */ + { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */ + { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */ +#endif /* 0 */ +}; + + + +static int +GetTimeInfo(TIMEINFO *Now) +{ + static time_t NextHour; + static long LastTzone; + struct tm *tm; + int secondsUntilNextHour; + struct timespec tv; + + /* Get the basic time. */ + if (gettimeofday(&tv, (struct timezone *) 0) == -1) + return -1; + Now->time = tv.tv_sec; + Now->millitm = tv.tv_nsec/1000; + + /* Now get the timezone if the last time < HH:00:00 <= now for some HH. */ + if (NextHour <= Now->time) { + tm = localtime(&Now->time); + if (tm == NULL) + return -1; + secondsUntilNextHour = 60 * (60 - tm->tm_min) - tm->tm_sec; + LastTzone = (0 - tm->tm_gmtoff) / 60; + NextHour = Now->time + secondsUntilNextHour; + } + Now->timezone = LastTzone; + return 0; +} + + +/* ARGSUSED */ +static void +date_error(s) + char *s; +{ + /* NOTREACHED */ +} + + +static time_t +ToSeconds(Hours, Minutes, Seconds, Meridian) + time_t Hours; + time_t Minutes; + time_t Seconds; + MERIDIAN Meridian; +{ + if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61) + return -1; + if (Meridian == MER24) { + if (Hours < 0 || Hours > 23) + return -1; + } + else { + if (Hours < 1 || Hours > 12) + return -1; + if (Hours == 12) + Hours = 0; + if (Meridian == MERpm) + Hours += 12; + } + return (Hours * 60L + Minutes) * 60L + Seconds; +} + + +static time_t +Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, dst) + time_t Month; + time_t Day; + time_t Year; + time_t Hours; + time_t Minutes; + time_t Seconds; + MERIDIAN Meridian; + DSTMODE dst; +{ + static int DaysNormal[13] = { + 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + }; + static int DaysLeap[13] = { + 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + }; + static int LeapYears[] = { + 1972, 1976, 1980, 1984, 1988, 1992, 1996, + 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036 + }; + int *yp; + int *mp; + time_t Julian; + int i; + time_t tod; + + /* Year should not be passed as a relative value, but absolute one. + so this should not happen, but just ensure it */ + if (Year < 0) + Year = -Year; + if (Year < 100) { + Year += 1900; + if (Year < EPOCH) + Year += 100; + } + for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++) + if (Year == *yp) { + mp = DaysLeap; + break; + } + if (Year < EPOCH || Year > END_OF_TIME + || Month < 1 || Month > 12 + /* NOSTRICT *//* conversion from long may lose accuracy */ + || Day < 1 || Day > mp[(int)Month]) + return -1; + + Julian = Day - 1 + (Year - EPOCH) * 365; + for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++) + if (Year <= *yp) + break; + for (i = 1; i < Month; i++) + Julian += *++mp; + Julian *= SECSPERDAY; + Julian += yyTimezone * 60L; + if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) + return -1; + Julian += tod; + tod = Julian; + if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst)) + Julian -= DST_OFFSET * 60 * 60; + return Julian; +} + + +static time_t +DSTcorrect(Start, Future) + time_t Start; + time_t Future; +{ + time_t StartDay; + time_t FutureDay; + + StartDay = (localtime(&Start)->tm_hour + 1) % 24; + FutureDay = (localtime(&Future)->tm_hour + 1) % 24; + return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60 * 60; +} + + +static time_t +RelativeMonth(Start, RelMonth) + time_t Start; + time_t RelMonth; +{ + struct tm *tm; + time_t Month; + time_t Year; + + tm = localtime(&Start); + Month = 12 * tm->tm_year + tm->tm_mon + RelMonth; + Year = Month / 12; + Year += 1900; + Month = Month % 12 + 1; + return DSTcorrect(Start, + Convert(Month, (time_t)tm->tm_mday, Year, + (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, + MER24, DSTmaybe)); +} + + +static int LookupWord(char *buff, int length) +{ + char *p; + STRING q; + TABLE *tp; + int c; + + p = buff; + c = p[0]; + + /* See if we have an abbreviation for a month. */ + if (length == 3 || (length == 4 && p[3] == '.')) + for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) { + q = tp->name; + if (c == q[0] && p[1] == q[1] && p[2] == q[2]) { + yylval.Number = tp->value; + return tp->type; + } + } + else + for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) + if (c == tp->name[0] && strcmp(p, tp->name) == 0) { + yylval.Number = tp->value; + return tp->type; + } + + /* Try for a timezone. */ + for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++) + if (c == tp->name[0] && p[1] == tp->name[1] + && strcmp(p, tp->name) == 0) { + yylval.Number = tp->value; + return tp->type; + } + + /* Try the units table. */ + for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++) + if (c == tp->name[0] && strcmp(p, tp->name) == 0) { + yylval.Number = tp->value; + return tp->type; + } + + /* Strip off any plural and try the units table again. */ + if (--length > 0 && p[length] == 's') { + p[length] = '\0'; + for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++) + if (c == tp->name[0] && strcmp(p, tp->name) == 0) { + p[length] = 's'; + yylval.Number = tp->value; + return tp->type; + } + p[length] = 's'; + } + length++; + + /* Drop out any periods. */ + for (p = buff, q = (STRING)buff; *q; q++) + if (*q != '.') + *p++ = *q; + *p = '\0'; + + /* Try the meridians. */ + if (buff[1] == 'm' && buff[2] == '\0') { + if (buff[0] == 'a') { + yylval.Meridian = MERam; + return tMERIDIAN; + } + if (buff[0] == 'p') { + yylval.Meridian = MERpm; + return tMERIDIAN; + } + } + + /* If we saw any periods, try the timezones again. */ + if (p - buff != length) { + c = buff[0]; + for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++) + if (c == tp->name[0] && p[1] == tp->name[1] + && strcmp(p, tp->name) == 0) { + yylval.Number = tp->value; + return tp->type; + } + } + + /* Unknown word -- assume GMT timezone. */ + yylval.Number = 0; + return tZONE; +} + + +static int date_lex(void) +{ + char c; + char *p; + char buff[20]; + int sign; + int i; + int nesting; + + for ( ; ; ) { + /* Get first character after the whitespace. */ + for ( ; ; ) { + while (CTYPE(isspace, (int)*yyInput)) + yyInput++; + c = *yyInput; + + /* Ignore RFC 822 comments, typically time zone names. */ + if (c != LPAREN) + break; + for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; ) + if (c == LPAREN) + nesting++; + else if (!IS7BIT(c) || c == '\0' || c == '\r' + || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c)))) + /* Lexical error: bad comment. */ + return '?'; + yyInput++; + } + + /* A number? */ + if (CTYPE(isdigit, (int)c) || c == '-' || c == '+') { + if (c == '-' || c == '+') { + sign = c == '-' ? -1 : 1; + yyInput++; + if (!CTYPE(isdigit, (int)*yyInput)) + /* Skip the plus or minus sign. */ + continue; + } + else + sign = 0; + for (i = 0; (c = *yyInput++) != '\0' && CTYPE(isdigit, (int)c); ) + i = 10 * i + c - '0'; + yyInput--; + yylval.Number = sign < 0 ? -i : i; + return sign ? tSNUMBER : tUNUMBER; + } + + /* A word? */ + if (CTYPE(isalpha, (int)c)) { + for (p = buff; (c = *yyInput++) == '.' || CTYPE(isalpha, (int)c); ) + if (p < &buff[sizeof buff - 1]) + *p++ = CTYPE(isupper, (int)c) ? tolower(c) : c; + *p = '\0'; + yyInput--; + return LookupWord(buff, p - buff); + } + + return *yyInput++; + } +} + + +time_t parsedate(char *p, TIMEINFO *now) +{ + extern int date_parse(); + struct tm *tm; + TIMEINFO ti; + time_t Start; + + yyInput = p; + if (now == NULL) { + now = &ti; + (void)GetTimeInfo(&ti); + } + + tm = localtime(&now->time); + yyYear = tm->tm_year + 1900; + yyMonth = tm->tm_mon + 1; + yyDay = tm->tm_mday; + yyTimezone = now->timezone; + yyDSTmode = DSTmaybe; + yyHour = 0; + yyMinutes = 0; + yySeconds = 0; + yyMeridian = MER24; + yyRelSeconds = 0; + yyRelMonth = 0; + yyHaveDate = 0; + yyHaveRel = 0; + yyHaveTime = 0; + + if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1) + return -1; + + if (yyHaveDate || yyHaveTime) { + Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds, + yyMeridian, yyDSTmode); + if (Start < 0) + return -1; + } + else { + Start = now->time; + if (!yyHaveRel) + Start -= (tm->tm_hour * 60L + tm->tm_min) * 60L + tm->tm_sec; + } + + Start += yyRelSeconds; + if (yyRelMonth) + Start += RelativeMonth(Start, yyRelMonth); + + /* Have to do *something* with a legitimate -1 so it's distinguishable + * from the error return value. (Alternately could set errno on error.) */ + return Start == -1 ? 0 : Start; +} + + +#if defined(TEST) + +#if YYDEBUG +extern int yydebug; +#endif /* YYDEBUG */ + +/* ARGSUSED */ +int +main(ac, av) + int ac; + char *av[]; +{ + char buff[128]; + time_t d; + +#if YYDEBUG + yydebug = 1; +#endif /* YYDEBUG */ + + (void)printf("Enter date, or blank line to exit.\n\t> "); + for ( ; ; ) { + (void)printf("\t> "); + (void)fflush(stdout); + if (gets(buff) == NULL || buff[0] == '\n') + break; +#if YYDEBUG + if (strcmp(buff, "yydebug") == 0) { + yydebug = !yydebug; + printf("yydebug = %s\n", yydebug ? "on" : "off"); + continue; + } +#endif /* YYDEBUG */ + d = parsedate(buff, (TIMEINFO *)NULL); + if (d == -1) + (void)printf("Bad format - couldn't convert.\n"); + else + (void)printf("%s", ctime(&d)); + } + + exit(0); + /* NOTREACHED */ +} +#endif /* defined(TEST) */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 6:29:58 2002 Delivered-To: freebsd-audit@freebsd.org Received: from a96180.upc-a.chello.nl (a96180.upc-a.chello.nl [62.163.96.180]) by hub.freebsd.org (Postfix) with ESMTP id 1297D37B42B; Wed, 20 Mar 2002 06:28:35 -0800 (PST) Received: by a96180.upc-a.chello.nl (Postfix, from userid 1001) id 00E1B218E; Wed, 20 Mar 2002 15:28:32 +0100 (CET) Date: Wed, 20 Mar 2002 15:28:32 +0100 From: Jeroen Ruigrok/asmodai To: markm@freebsd.org Cc: audit@freebsd.org Subject: Re: Make find(1) standalone - commit candidate Message-ID: <20020320142832.GK45578@daemon.ninth-circle.org> References: <200203201335.g2KDZL4j025080@grimreaper.grondar.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200203201335.g2KDZL4j025080@grimreaper.grondar.org> User-Agent: Mutt/1.3.24i Organisation: Ninth Circle Enterprises Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Looks good to me, and as an aside we loose the dependency on cvs for the yacc file. Nice. -- Jeroen Ruigrok van der Werven / asmodai / Kita no Mono asmodai@[wxs.nl|xmach.org], finger asmodai@ninth-circle.org http://www.softweyr.com/asmodai/ | http://www.[tendra|xmach].org/ Toi qui entres ici abandonne tout espoir, tu entres dans le royaume de la mort... To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 10:25:43 2002 Delivered-To: freebsd-audit@freebsd.org Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by hub.freebsd.org (Postfix) with ESMTP id C299637B400; Wed, 20 Mar 2002 10:25:40 -0800 (PST) Received: from bremen.shuttle.de (localhost [127.0.0.1]) by bremen.shuttle.de (Postfix) with ESMTP id 3863617D50; Wed, 20 Mar 2002 19:25:30 +0100 (CET) Received: (from uucp@localhost) by bremen.shuttle.de (8.12.1/8.12.1/Debian -5) with UUCP id g2KIPUix014059; Wed, 20 Mar 2002 19:25:30 +0100 Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.12.2/8.11.6) id g2KIQPqp002267; Wed, 20 Mar 2002 19:26:25 +0100 (CET) (envelope-from schweikh) Date: Wed, 20 Mar 2002 19:26:24 +0100 From: Jens Schweikhardt To: Garance A Drosihn Cc: freebsd-audit@FreeBSD.ORG, joerg@FreeBSD.ORG Subject: Re: crontab changes for PR bin/22612; please comment Message-ID: <20020320192624.A1258@schweikhardt.net> References: <20020318130904.A3869@schweikhardt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from drosih@rpi.edu on Mon, Mar 18, 2002 at 04:08:04PM -0500 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Mar 18, 2002 at 04:08:04PM -0500, Garance A Drosihn wrote: # At 1:09 PM +0100 3/18/02, Jens Schweikhardt wrote: # >hello, world\n # > # >please comment on this patch (slightly different from the # >one in the PR # >http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/22612) # > # >Currently, checking for modification of the tmp file just # >looks at the mtime and gives a false "no modification" if # >the edit took less than 1 second. This is solved by simply # >comparing the whole struct stat. ... # Stupid brain-dead alternative fix: # Create the file. stat the file. sleep a second. # *Then* open the file in the user's editor. Any # change that they make will have to have been done # more than a second later. Hmm. What about completely removing the test whether the tmp file was modified? Just try to install the crontab, no matter what. Or is there a reason why crontab files must not be installed if they havn't changed? Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 11: 5:29 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id C71DD37B404; Wed, 20 Mar 2002 11:05:25 -0800 (PST) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.12.1/8.12.1) with ESMTP id g2KJ5OgQ087128; Wed, 20 Mar 2002 14:05:24 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: <20020320192624.A1258@schweikhardt.net> References: <20020318130904.A3869@schweikhardt.net> <20020320192624.A1258@schweikhardt.net> Date: Wed, 20 Mar 2002 14:05:23 -0500 To: Jens Schweikhardt From: Garance A Drosihn Subject: Re: crontab changes for PR bin/22612; please comment Cc: freebsd-audit@FreeBSD.ORG, joerg@FreeBSD.ORG Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At 7:26 PM +0100 3/20/02, Jens Schweikhardt wrote: >Hmm. What about completely removing the test whether the >tmp file was modified? Just try to install the crontab, >no matter what. Or is there a reason why crontab files >must not be installed if they havn't changed? I don't know if there are any technical reasons, but I would want the check there for the peace of mine of the user. Let's say you start to edit a crontab, and then really screw it up due to some typos or something. You know it's screwed up, so you just want to bail out. You type :q! and you then see the message "installing new crontab". You then think -- "Oh no! What just happened?!?" In that situation, I would rather keep the current behavior, where you see "no changes made to crontab". -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 12:37:13 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 39AFF37B400; Wed, 20 Mar 2002 12:36:32 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id HAA08605; Thu, 21 Mar 2002 07:36:29 +1100 Date: Thu, 21 Mar 2002 07:36:40 +1100 (EST) From: Bruce Evans X-X-Sender: To: Cc: Subject: Re: Make find(1) standalone - commit candidate In-Reply-To: <200203201335.g2KDZL4j025080@grimreaper.grondar.org> Message-ID: <20020321072334.Q11390-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 20 Mar 2002 markm@FreeBSD.ORG wrote: OK, except there are now (surprisingly, only) 3 clones of getdate.y (the others are in tar and cvs), and the yacc stuff in the Makefile is as bogus as before. > Index: Makefile > =================================================================== > RCS file: /home/ncvs/src/usr.bin/find/Makefile,v > retrieving revision 1.12 > diff -u -d -r1.12 Makefile > --- Makefile 27 Feb 2002 17:57:00 -0000 1.12 > +++ Makefile 20 Mar 2002 09:36:58 -0000 > @@ -2,9 +2,7 @@ > # $FreeBSD: src/usr.bin/find/Makefile,v 1.12 2002/02/27 17:57:00 dwmalone Exp $ > > PROG= find > -SRCS= find.c function.c ls.c main.c misc.c operator.c option.c getdate.y > -CLEANFILES+= getdate.c y.tab.h > -CFLAGS+= -I${.CURDIR}/../../gnu/usr.bin/cvs/lib -DHAVE_CONFIG_H > -.PATH: ${.CURDIR}/../../contrib/cvs/lib > +SRCS= find.c function.c ls.c main.c misc.c operator.c option.c parsedate.y > +CLEANFILES+= parsedate.c y.tab.h > > .include The CLEANFILES lines have many style bugs: - use of "+=" for the first initialization of a variable. - duplicate getdate.c/parsedate.c. It is added automatically by bsd.prog.mk. - bogus y.tab.h. y.tab.h is not created, since it is not in SRCS. getdate.h is created instead (and automatically put in CLEANFILES). The (missing) YFLAGS line has a style bug. The default YFLAGS is -d. This causes getdate.h to be created and removed, but getdate.h is not used. YFLAGS should be set to to prevent this garbage. See tar/Makefile and cvs/lib/Makefile for correct handling of getdate.y. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 13: 0:38 2002 Delivered-To: freebsd-audit@freebsd.org Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.139.170]) by hub.freebsd.org (Postfix) with ESMTP id 6482A37B416 for ; Wed, 20 Mar 2002 13:00:33 -0800 (PST) Received: (from uucp@localhost) by storm.FreeBSD.org.uk (8.11.6/8.11.6) with UUCP id g2KL0Qg51141; Wed, 20 Mar 2002 21:00:26 GMT (envelope-from mark@grimreaper.grondar.za) Received: from grimreaper (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.2/8.12.2) with ESMTP id g2KKvA4j013529; Wed, 20 Mar 2002 20:57:10 GMT (envelope-from mark@grimreaper.grondar.za) Message-Id: <200203202057.g2KKvA4j013529@grimreaper.grondar.org> To: Bruce Evans Cc: audit@FreeBSD.ORG Subject: Re: Make find(1) standalone - commit candidate References: <20020321072334.Q11390-100000@gamplex.bde.org> In-Reply-To: <20020321072334.Q11390-100000@gamplex.bde.org> ; from Bruce Evans "Thu, 21 Mar 2002 07:36:40 +1100." Date: Wed, 20 Mar 2002 20:57:10 +0000 From: Mark Murray Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > On Wed, 20 Mar 2002 markm@FreeBSD.ORG wrote: > > OK, except there are now (surprisingly, only) 3 clones of getdate.y > (the others are in tar and cvs), and the yacc stuff in the Makefile > is as bogus as before. Would it make sense to put getdate.y into some library (libutil?) > The CLEANFILES lines have many style bugs: > - use of "+=" for the first initialization of a variable. > - duplicate getdate.c/parsedate.c. It is added automatically by bsd.prog.mk. > - bogus y.tab.h. y.tab.h is not created, since it is not in SRCS. getdate.h > is created instead (and automatically put in CLEANFILES). CLEANFILES removed. > The (missing) YFLAGS line has a style bug. The default YFLAGS is -d. This > causes getdate.h to be created and removed, but getdate.h is not used. > YFLAGS should be set to to prevent this garbage. Null YFLAGS added. > See tar/Makefile and cvs/lib/Makefile for correct handling of getdate.y. Maybe these should use the (above) library? M -- o Mark Murray \_ O.\_ Warning: this .sig is umop ap!sdn To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 13:28: 3 2002 Delivered-To: freebsd-audit@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 2EB5437B417; Wed, 20 Mar 2002 13:27:56 -0800 (PST) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 9C24D5346; Wed, 20 Mar 2002 22:27:53 +0100 (CET) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Jens Schweikhardt Cc: Garance A Drosihn , freebsd-audit@FreeBSD.ORG, joerg@FreeBSD.ORG Subject: Re: crontab changes for PR bin/22612; please comment References: <20020318130904.A3869@schweikhardt.net> <20020320192624.A1258@schweikhardt.net> From: Dag-Erling Smorgrav Date: 20 Mar 2002 22:27:52 +0100 In-Reply-To: <20020320192624.A1258@schweikhardt.net> Message-ID: Lines: 14 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Jens Schweikhardt writes: > Hmm. What about completely removing the test whether the tmp file was > modified? Just try to install the crontab, no matter what. Or is there a > reason why crontab files must not be installed if they havn't changed? Start editing your crontab in one xterm. Get a phonecall and lose brain state. Edit your crontab in a second xterm, save. Discover that you were already editing it in the first xterm, and exit the editor without saving your changes since you already made them in the second xterm. See "crontab installed". Curse. DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 15:10: 7 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 5B06737B400 for ; Wed, 20 Mar 2002 15:10:03 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id KAA26260; Thu, 21 Mar 2002 10:08:54 +1100 Date: Thu, 21 Mar 2002 10:09:04 +1100 (EST) From: Bruce Evans X-X-Sender: To: Mark Murray Cc: Subject: Re: Make find(1) standalone - commit candidate In-Reply-To: <200203202057.g2KKvA4j013529@grimreaper.grondar.org> Message-ID: <20020321100345.D11887-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 20 Mar 2002, Mark Murray wrote: > > On Wed, 20 Mar 2002 markm@FreeBSD.ORG wrote: > > > > OK, except there are now (surprisingly, only) 3 clones of getdate.y > > (the others are in tar and cvs), and the yacc stuff in the Makefile > > is as bogus as before. > > Would it make sense to put getdate.y into some library (libutil?) It seemsto be reasonably suitable for putting in a library despite its support for compile-time configuration. I don't like putting miscellaneous things in libutil. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 15:15:27 2002 Delivered-To: freebsd-audit@freebsd.org Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.139.170]) by hub.freebsd.org (Postfix) with ESMTP id 79CAE37B404 for ; Wed, 20 Mar 2002 15:15:23 -0800 (PST) Received: (from uucp@localhost) by storm.FreeBSD.org.uk (8.11.6/8.11.6) with UUCP id g2KNFKB52357; Wed, 20 Mar 2002 23:15:20 GMT (envelope-from mark@grimreaper.grondar.za) Received: from grimreaper (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.2/8.12.2) with ESMTP id g2KNEi4j080363; Wed, 20 Mar 2002 23:14:44 GMT (envelope-from mark@grimreaper.grondar.za) Message-Id: <200203202314.g2KNEi4j080363@grimreaper.grondar.org> To: Bruce Evans Cc: audit@FreeBSD.ORG Subject: Re: Make find(1) standalone - commit candidate References: <20020321100345.D11887-100000@gamplex.bde.org> In-Reply-To: <20020321100345.D11887-100000@gamplex.bde.org> ; from Bruce Evans "Thu, 21 Mar 2002 10:09:04 +1100." Date: Wed, 20 Mar 2002 23:14:44 +0000 From: Mark Murray Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > On Wed, 20 Mar 2002, Mark Murray wrote: > > > > On Wed, 20 Mar 2002 markm@FreeBSD.ORG wrote: > > > > > > OK, except there are now (surprisingly, only) 3 clones of getdate.y > > > (the others are in tar and cvs), and the yacc stuff in the Makefile > > > is as bogus as before. > > > > Would it make sense to put getdate.y into some library (libutil?) > > It seemsto be reasonably suitable for putting in a library despite its > support for compile-time configuration. I don't like putting miscellaneous > things in libutil. That was a loaded question :-). There is a load of password-related crap pw_*.c that is crying out to be shoved into a library. I have sorta decided that libutil may be it. get_date() seems to be another candidate. I belive that $#|+loads of other programs doing "private" date parsing can also use this. M -- o Mark Murray \_ O.\_ Warning: this .sig is umop ap!sdn To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Mar 20 21:10:31 2002 Delivered-To: freebsd-audit@freebsd.org Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by hub.freebsd.org (Postfix) with ESMTP id 46A9A37B417 for ; Wed, 20 Mar 2002 21:10:29 -0800 (PST) Received: (from uucp@localhost) by sax.sax.de (8.9.3/8.9.3) with UUCP id GAA06731; Thu, 21 Mar 2002 06:10:24 +0100 (CET) Received: (from j@localhost) by uriah.heep.sax.de (8.11.6/8.11.6) id g2KK4wY13426; Wed, 20 Mar 2002 21:04:58 +0100 (MET) (envelope-from j) Date: Wed, 20 Mar 2002 21:04:58 +0100 From: Joerg Wunsch To: Garance A Drosihn Cc: Jens Schweikhardt , freebsd-audit@FreeBSD.ORG Subject: Re: crontab changes for PR bin/22612; please comment Message-ID: <20020320210458.A13393@uriah.heep.sax.de> Reply-To: Joerg Wunsch References: <20020318130904.A3869@schweikhardt.net> <20020320192624.A1258@schweikhardt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from drosih@rpi.edu on Wed, Mar 20, 2002 at 02:05:23PM -0500 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG As Garance A Drosihn wrote: > You type :q! > and you then see the message "installing new crontab". > You then think -- "Oh no! What just happened?!?" In which case it would reinstall the old crontab only anyway :), but i agree, it would startle me, too. How about md5-checking the files? -- cheers, J"org .-.-. --... ...-- -.. . DL8DTL http://www.sax.de/~joerg/ NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Mar 21 16:56:48 2002 Delivered-To: freebsd-audit@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 0A9DA37B404; Thu, 21 Mar 2002 16:56:21 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.11.4/8.11.6) id g2M0uKU77186; Thu, 21 Mar 2002 19:56:20 -0500 (EST) (envelope-from wollman) Date: Thu, 21 Mar 2002 19:56:20 -0500 (EST) From: Garrett Wollman Message-Id: <200203220056.g2M0uKU77186@khavrinen.lcs.mit.edu> To: standards@FreeBSD.org Cc: audit@FreeBSD.org Subject: Expr fixes Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG [Followups to -standards, please.] I've fixed expr to be able to deal correctly with arguments and results consisting of a single '-'. At the same time, I also changed the data type used internally by expr to intmax_t, away from (deprecated) quad_t. The whole ``pre-parse to see if it might be an integer'' thing is silly, and should probably be removed entirely -- function calls are *not* that expensive. There are many style bugs in this utility. I have a couple of defect reports in to the Austin Group about the lack of specificity in 1003.1-2001 as regards how expr's integer math actually works, and whether expr should be prepared to accept an initial argument of "--" to indicate that there are no options. This change was created and tested on FreeBSD/sparc64, while tracking down a test-suite failure in autoconf 2.52. -GAWollman Index: expr.y =================================================================== RCS file: /home/cvs/src/bin/expr/expr.y,v retrieving revision 1.18 diff -u -r1.18 expr.y --- expr.y 2002/02/02 06:36:49 1.18 +++ expr.y 2002/03/22 00:47:57 @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -26,20 +27,20 @@ enum valtype type; union { char *s; - quad_t i; + intmax_t i; } u; } ; struct val *result; -int chk_div(quad_t, quad_t); -int chk_minus(quad_t, quad_t, quad_t); -int chk_plus(quad_t, quad_t, quad_t); -int chk_times(quad_t, quad_t, quad_t); +int chk_div(intmax_t, intmax_t); +int chk_minus(intmax_t, intmax_t, intmax_t); +int chk_plus(intmax_t, intmax_t, intmax_t); +int chk_times(intmax_t, intmax_t, intmax_t); void free_value(struct val *); int is_zero_or_null(struct val *); int isstring(struct val *); -struct val *make_integer(quad_t); +struct val *make_integer(intmax_t); struct val *make_str(const char *); struct val *op_and(struct val *, struct val *); struct val *op_colon(struct val *, struct val *); @@ -55,7 +56,7 @@ struct val *op_plus(struct val *, struct val *); struct val *op_rem(struct val *, struct val *); struct val *op_times(struct val *, struct val *); -quad_t to_integer(struct val *); +intmax_t to_integer(struct val *); void to_string(struct val *); int yyerror(const char *); int yylex(void); @@ -105,7 +106,7 @@ %% struct val * -make_integer(quad_t i) +make_integer(intmax_t i) { struct val *vp; @@ -123,26 +124,34 @@ make_str(const char *s) { struct val *vp; - size_t i; - int isint; + char *ep; vp = (struct val *) malloc (sizeof (*vp)); if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { errx (2, "malloc() failed"); } - for(i = 1, isint = isdigit(s[0]) || s[0] == '-'; - isint && i < strlen(s); - i++) - { - if(!isdigit(s[i])) - isint = 0; - } + /* + * Previously we tried to scan the string to see if it ``looked like'' + * an integer (erroneously, as it happened). Let strtoimax() do the + * dirty work. We could cache the value, except that we are using + * a union and need to preserve the original string form until we + * are certain that it is not needed. + * + * IEEE Std.1003.1-2001 says: + * /integer/ An argument consisting only of an (optional) unary minus + * followed by digits. + * + * This means that arguments which consist of digits followed by + * non-digits MUST NOT be considered integers. strtoimax() will + * figure this out for us. + */ + (void)strtoimax(s, &ep, 10); - if (isint) - vp->type = numeric_string; - else + if (*ep != '\0') vp->type = string; + else + vp->type = numeric_string; return vp; } @@ -156,10 +165,10 @@ } -quad_t +intmax_t to_integer(struct val *vp) { - quad_t i; + intmax_t i; if (vp->type == integer) return 1; @@ -169,10 +178,10 @@ /* vp->type == numeric_string, make it numeric */ errno = 0; - i = strtoq(vp->u.s, (char**)NULL, 10); - if (errno != 0) { - errx (2, "overflow"); - } + i = strtoimax(vp->u.s, (char **)NULL, 10); + if (errno == ERANGE) + err(2, NULL); + free (vp->u.s); vp->u.i = i; vp->type = integer; @@ -187,12 +196,18 @@ if (vp->type == string || vp->type == numeric_string) return; - tmp = malloc ((size_t)25); + /* + * log_10(x) ~= 0.3 * log_2(x). Rounding up gives the number + * of digits; add one each for the sign and terminating null + * character, respectively. + */ +#define NDIGITS(x) (3 * (sizeof(x) * CHAR_BIT) / 10 + 1 + 1 + 1) + tmp = malloc (NDIGITS(vp->u.i)); if (tmp == NULL) { errx (2, "malloc() failed"); } - sprintf (tmp, "%lld", (long long)vp->u.i); + sprintf (tmp, "%jd", vp->u.i); vp->type = string; vp->u.s = tmp; } @@ -252,7 +267,7 @@ yyparse (); if (result->type == integer) - printf ("%lld\n", (long long)result->u.i); + printf ("%jd\n", result->u.i); else printf ("%s\n", result->u.s); @@ -284,7 +299,7 @@ if (is_zero_or_null (a) || is_zero_or_null (b)) { free_value (a); free_value (b); - return (make_integer ((quad_t)0)); + return (make_integer ((intmax_t)0)); } else { free_value (b); return (a); @@ -299,11 +314,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) == 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) == 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i == b->u.i)); + r = make_integer ((intmax_t)(a->u.i == b->u.i)); } free_value (a); @@ -319,11 +334,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) > 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) > 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i > b->u.i)); + r = make_integer ((intmax_t)(a->u.i > b->u.i)); } free_value (a); @@ -339,11 +354,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) < 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) < 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i < b->u.i)); + r = make_integer ((intmax_t)(a->u.i < b->u.i)); } free_value (a); @@ -359,11 +374,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) >= 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) >= 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i >= b->u.i)); + r = make_integer ((intmax_t)(a->u.i >= b->u.i)); } free_value (a); @@ -379,11 +394,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) <= 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) <= 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i <= b->u.i)); + r = make_integer ((intmax_t)(a->u.i <= b->u.i)); } free_value (a); @@ -399,11 +414,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) != 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) != 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i != b->u.i)); + r = make_integer ((intmax_t)(a->u.i != b->u.i)); } free_value (a); @@ -412,7 +427,7 @@ } int -chk_plus(quad_t a, quad_t b, quad_t r) +chk_plus(intmax_t a, intmax_t b, intmax_t r) { /* sum of two positive numbers must be positive */ if (a > 0 && b > 0 && r <= 0) @@ -433,7 +448,7 @@ errx (2, "non-numeric argument"); } - r = make_integer (/*(quad_t)*/(a->u.i + b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i + b->u.i)); if (chk_plus (a->u.i, b->u.i, r->u.i)) { errx (2, "overflow"); } @@ -443,16 +458,16 @@ } int -chk_minus(quad_t a, quad_t b, quad_t r) +chk_minus(intmax_t a, intmax_t b, intmax_t r) { - /* special case subtraction of QUAD_MIN */ - if (b == QUAD_MIN) { + /* special case subtraction of INTMAX_MIN */ + if (b == INTMAX_MIN) { if (a >= 0) return 1; else return 0; } - /* this is allowed for b != QUAD_MIN */ + /* this is allowed for b != INTMAX_MIN */ return chk_plus (a, -b, r); } @@ -465,7 +480,7 @@ errx (2, "non-numeric argument"); } - r = make_integer (/*(quad_t)*/(a->u.i - b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i - b->u.i)); if (chk_minus (a->u.i, b->u.i, r->u.i)) { errx (2, "overflow"); } @@ -475,7 +490,7 @@ } int -chk_times(quad_t a, quad_t b, quad_t r) +chk_times(intmax_t a, intmax_t b, intmax_t r) { /* special case: first operand is 0, no overflow possible */ if (a == 0) @@ -495,7 +510,7 @@ errx (2, "non-numeric argument"); } - r = make_integer (/*(quad_t)*/(a->u.i * b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i * b->u.i)); if (chk_times (a->u.i, b->u.i, r->u.i)) { errx (2, "overflow"); } @@ -505,11 +520,11 @@ } int -chk_div(quad_t a, quad_t b) +chk_div(intmax_t a, intmax_t b) { /* div by zero has been taken care of before */ - /* only QUAD_MIN / -1 causes overflow */ - if (a == QUAD_MIN && b == -1) + /* only INTMAX_MIN / -1 causes overflow */ + if (a == INTMAX_MIN && b == -1) return 1; /* everything else is OK */ return 0; @@ -528,7 +543,7 @@ errx (2, "division by zero"); } - r = make_integer (/*(quad_t)*/(a->u.i / b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i / b->u.i)); if (chk_div (a->u.i, b->u.i)) { errx (2, "overflow"); } @@ -550,7 +565,7 @@ errx (2, "division by zero"); } - r = make_integer (/*(quad_t)*/(a->u.i % b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i % b->u.i)); /* chk_rem necessary ??? */ free_value (a); free_value (b); @@ -584,11 +599,11 @@ v = make_str (a->u.s + rm[1].rm_so); } else { - v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); + v = make_integer ((intmax_t)(rm[0].rm_eo - rm[0].rm_so)); } } else { if (rp.re_nsub == 0) { - v = make_integer ((quad_t)0); + v = make_integer ((intmax_t)0); } else { v = make_str (""); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Mar 21 20:19:18 2002 Delivered-To: freebsd-audit@freebsd.org Received: from sunny.newgold.net (Durham-ar1-4-64-252-018.dsl.genuity.net [4.64.252.18]) by hub.freebsd.org (Postfix) with ESMTP id 5EBC337B400; Thu, 21 Mar 2002 20:19:16 -0800 (PST) Received: from sunny.newgold.net (freebsd@localhost [IPv6:::1]) by sunny.newgold.net (8.12.1/8.12.1) with ESMTP id g2M3rxII001936; Fri, 22 Mar 2002 03:58:03 GMT Received: (from freebsd@localhost) by sunny.newgold.net (8.12.1/8.12.1/Submit) id g2M3rrt5014943; Fri, 22 Mar 2002 03:53:53 GMT Date: Fri, 22 Mar 2002 03:52:31 +0000 From: "J. Mallett" To: "J. Mallett" Cc: Dag-Erling Smorgrav , "Tim J. Robbins" , freebsd-audit@FreeBSD.ORG Subject: Re: patch for review: xargs standards compliance Message-ID: <20020322035231.A23277@FreeBSD.ORG> References: <20020315231100.A20942@FreeBSD.ORG> <20020316192629.A5254@descent.robbins.dropbear.id.au> <20020316090004.A26394@FreeBSD.ORG> <20020316093507.B26394@FreeBSD.ORG> <20020316101434.A2192@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020316101434.A2192@FreeBSD.ORG> User-Agent: Mutt/1.3.21i Organisation: FreeBSD Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, Mar 16, 2002 at 10:14:35AM +0000, J. Mallett wrote: > http://people.freebsd.org/~jmallett/xargs.patch3 I take it nobody objects to this version of my patch then? Thanks, /j. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Mar 21 21:13:48 2002 Delivered-To: freebsd-audit@freebsd.org Received: from descent.robbins.dropbear.id.au (049.b.006.mel.iprimus.net.au [210.50.45.49]) by hub.freebsd.org (Postfix) with ESMTP id 0E04A37B404; Thu, 21 Mar 2002 21:13:41 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2M582p01423; Fri, 22 Mar 2002 16:08:02 +1100 (EST) (envelope-from tim) Date: Fri, 22 Mar 2002 16:08:02 +1100 From: "Tim J. Robbins" To: "J. Mallett" Cc: freebsd-audit@FreeBSD.ORG Subject: Re: patch for review: xargs standards compliance Message-ID: <20020322160802.B1338@descent.robbins.dropbear.id.au> References: <20020315231100.A20942@FreeBSD.ORG> <20020316192629.A5254@descent.robbins.dropbear.id.au> <20020316090004.A26394@FreeBSD.ORG> <20020316093507.B26394@FreeBSD.ORG> <20020316101434.A2192@FreeBSD.ORG> <20020322035231.A23277@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020322035231.A23277@FreeBSD.ORG>; from jmallett@FreeBSD.ORG on Fri, Mar 22, 2002 at 03:52:31AM +0000 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Mar 22, 2002 at 03:52:31AM +0000, J. Mallett wrote: > On Sat, Mar 16, 2002 at 10:14:35AM +0000, J. Mallett wrote: > > http://people.freebsd.org/~jmallett/xargs.patch3 > > I take it nobody objects to this version of my patch then? I don't like the wording here: + .It Fl I Ar replstr + If this option is specified up to 5 occurences of + .Ar replstr + may be replaced in the arguments to + .Ar utility + with one line of standard input. + .Ar Utility + is executed for every line of input in this mode. + In this mode + .Fl x + is implied. Wouldn't this be better? .It Fl I Ar replstr Execute .Ar utility for each input line, replacing up to 5 occurrences of .Ar replstr in the arguments with the line read. Implies .Fl x . (or similar; mdoc-ing hasn't been checked). And while not really a bug, there probably should be const qualifiers on `match' and `replstr' in strnsubst(): size_t strnsubst(char **str, char *match, char *replstr, size_t n) + if (this == NULL) + goto done; This goto could be changed to a break, simplifying it a bit. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Mar 22 7:36:43 2002 Delivered-To: freebsd-audit@freebsd.org Received: from sunny.newgold.net (Durham-ar1-4-64-252-018.dsl.genuity.net [4.64.252.18]) by hub.freebsd.org (Postfix) with ESMTP id 2FF2437B404; Fri, 22 Mar 2002 07:36:38 -0800 (PST) Received: from sunny.newgold.net (freebsd@localhost [IPv6:::1]) by sunny.newgold.net (8.12.1/8.12.1) with ESMTP id g2MFDmII007719; Fri, 22 Mar 2002 15:15:23 GMT Received: (from freebsd@localhost) by sunny.newgold.net (8.12.1/8.12.1/Submit) id g2MFDc9u006649; Fri, 22 Mar 2002 15:13:38 GMT Date: Fri, 22 Mar 2002 15:12:15 +0000 From: "J. Mallett" To: "Tim J. Robbins" Cc: "J. Mallett" , freebsd-audit@FreeBSD.ORG Subject: Re: patch for review: xargs standards compliance Message-ID: <20020322151214.A26549@FreeBSD.ORG> References: <20020315231100.A20942@FreeBSD.ORG> <20020316192629.A5254@descent.robbins.dropbear.id.au> <20020316090004.A26394@FreeBSD.ORG> <20020316093507.B26394@FreeBSD.ORG> <20020316101434.A2192@FreeBSD.ORG> <20020322035231.A23277@FreeBSD.ORG> <20020322160802.B1338@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="ibTvN161/egqYuK8" Content-Disposition: inline In-Reply-To: <20020322160802.B1338@descent.robbins.dropbear.id.au> User-Agent: Mutt/1.3.21i Organisation: FreeBSD Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 22, 2002 at 04:08:02PM +1100, Tim J. Robbins wrote: > On Fri, Mar 22, 2002 at 03:52:31AM +0000, J. Mallett wrote: >=20 > > On Sat, Mar 16, 2002 at 10:14:35AM +0000, J. Mallett wrote: >=20 > > > http://people.freebsd.org/~jmallett/xargs.patch3 > >=20 > > I take it nobody objects to this version of my patch then? >=20 > I don't like the wording here: >=20 > + .It Fl I Ar replstr > + If this option is specified up to 5 occurences of > + .Ar replstr > + may be replaced in the arguments to > + .Ar utility > + with one line of standard input. > + .Ar Utility > + is executed for every line of input in this mode. > + In this mode > + .Fl x > + is implied. >=20 > Wouldn't this be better? >=20 > .It Fl I Ar replstr > Execute > .Ar utility > for each input line, replacing up to 5 occurrences of > .Ar replstr > in the arguments with the line read. > Implies > .Fl x . >=20 > (or similar; mdoc-ing hasn't been checked). Good call on that, I believe, I've used that as a jumping off point to=20 redo -I's description, though I think it needs to be clear that it's=20 arguments to .Ar utility that will have replacement done.. >=20 > And while not really a bug, there probably should be const qualifiers > on `match' and `replstr' in strnsubst(): > size_t strnsubst(char **str, char *match, char *replstr, size_t n) Fair enough, my local copy of strnsubst has been cleaned with such, so I=20 have no problems with that. >=20 > + if (this =3D=3D NULL) > + goto done; >=20 > This goto could be changed to a break, simplifying it a bit. Sounds reasonable. >=20 > Tim Well, given all the input thus far, I'd like to commit http://people.freebsd.org/~jmallett/xargs.patch4 Some time this evening, as I've handled every comment I've gotten in the=20 past week of review (I believe). Thank you, /j. --ibTvN161/egqYuK8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: 2.6.3ia iQCVAwUBPJtJvIlNtGTEXmf1AQGGXwP/adfTESF8RfA8e41b0JI2dcmrShnaRDyl dEuoFWgkAHdn6hF5BBjlXAIyoot2IuuxSsROWqCvnNfXPREAITjpkIFfHYP4bblq ds9mg4600r5n45ZWsYYdn/VuxbD9ZfhksBR6UK5OBifKoIXsnPXEG4/TZV5yJ7af Ln9MXeepVSE= =81Kw -----END PGP SIGNATURE----- --ibTvN161/egqYuK8-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Mar 22 8:16:23 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id 192E737B41E for ; Fri, 22 Mar 2002 08:16:18 -0800 (PST) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.12.1/8.12.1) with ESMTP id g2MGGG9e095922; Fri, 22 Mar 2002 11:16:17 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: <20020320210458.A13393@uriah.heep.sax.de> References: <20020318130904.A3869@schweikhardt.net> <20020320192624.A1258@schweikhardt.net> <20020320210458.A13393@uriah.heep.sax.de> Date: Fri, 22 Mar 2002 11:16:15 -0500 To: Joerg Wunsch From: Garance A Drosihn Subject: Re: crontab changes for PR bin/22612; please comment Cc: Jens Schweikhardt , freebsd-audit@FreeBSD.ORG Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At 9:04 PM +0100 3/20/02, Joerg Wunsch wrote: >As Garance A Drosihn wrote: > >> You type :q! >> and you then see the message "installing new crontab". >> You then think -- "Oh no! What just happened?!?" > >In which case it would reinstall the old crontab only >anyway :), but I agree, it would startle me, too. > >How about md5-checking the files? Well, if it were me I would probably go with the lazy fix and add the 1-second sleep. However, it probably would be even "nicer to the user" to do an md5-check. -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Mar 22 8:33:38 2002 Delivered-To: freebsd-audit@freebsd.org Received: from sunny.newgold.net (Durham-ar1-4-64-252-018.dsl.genuity.net [4.64.252.18]) by hub.freebsd.org (Postfix) with ESMTP id 8DB7237B427; Fri, 22 Mar 2002 08:33:23 -0800 (PST) Received: from sunny.newgold.net (freebsd@localhost [IPv6:::1]) by sunny.newgold.net (8.12.1/8.12.1) with ESMTP id g2MG85II012588; Fri, 22 Mar 2002 16:12:10 GMT Received: (from freebsd@localhost) by sunny.newgold.net (8.12.1/8.12.1/Submit) id g2MG7svv006089; Fri, 22 Mar 2002 16:07:54 GMT Date: Fri, 22 Mar 2002 16:06:32 +0000 From: "J. Mallett" To: "J. Mallett" Cc: "Tim J. Robbins" , freebsd-audit@FreeBSD.ORG, freebsd-standards@FreeBSD.ORG Subject: Re: patch for review: xargs standards compliance Message-ID: <20020322160631.A31375@FreeBSD.ORG> References: <20020315231100.A20942@FreeBSD.ORG> <20020316192629.A5254@descent.robbins.dropbear.id.au> <20020316090004.A26394@FreeBSD.ORG> <20020316093507.B26394@FreeBSD.ORG> <20020316101434.A2192@FreeBSD.ORG> <20020322035231.A23277@FreeBSD.ORG> <20020322160802.B1338@descent.robbins.dropbear.id.au> <20020322151214.A26549@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020322151214.A26549@FreeBSD.ORG> User-Agent: Mutt/1.3.21i Organisation: FreeBSD Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Mar 22, 2002 at 03:12:15PM +0000, J. Mallett wrote: > > Well, given all the input thus far, I'd like to commit > http://people.freebsd.org/~jmallett/xargs.patch4 > However I just pulled up the SUS spec online and found I was misremembering how exactly things were worded, and realised that strnsubst needs run with a n of 5 for each argument, not for the entire arguments list. One thing I am now unsure of that I'd forgotten all about is: "Constructed arguments cannot grow larger than 255 bytes. " Should I errx() if strlen(*tmp) is >255, or should I augment strnsubst() to take a size argument and not allow more than that amount to be allocated, and furthermore, do I strlcat replstr for each match, or do I do checks along the way to see if it is time to give up on replacing, and just concatenate the rest of the string. I *think* given the language relating to umber of replacements in the argument list, that I should TRY to replace as many times as possible, up to five... Thoughts? Anyway, here's with strnsubst() taking yet another size_t argument, and it being used to set the maximum size, and checks as I think the standard permits it. The way I've done it is to ensure we either get as much of the input string as possible, or we continue concatenating. This sometimes results in arguments less than 255 bytes, but will never result in a higher amount. The standard is not clear enough on this point in my opinion, and so it is up to the implementation what to do to ensure it never grows beyond 255 bytes per argument, I suppose, in whatever way is seen fit. http://people.freebsd.org/~jmallett/xargs.patch5 This is being copied to -standards, as now I am getting into the grounds of interpereting SUS, and I'd rather not do that without review in principle as well as in code. Thank you, /j. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Mar 22 13:13:36 2002 Delivered-To: freebsd-audit@freebsd.org Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by hub.freebsd.org (Postfix) with ESMTP id 2DCC537B420 for ; Fri, 22 Mar 2002 13:13:28 -0800 (PST) Received: from bremen.shuttle.de (localhost [127.0.0.1]) by bremen.shuttle.de (Postfix) with ESMTP id 77D2A17D30; Fri, 22 Mar 2002 22:13:25 +0100 (CET) Received: (from uucp@localhost) by bremen.shuttle.de (8.12.1/8.12.1/Debian -5) with UUCP id g2MLDPjf017007; Fri, 22 Mar 2002 22:13:25 +0100 Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.12.2/8.11.6) id g2MLEN1t005639; Fri, 22 Mar 2002 22:14:23 +0100 (CET) (envelope-from schweikh) Date: Fri, 22 Mar 2002 22:14:22 +0100 From: Jens Schweikhardt To: Garance A Drosihn Cc: Joerg Wunsch , freebsd-audit@FreeBSD.ORG Subject: Re: crontab changes for PR bin/22612; please comment Message-ID: <20020322221422.A5487@schweikhardt.net> References: <20020318130904.A3869@schweikhardt.net> <20020320192624.A1258@schweikhardt.net> <20020320210458.A13393@uriah.heep.sax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from drosih@rpi.edu on Fri, Mar 22, 2002 at 11:16:15AM -0500 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Folks, On Fri, Mar 22, 2002 at 11:16:15AM -0500, Garance A Drosihn wrote: # At 9:04 PM +0100 3/20/02, Joerg Wunsch wrote: ... # >How about md5-checking the files? # # Well, if it were me I would probably go with the lazy # fix and add the 1-second sleep. However, it probably # would be even "nicer to the user" to do an md5-check. I tried to also look at the tv_nsec field and usleep for just a few ms, but to my dismay it's always 0. So I finally decided to go the way Garance suggested. Any strong objections? Index: crontab.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/cron/crontab/crontab.c,v retrieving revision 1.18 diff -u -r1.18 crontab.c --- crontab.c 9 Jul 2001 09:23:57 -0000 1.18 +++ crontab.c 22 Mar 2002 19:22:10 -0000 @@ -43,7 +43,7 @@ #if defined(POSIX) # include #endif - +#include #define NHEADER_LINES 3 @@ -381,6 +381,13 @@ if (statbuf.st_dev != fsbuf.st_dev || statbuf.st_ino != fsbuf.st_ino) errx(ERROR_EXIT, "temp file must be edited in place"); mtime = statbuf.st_mtime; + /* + * Nap for one second so the mtime is guaranteed to be less than the + * mtime for the temp file we examine later on (in case of + * modifications). We can't use the tv_nsec because some file systems + * do not use it. + */ + sleep(1); if ((!(editor = getenv("VISUAL"))) && (!(editor = getenv("EDITOR"))) Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Mar 22 15:38: 2 2002 Delivered-To: freebsd-audit@freebsd.org Received: from rwcrmhc54.attbi.com (rwcrmhc54.attbi.com [216.148.227.87]) by hub.freebsd.org (Postfix) with ESMTP id B9CC337B400 for ; Fri, 22 Mar 2002 15:37:33 -0800 (PST) Received: from blossom.cjclark.org ([12.234.91.48]) by rwcrmhc54.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020322233731.MFAG1214.rwcrmhc54.attbi.com@blossom.cjclark.org>; Fri, 22 Mar 2002 23:37:31 +0000 Received: (from cjc@localhost) by blossom.cjclark.org (8.11.6/8.11.6) id g2MNbTx41621; Fri, 22 Mar 2002 15:37:29 -0800 (PST) (envelope-from cjc) Date: Fri, 22 Mar 2002 15:37:29 -0800 From: "Crist J. Clark" To: Garance A Drosihn Cc: Joerg Wunsch , Jens Schweikhardt , freebsd-audit@FreeBSD.org Subject: Re: crontab changes for PR bin/22612; please comment Message-ID: <20020322153729.C41186@blossom.cjclark.org> References: <20020318130904.A3869@schweikhardt.net> <20020320192624.A1258@schweikhardt.net> <20020320210458.A13393@uriah.heep.sax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from drosih@rpi.edu on Fri, Mar 22, 2002 at 11:16:15AM -0500 X-URL: http://people.freebsd.org/~cjc/ Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Mar 22, 2002 at 11:16:15AM -0500, Garance A Drosihn wrote: > At 9:04 PM +0100 3/20/02, Joerg Wunsch wrote: > >As Garance A Drosihn wrote: > > > >> You type :q! > >> and you then see the message "installing new crontab". > >> You then think -- "Oh no! What just happened?!?" > > > >In which case it would reinstall the old crontab only > >anyway :), but I agree, it would startle me, too. > > > >How about md5-checking the files? > > Well, if it were me I would probably go with the lazy > fix and add the 1-second sleep. However, it probably > would be even "nicer to the user" to do an md5-check. You can borrow the MD5-check code from src/usr.bin/chpass/edit.c. -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Mar 22 17: 0:38 2002 Delivered-To: freebsd-audit@freebsd.org Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.139.170]) by hub.freebsd.org (Postfix) with ESMTP id EA6B237B400 for ; Fri, 22 Mar 2002 17:00:15 -0800 (PST) Received: (from uucp@localhost) by storm.FreeBSD.org.uk (8.11.6/8.11.6) with UUCP id g2N10E667484 for audit@freebsd.org; Sat, 23 Mar 2002 01:00:14 GMT (envelope-from root@grimreaper.grondar.za) Received: from grimreaper (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.2/8.12.2) with ESMTP id g2N0uV1D047229 for ; Sat, 23 Mar 2002 00:56:31 GMT (envelope-from root@grimreaper.grondar.za) Message-Id: <200203230056.g2N0uV1D047229@grimreaper.grondar.org> To: audit@freebsd.org Subject: chpass WARNS/lint fixes From: markm@freebsd.org Date: Sat, 23 Mar 2002 00:56:31 +0000 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Index: Makefile =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/Makefile,v retrieving revision 1.24 diff -u -d -r1.24 Makefile --- Makefile 13 Sep 2001 06:48:16 -0000 1.24 +++ Makefile 23 Mar 2002 00:51:47 -0000 @@ -2,7 +2,6 @@ # $FreeBSD: src/usr.bin/chpass/Makefile,v 1.24 2001/09/13 06:48:16 ru Exp $ PROG= chpass -CFLAGS+=-Wall SRCS= chpass.c edit.c field.c pw_copy.c pw_scan.c pw_util.c pw_yp.c \ table.c util.c ypxfr_misc.c ${GENSRCS} GENSRCS=yp.h yp_clnt.c yppasswd.h yppasswd_clnt.c yppasswd_private.h \ Index: chpass.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/chpass.c,v retrieving revision 1.20 diff -u -d -r1.20 chpass.c --- chpass.c 22 Mar 2002 01:19:26 -0000 1.20 +++ chpass.c 23 Mar 2002 00:45:13 -0000 @@ -39,10 +39,11 @@ #ifndef lint static const char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94"; -static const char rcsid[] = - "$FreeBSD: src/usr.bin/chpass/chpass.c,v 1.20 2002/03/22 01:19:26 imp Exp $"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -77,6 +78,8 @@ void baduser(void); void usage(void); +char localhost[] = "localhost"; + int main(argc, argv) int argc; @@ -135,7 +138,7 @@ #endif yp_domain = optarg; if (yp_server == NULL) - yp_server = "localhost"; + yp_server = localhost; #ifdef PARANOID } #endif Index: chpass.h =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/chpass.h,v retrieving revision 1.4 diff -u -d -r1.4 chpass.h --- chpass.h 22 Mar 2002 01:19:26 -0000 1.4 +++ chpass.h 23 Mar 2002 00:49:56 -0000 @@ -37,8 +37,9 @@ struct passwd; typedef struct _entry { - char *prompt; - int (*func)(), restricted, len; + const char *prompt; + int (*func)(char *, struct passwd *, struct _entry *); + int restricted, len; char *except, *save; } ENTRY; Index: edit.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/edit.c,v retrieving revision 1.19 diff -u -d -r1.19 edit.c --- edit.c 26 Jul 2001 23:27:10 -0000 1.19 +++ edit.c 23 Mar 2002 00:45:42 -0000 @@ -29,14 +29,15 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD: src/usr.bin/chpass/edit.c,v 1.19 2001/07/26 23:27:10 mike Exp $ */ #ifndef lint static const char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include @@ -100,7 +101,7 @@ struct passwd *pw; { FILE *fp; - char *bp, *p, *ttoa(); + char *bp, *p; if (!(fp = fdopen(fd, "w"))) pw_error(tempname, 1, 1); @@ -260,7 +261,7 @@ pw->pw_name, pw->pw_passwd, (unsigned long)pw->pw_uid, (unsigned long)pw->pw_gid, pw->pw_class, (long)pw->pw_change, (long)pw->pw_expire, pw->pw_gecos, pw->pw_dir, - pw->pw_shell) >= sizeof(buf)) { + pw->pw_shell) >= (int)sizeof(buf)) { warnx("entries too long"); free(p); return (0); Index: field.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/field.c,v retrieving revision 1.4 diff -u -d -r1.4 field.c --- field.c 6 Dec 1998 22:58:14 -0000 1.4 +++ field.c 23 Mar 2002 00:45:59 -0000 @@ -35,6 +35,9 @@ static const char sccsid[] = "@(#)field.c 8.4 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include @@ -56,7 +59,7 @@ p_login(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!*p) { warnx("empty login field"); @@ -85,10 +88,10 @@ p_passwd(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!*p) - pw->pw_passwd = ""; /* "NOLOGIN"; */ + pw->pw_passwd = strdup(""); /* "NOLOGIN"; */ else if (!(pw->pw_passwd = strdup(p))) { warnx("can't save password entry"); return (1); @@ -102,7 +105,7 @@ p_uid(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { uid_t id; char *np; @@ -130,7 +133,7 @@ p_gid(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { struct group *gr; gid_t id; @@ -163,10 +166,10 @@ p_class(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!*p) - pw->pw_class = ""; + pw->pw_class = strdup(""); else if (!(pw->pw_class = strdup(p))) { warnx("can't save entry"); return (1); @@ -180,7 +183,7 @@ p_change(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!atot(p, &pw->pw_change)) return (0); @@ -193,7 +196,7 @@ p_expire(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!atot(p, &pw->pw_expire)) return (0); @@ -205,11 +208,11 @@ int p_gecos(p, pw, ep) char *p; - struct passwd *pw; + struct passwd *pw __unused; ENTRY *ep; { if (!*p) - ep->save = ""; + ep->save = strdup(""); else if (!(ep->save = strdup(p))) { warnx("can't save entry"); return (1); @@ -222,7 +225,7 @@ p_hdir(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!*p) { warnx("empty home directory field"); @@ -240,13 +243,13 @@ p_shell(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { - char *t, *ok_shell(); + char *t; struct stat sbuf; if (!*p) { - pw->pw_shell = _PATH_BSHELL; + pw->pw_shell = strdup(_PATH_BSHELL); return (0); } /* only admin can change from or to "restricted" shells */ Index: pw_copy.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/pw_copy.c,v retrieving revision 1.11 diff -u -d -r1.11 pw_copy.c --- pw_copy.c 18 Mar 2002 02:22:53 -0000 1.11 +++ pw_copy.c 23 Mar 2002 00:46:11 -0000 @@ -37,6 +37,9 @@ static const char sccsid[] = "@(#)pw_copy.c 8.4 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + /* * This module is used to copy the master password file, replacing a single * record, by chpass(1) and passwd(1). Index: pw_yp.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/pw_yp.c,v retrieving revision 1.19 diff -u -d -r1.19 pw_yp.c --- pw_yp.c 6 Feb 2002 15:26:04 -0000 1.19 +++ pw_yp.c 23 Mar 2002 00:46:33 -0000 @@ -34,35 +34,37 @@ * Written by Bill Paul * Center for Telecommunications Research * Columbia University, New York City - * - * $FreeBSD: src/usr.bin/chpass/pw_yp.c,v 1.19 2002/02/06 15:26:04 des Exp $ */ +#include +__FBSDID("$FreeBSD$"); + #ifdef YP -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include +#include #include #include -struct dom_binding {}; #include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include + +struct dom_binding {}; + #include "pw_yp.h" #include "ypxfr_extern.h" #include "yppasswd_private.h" Index: table.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/table.c,v retrieving revision 1.7 diff -u -d -r1.7 table.c --- table.c 23 Feb 1999 02:41:26 -0000 1.7 +++ table.c 23 Mar 2002 00:46:44 -0000 @@ -35,6 +35,9 @@ static const char sccsid[] = "@(#)table.c 8.3 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include "chpass.h" @@ -43,23 +46,23 @@ char e2[] = ":,"; ENTRY list[] = { - { "login", p_login, 1, 5, e1, }, - { "password", p_passwd, 1, 8, e1, }, - { "uid", p_uid, 1, 3, e1, }, - { "gid", p_gid, 1, 3, e1, }, - { "class", p_class, 1, 5, e1, }, - { "change", p_change, 1, 6, NULL, }, - { "expire", p_expire, 1, 6, NULL, }, + { "login", p_login, 1, 5, e1, NULL }, + { "password", p_passwd, 1, 8, e1, NULL }, + { "uid", p_uid, 1, 3, e1, NULL }, + { "gid", p_gid, 1, 3, e1, NULL }, + { "class", p_class, 1, 5, e1, NULL }, + { "change", p_change, 1, 6, NULL, NULL }, + { "expire", p_expire, 1, 6, NULL, NULL }, #ifdef RESTRICT_FULLNAME_CHANGE /* do not allow fullname changes */ - { "full name", p_gecos, 1, 9, e2, }, + { "full name", p_gecos, 1, 9, e2, NULL }, #else - { "full name", p_gecos, 0, 9, e2, }, + { "full name", p_gecos, 0, 9, e2, NULL }, #endif - { "office phone", p_gecos, 0, 12, e2, }, - { "home phone", p_gecos, 0, 10, e2, }, - { "office location", p_gecos, 0, 15, e2, }, - { "other information", p_gecos, 0, 11, e1, }, - { "home directory", p_hdir, 1, 14, e1, }, - { "shell", p_shell, 0, 5, e1, }, - { NULL, 0, }, + { "office phone", p_gecos, 0, 12, e2, NULL }, + { "home phone", p_gecos, 0, 10, e2, NULL }, + { "office location", p_gecos, 0, 15, e2, NULL }, + { "other information", p_gecos, 0, 11, e1, NULL }, + { "home directory", p_hdir, 1, 14, e1, NULL }, + { "shell", p_shell, 0, 5, e1, NULL }, + { NULL, NULL, 0, 0, NULL, NULL }, }; Index: util.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/util.c,v retrieving revision 1.9 diff -u -d -r1.9 util.c --- util.c 18 Mar 2002 09:49:18 -0000 1.9 +++ util.c 23 Mar 2002 00:46:57 -0000 @@ -32,13 +32,12 @@ */ #ifndef lint -#if 0 -static char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94"; -#endif -static const char rcsid[] = - "$FreeBSD: src/usr.bin/chpass/util.c,v 1.9 2002/03/18 09:49:18 cjc Exp $"; +static const char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include @@ -52,7 +51,7 @@ #include "chpass.h" #include "pathnames.h" -static char *months[] = +static const char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL }; @@ -80,7 +79,8 @@ time_t *store; { static struct tm *lt; - char *t, **mp; + char *t; + const char **mp; time_t tval; int day, month, year; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Mar 22 19:41:56 2002 Delivered-To: freebsd-audit@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id 47BF137B419; Fri, 22 Mar 2002 19:41:50 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g2N3Ztg68192; Fri, 22 Mar 2002 22:35:55 -0500 (EST) (envelope-from mike) Date: Fri, 22 Mar 2002 22:35:55 -0500 From: Mike Barcroft To: markm@freebsd.org Cc: audit@freebsd.org Subject: Re: chpass WARNS/lint fixes Message-ID: <20020322223555.I80338@espresso.q9media.com> References: <200203230056.g2N0uV1D047229@grimreaper.grondar.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200203230056.g2N0uV1D047229@grimreaper.grondar.org>; from markm@freebsd.org on Sat, Mar 23, 2002 at 12:56:31AM +0000 Organization: The FreeBSD Project Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG markm@freebsd.org writes: > Index: chpass.c > =================================================================== > RCS file: /home/ncvs/src/usr.bin/chpass/chpass.c,v > retrieving revision 1.20 > diff -u -d -r1.20 chpass.c > --- chpass.c 22 Mar 2002 01:19:26 -0000 1.20 > +++ chpass.c 23 Mar 2002 00:45:13 -0000 > @@ -39,10 +39,11 @@ > > #ifndef lint > static const char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94"; > -static const char rcsid[] = > - "$FreeBSD: src/usr.bin/chpass/chpass.c,v 1.20 2002/03/22 01:19:26 imp Exp $"; > #endif /* not lint */ The vendor ID should be restored from Rev 1.1 and then wrapped in #if 0 ... #endif. > +++ edit.c 23 Mar 2002 00:45:42 -0000 [...] > @@ -260,7 +261,7 @@ > pw->pw_name, pw->pw_passwd, (unsigned long)pw->pw_uid, > (unsigned long)pw->pw_gid, pw->pw_class, (long)pw->pw_change, > (long)pw->pw_expire, pw->pw_gecos, pw->pw_dir, > - pw->pw_shell) >= sizeof(buf)) { > + pw->pw_shell) >= (int)sizeof(buf)) { I don't like the idea of casting this down, but it won't make a difference in this case unless LINE_MAX becomes much larger. > Index: pw_yp.c > =================================================================== > RCS file: /home/ncvs/src/usr.bin/chpass/pw_yp.c,v > retrieving revision 1.19 > diff -u -d -r1.19 pw_yp.c > --- pw_yp.c 6 Feb 2002 15:26:04 -0000 1.19 > +++ pw_yp.c 23 Mar 2002 00:46:33 -0000 > @@ -34,35 +34,37 @@ > * Written by Bill Paul > * Center for Telecommunications Research > * Columbia University, New York City > - * > - * $FreeBSD: src/usr.bin/chpass/pw_yp.c,v 1.19 2002/02/06 15:26:04 des Exp $ > */ > > +#include > +__FBSDID("$FreeBSD$"); > + > #ifdef YP > -#include > -#include > -#include > -#include > -#include > -#include > +#include > #include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > #include > -#include > -#include > +#include New line needed. > #include > #include > -struct dom_binding {}; > #include > #include New line needed. > +#include > +#include > +#include > +#include > +#include > +#include > #include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +struct dom_binding {}; > + This seems bogus; what is it used for? > #include "pw_yp.h" > #include "ypxfr_extern.h" > #include "yppasswd_private.h" The rest looks okay. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Mar 22 20: 2:21 2002 Delivered-To: freebsd-audit@freebsd.org Received: from descent.robbins.dropbear.id.au (254.d.010.mel.iprimus.net.au [210.50.203.254]) by hub.freebsd.org (Postfix) with ESMTP id D858337B419; Fri, 22 Mar 2002 20:02:13 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2N415a03833; Sat, 23 Mar 2002 15:01:05 +1100 (EST) (envelope-from tim) Date: Sat, 23 Mar 2002 15:01:05 +1100 From: "Tim J. Robbins" To: "J. Mallett" Cc: freebsd-audit@FreeBSD.ORG, freebsd-standards@FreeBSD.ORG Subject: Re: patch for review: xargs standards compliance Message-ID: <20020323150105.A3813@descent.robbins.dropbear.id.au> References: <20020316192629.A5254@descent.robbins.dropbear.id.au> <20020316090004.A26394@FreeBSD.ORG> <20020316093507.B26394@FreeBSD.ORG> <20020316101434.A2192@FreeBSD.ORG> <20020322035231.A23277@FreeBSD.ORG> <20020322160802.B1338@descent.robbins.dropbear.id.au> <20020322151214.A26549@FreeBSD.ORG> <20020322160631.A31375@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020322160631.A31375@FreeBSD.ORG>; from jmallett@FreeBSD.ORG on Fri, Mar 22, 2002 at 04:06:32PM +0000 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Mar 22, 2002 at 04:06:32PM +0000, J. Mallett wrote: > One thing I am now unsure of that I'd forgotten all about is: > "Constructed arguments cannot grow larger than 255 bytes. " > > Should I errx() if strlen(*tmp) is >255, or should I augment strnsubst() > to take a size argument and not allow more than that amount to be > allocated, and furthermore, do I strlcat replstr for each match, or do I > do checks along the way to see if it is time to give up on replacing, and > just concatenate the rest of the string. I *think* given the language > relating to umber of replacements in the argument list, that I should TRY > to replace as many times as possible, up to five... $ echo hello | xargs -I xxx echo `perl -e 'print "A"x255;'`xxx xargs: Maximum argument size with insertion via xxx's exceeded Segmentation Fault $ uname -sr SunOS 5.8 Since SUS is biased towards SysV, you should probably print an error message and exit like Solaris tries to; no need for you to segfault like they do though ;) Also: $ echo hello | xargs -Ixxx a xxx b xxx c xxx d xxx e xxx f xxx xargs: too many args with xxx So it seems you should quit with an error when either of these limits are reached. This seems to be a flaw in the standard because these limits are (a) artifically low and (b) cannot be raised by implementors. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Mar 23 1:15:11 2002 Delivered-To: freebsd-audit@freebsd.org Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.139.170]) by hub.freebsd.org (Postfix) with ESMTP id 036BC37B404; Sat, 23 Mar 2002 01:15:07 -0800 (PST) Received: (from uucp@localhost) by storm.FreeBSD.org.uk (8.11.6/8.11.6) with UUCP id g2N9F5D10825; Sat, 23 Mar 2002 09:15:05 GMT (envelope-from mark@grimreaper.grondar.za) Received: from grimreaper (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.2/8.12.2) with ESMTP id g2N9CqFc002263; Sat, 23 Mar 2002 09:12:52 GMT (envelope-from mark@grimreaper.grondar.za) Message-Id: <200203230912.g2N9CqFc002263@grimreaper.grondar.org> To: Mike Barcroft Cc: audit@FreeBSD.ORG Subject: Re: chpass WARNS/lint fixes References: <20020322223555.I80338@espresso.q9media.com> In-Reply-To: <20020322223555.I80338@espresso.q9media.com> ; from Mike Barcroft "Fri, 22 Mar 2002 22:35:55 EST." Date: Sat, 23 Mar 2002 09:12:52 +0000 From: Mark Murray Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > @@ -39,10 +39,11 @@ > > > > #ifndef lint > > static const char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94"; > > -static const char rcsid[] = > > - "$FreeBSD: src/usr.bin/chpass/chpass.c,v 1.20 2002/03/22 01:19:26 imp Exp $"; > > #endif /* not lint */ > > The vendor ID should be restored from Rev 1.1 and then wrapped in > #if 0 ... #endif. There is a __FBSDID() a little later. Or are you talking about $Id$ from the original code? > > + > > +struct dom_binding {}; > > + > > This seems bogus; what is it used for? Nothing. It is bogus. :-) > The rest looks okay. Take 2 is on its way. M -- o Mark Murray \_ O.\_ Warning: this .sig is umop ap!sdn To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Mar 23 1:15:31 2002 Delivered-To: freebsd-audit@freebsd.org Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.139.170]) by hub.freebsd.org (Postfix) with ESMTP id 9764E37B419 for ; Sat, 23 Mar 2002 01:15:09 -0800 (PST) Received: (from uucp@localhost) by storm.FreeBSD.org.uk (8.11.6/8.11.6) with UUCP id g2N9F8n10826 for audit@freebsd.org; Sat, 23 Mar 2002 09:15:08 GMT (envelope-from root@grimreaper.grondar.za) Received: from grimreaper (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.2/8.12.2) with ESMTP id g2N9EEFc002274 for ; Sat, 23 Mar 2002 09:14:14 GMT (envelope-from root@grimreaper.grondar.za) Message-Id: <200203230914.g2N9EEFc002274@grimreaper.grondar.org> To: audit@freebsd.org Subject: chpass fixes take 2 (commit candidate) From: markm@freebsd.org Date: Sat, 23 Mar 2002 09:14:14 +0000 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Index: Makefile =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/Makefile,v retrieving revision 1.24 diff -u -d -r1.24 Makefile --- Makefile 13 Sep 2001 06:48:16 -0000 1.24 +++ Makefile 23 Mar 2002 00:51:47 -0000 @@ -2,7 +2,6 @@ # $FreeBSD: src/usr.bin/chpass/Makefile,v 1.24 2001/09/13 06:48:16 ru Exp $ PROG= chpass -CFLAGS+=-Wall SRCS= chpass.c edit.c field.c pw_copy.c pw_scan.c pw_util.c pw_yp.c \ table.c util.c ypxfr_misc.c ${GENSRCS} GENSRCS=yp.h yp_clnt.c yppasswd.h yppasswd_clnt.c yppasswd_private.h \ Index: chpass.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/chpass.c,v retrieving revision 1.20 diff -u -d -r1.20 chpass.c --- chpass.c 22 Mar 2002 01:19:26 -0000 1.20 +++ chpass.c 23 Mar 2002 00:45:13 -0000 @@ -39,10 +39,11 @@ #ifndef lint static const char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94"; -static const char rcsid[] = - "$FreeBSD: src/usr.bin/chpass/chpass.c,v 1.20 2002/03/22 01:19:26 imp Exp $"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -77,6 +78,8 @@ void baduser(void); void usage(void); +char localhost[] = "localhost"; + int main(argc, argv) int argc; @@ -135,7 +138,7 @@ #endif yp_domain = optarg; if (yp_server == NULL) - yp_server = "localhost"; + yp_server = localhost; #ifdef PARANOID } #endif Index: chpass.h =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/chpass.h,v retrieving revision 1.4 diff -u -d -r1.4 chpass.h --- chpass.h 22 Mar 2002 01:19:26 -0000 1.4 +++ chpass.h 23 Mar 2002 00:49:56 -0000 @@ -37,8 +37,9 @@ struct passwd; typedef struct _entry { - char *prompt; - int (*func)(), restricted, len; + const char *prompt; + int (*func)(char *, struct passwd *, struct _entry *); + int restricted, len; char *except, *save; } ENTRY; Index: edit.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/edit.c,v retrieving revision 1.19 diff -u -d -r1.19 edit.c --- edit.c 26 Jul 2001 23:27:10 -0000 1.19 +++ edit.c 23 Mar 2002 00:45:42 -0000 @@ -29,14 +29,15 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD: src/usr.bin/chpass/edit.c,v 1.19 2001/07/26 23:27:10 mike Exp $ */ #ifndef lint static const char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include @@ -100,7 +101,7 @@ struct passwd *pw; { FILE *fp; - char *bp, *p, *ttoa(); + char *bp, *p; if (!(fp = fdopen(fd, "w"))) pw_error(tempname, 1, 1); @@ -260,7 +261,7 @@ pw->pw_name, pw->pw_passwd, (unsigned long)pw->pw_uid, (unsigned long)pw->pw_gid, pw->pw_class, (long)pw->pw_change, (long)pw->pw_expire, pw->pw_gecos, pw->pw_dir, - pw->pw_shell) >= sizeof(buf)) { + pw->pw_shell) >= (int)sizeof(buf)) { warnx("entries too long"); free(p); return (0); Index: field.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/field.c,v retrieving revision 1.4 diff -u -d -r1.4 field.c --- field.c 6 Dec 1998 22:58:14 -0000 1.4 +++ field.c 23 Mar 2002 00:45:59 -0000 @@ -35,6 +35,9 @@ static const char sccsid[] = "@(#)field.c 8.4 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include @@ -56,7 +59,7 @@ p_login(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!*p) { warnx("empty login field"); @@ -85,10 +88,10 @@ p_passwd(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!*p) - pw->pw_passwd = ""; /* "NOLOGIN"; */ + pw->pw_passwd = strdup(""); /* "NOLOGIN"; */ else if (!(pw->pw_passwd = strdup(p))) { warnx("can't save password entry"); return (1); @@ -102,7 +105,7 @@ p_uid(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { uid_t id; char *np; @@ -130,7 +133,7 @@ p_gid(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { struct group *gr; gid_t id; @@ -163,10 +166,10 @@ p_class(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!*p) - pw->pw_class = ""; + pw->pw_class = strdup(""); else if (!(pw->pw_class = strdup(p))) { warnx("can't save entry"); return (1); @@ -180,7 +183,7 @@ p_change(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!atot(p, &pw->pw_change)) return (0); @@ -193,7 +196,7 @@ p_expire(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!atot(p, &pw->pw_expire)) return (0); @@ -205,11 +208,11 @@ int p_gecos(p, pw, ep) char *p; - struct passwd *pw; + struct passwd *pw __unused; ENTRY *ep; { if (!*p) - ep->save = ""; + ep->save = strdup(""); else if (!(ep->save = strdup(p))) { warnx("can't save entry"); return (1); @@ -222,7 +225,7 @@ p_hdir(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { if (!*p) { warnx("empty home directory field"); @@ -240,13 +243,13 @@ p_shell(p, pw, ep) char *p; struct passwd *pw; - ENTRY *ep; + ENTRY *ep __unused; { - char *t, *ok_shell(); + char *t; struct stat sbuf; if (!*p) { - pw->pw_shell = _PATH_BSHELL; + pw->pw_shell = strdup(_PATH_BSHELL); return (0); } /* only admin can change from or to "restricted" shells */ Index: pw_copy.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/pw_copy.c,v retrieving revision 1.11 diff -u -d -r1.11 pw_copy.c --- pw_copy.c 18 Mar 2002 02:22:53 -0000 1.11 +++ pw_copy.c 23 Mar 2002 00:46:11 -0000 @@ -37,6 +37,9 @@ static const char sccsid[] = "@(#)pw_copy.c 8.4 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + /* * This module is used to copy the master password file, replacing a single * record, by chpass(1) and passwd(1). Index: pw_yp.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/pw_yp.c,v retrieving revision 1.19 diff -u -d -r1.19 pw_yp.c --- pw_yp.c 6 Feb 2002 15:26:04 -0000 1.19 +++ pw_yp.c 23 Mar 2002 09:08:10 -0000 @@ -34,35 +34,39 @@ * Written by Bill Paul * Center for Telecommunications Research * Columbia University, New York City - * - * $FreeBSD: src/usr.bin/chpass/pw_yp.c,v 1.19 2002/02/06 15:26:04 des Exp $ */ +#include +__FBSDID("$FreeBSD$"); + #ifdef YP -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include +#include + #include #include -struct dom_binding {}; #include #include + +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include + +/* struct dom_binding {}; */ + #include "pw_yp.h" #include "ypxfr_extern.h" #include "yppasswd_private.h" @@ -77,6 +81,10 @@ 0, /* lorder */ }; +static char passwdbyname[] = "passwd.byname"; +static char localhost[] = "localhost"; +static char blank[] = ""; + int force_old = 0; int _use_yp = 0; int suser_override = 0; @@ -139,7 +147,7 @@ return; } -void +static void copy_local_pass(char *p, int m) { register char *t; @@ -178,7 +186,7 @@ * environment. */ static int -my_yp_match(char *server, char *domain, char *map, char *key, +my_yp_match(char *server, char *domain, const char *map, char *key, unsigned long keylen, char **result, unsigned long *resultlen) { ypreq_key ypkey; @@ -194,27 +202,17 @@ * the record we were looking for. Letting use_yp() know * that the lookup failed is sufficient. */ - if ((clnt = clnt_create(server, YPPROG,YPVERS,"udp")) == NULL) { + if ((clnt = clnt_create(server, YPPROG,YPVERS,"udp")) == NULL) return(1); -#ifdef notdef - warnx("failed to create UDP handle: %s", - clnt_spcreateerror(server)); - pw_error(tempname, 0, 1); -#endif - } ypkey.domain = domain; - ypkey.map = map; + ypkey.map = strdup(map); ypkey.key.keydat_len = keylen; ypkey.key.keydat_val = key; if ((ypval = ypproc_match_2(&ypkey, clnt)) == NULL) { clnt_destroy(clnt); return(1); -#ifdef notdef - warnx("%s",clnt_sperror(clnt,"YPPROC_MATCH failed")); - pw_error(tempname, 0, 1); -#endif } clnt_destroy(clnt); @@ -222,16 +220,6 @@ if (ypval->stat != YP_TRUE) { xdr_free(xdr_ypresp_val, (char *)ypval); return(1); -#ifdef notdef - int stat = ypval->stat; - xdr_free(xdr_ypresp_val, (char *)ypval); - if (stat == YP_NOMAP && strstr(map, "master.passwd")) - return(1); - if (stat == YP_NOKEY) - return(1); - warnx("ypmatch failed: %s", yperr_string(ypprot_err(stat))); - pw_error(tempname, 0, 1); -#endif } @@ -366,7 +354,7 @@ /* Get master server of passwd map. */ - if ((mastername = ypxfr_get_master(yp_domain, "passwd.byname", + if ((mastername = ypxfr_get_master(yp_domain, passwdbyname, yp_server, yp_server ? 0 : 1)) == NULL) { warnx("can't get name of master NIS server"); pw_error(tempname, 0, 1); @@ -394,11 +382,11 @@ } /* See if _we_ are the master server. */ - if (!force_old && !getuid() && (localport = getrpcport("localhost", + if (!force_old && !getuid() && (localport = getrpcport(localhost, YPPASSWDPROG, YPPASSWDPROC_UPDATE, IPPROTO_UDP)) != 0) { if (localport == rval) { suser_override = 1; - mastername = "localhost"; + mastername = localhost; } } @@ -427,7 +415,7 @@ CLIENT *clnt; char *master, *password; int *status = NULL; - struct rpc_err err; + struct rpc_err lerr; nconf = NULL; _use_yp = 1; @@ -449,9 +437,10 @@ master_yppasswd.newpw.pw_gecos = strdup(pw->pw_gecos); master_yppasswd.newpw.pw_dir = strdup(pw->pw_dir); master_yppasswd.newpw.pw_shell = strdup(pw->pw_shell); - master_yppasswd.newpw.pw_class = pw->pw_class != NULL ? - strdup(pw->pw_class) : ""; - master_yppasswd.oldpass = ""; /* not really needed */ + master_yppasswd.newpw.pw_class = pw->pw_class != NULL + ? strdup(pw->pw_class) + : blank; + master_yppasswd.oldpass = blank; /* not really needed */ master_yppasswd.domain = yp_domain; } else { yppasswd.newpw.pw_passwd = strdup(pw->pw_passwd); @@ -461,7 +450,7 @@ yppasswd.newpw.pw_gecos = strdup(pw->pw_gecos); yppasswd.newpw.pw_dir = strdup(pw->pw_dir); yppasswd.newpw.pw_shell = strdup(pw->pw_shell); - yppasswd.oldpass = ""; + yppasswd.oldpass = blank; } /* Get the user's password for authentication purposes. */ @@ -519,15 +508,15 @@ else status = yppasswdproc_update_1(&yppasswd, clnt); - clnt_geterr(clnt, &err); + clnt_geterr(clnt, &lerr); auth_destroy(clnt->cl_auth); clnt_destroy(clnt); /* Call failed: signal the error. */ - if (err.re_status != RPC_SUCCESS || status == NULL || *status) { - warnx("NIS update failed: %s", clnt_sperrno(err.re_status)); + if (lerr.re_status != RPC_SUCCESS || status == NULL || *status) { + warnx("NIS update failed: %s", clnt_sperrno(lerr.re_status)); pw_error(NULL, 0, 1); } Index: table.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/table.c,v retrieving revision 1.7 diff -u -d -r1.7 table.c --- table.c 23 Feb 1999 02:41:26 -0000 1.7 +++ table.c 23 Mar 2002 00:46:44 -0000 @@ -35,6 +35,9 @@ static const char sccsid[] = "@(#)table.c 8.3 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include "chpass.h" @@ -43,23 +46,23 @@ char e2[] = ":,"; ENTRY list[] = { - { "login", p_login, 1, 5, e1, }, - { "password", p_passwd, 1, 8, e1, }, - { "uid", p_uid, 1, 3, e1, }, - { "gid", p_gid, 1, 3, e1, }, - { "class", p_class, 1, 5, e1, }, - { "change", p_change, 1, 6, NULL, }, - { "expire", p_expire, 1, 6, NULL, }, + { "login", p_login, 1, 5, e1, NULL }, + { "password", p_passwd, 1, 8, e1, NULL }, + { "uid", p_uid, 1, 3, e1, NULL }, + { "gid", p_gid, 1, 3, e1, NULL }, + { "class", p_class, 1, 5, e1, NULL }, + { "change", p_change, 1, 6, NULL, NULL }, + { "expire", p_expire, 1, 6, NULL, NULL }, #ifdef RESTRICT_FULLNAME_CHANGE /* do not allow fullname changes */ - { "full name", p_gecos, 1, 9, e2, }, + { "full name", p_gecos, 1, 9, e2, NULL }, #else - { "full name", p_gecos, 0, 9, e2, }, + { "full name", p_gecos, 0, 9, e2, NULL }, #endif - { "office phone", p_gecos, 0, 12, e2, }, - { "home phone", p_gecos, 0, 10, e2, }, - { "office location", p_gecos, 0, 15, e2, }, - { "other information", p_gecos, 0, 11, e1, }, - { "home directory", p_hdir, 1, 14, e1, }, - { "shell", p_shell, 0, 5, e1, }, - { NULL, 0, }, + { "office phone", p_gecos, 0, 12, e2, NULL }, + { "home phone", p_gecos, 0, 10, e2, NULL }, + { "office location", p_gecos, 0, 15, e2, NULL }, + { "other information", p_gecos, 0, 11, e1, NULL }, + { "home directory", p_hdir, 1, 14, e1, NULL }, + { "shell", p_shell, 0, 5, e1, NULL }, + { NULL, NULL, 0, 0, NULL, NULL }, }; Index: util.c =================================================================== RCS file: /home/ncvs/src/usr.bin/chpass/util.c,v retrieving revision 1.9 diff -u -d -r1.9 util.c --- util.c 18 Mar 2002 09:49:18 -0000 1.9 +++ util.c 23 Mar 2002 00:46:57 -0000 @@ -32,13 +32,12 @@ */ #ifndef lint -#if 0 -static char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94"; -#endif -static const char rcsid[] = - "$FreeBSD: src/usr.bin/chpass/util.c,v 1.9 2002/03/18 09:49:18 cjc Exp $"; +static const char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include @@ -52,7 +51,7 @@ #include "chpass.h" #include "pathnames.h" -static char *months[] = +static const char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL }; @@ -80,7 +79,8 @@ time_t *store; { static struct tm *lt; - char *t, **mp; + char *t; + const char **mp; time_t tval; int day, month, year; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Mar 23 2: 8:28 2002 Delivered-To: freebsd-audit@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id B87B137B400 for ; Sat, 23 Mar 2002 02:08:24 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g2NA2Hp94438; Sat, 23 Mar 2002 05:02:17 -0500 (EST) (envelope-from mike) Date: Sat, 23 Mar 2002 05:02:17 -0500 From: Mike Barcroft To: Mark Murray Cc: audit@FreeBSD.ORG Subject: Re: chpass WARNS/lint fixes Message-ID: <20020323050217.J80338@espresso.q9media.com> References: <20020322223555.I80338@espresso.q9media.com> <200203230912.g2N9CqFc002263@grimreaper.grondar.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200203230912.g2N9CqFc002263@grimreaper.grondar.org>; from mark@grondar.za on Sat, Mar 23, 2002 at 09:12:52AM +0000 Organization: The FreeBSD Project Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Mark Murray writes: > > > @@ -39,10 +39,11 @@ > > > > > > #ifndef lint > > > static const char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94"; > > > -static const char rcsid[] = > > > - "$FreeBSD: src/usr.bin/chpass/chpass.c,v 1.20 2002/03/22 01:19:26 imp Exp $"; > > > #endif /* not lint */ > > > > The vendor ID should be restored from Rev 1.1 and then wrapped in > > #if 0 ... #endif. > > There is a __FBSDID() a little later. Or are you talking about $Id$ from the > original code? Yes, sorry, I was referring to foreign IDs (in this case UCB). See the description and example in style(9) for details. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Mar 23 14:29:41 2002 Delivered-To: freebsd-audit@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 84AF737B417 for ; Sat, 23 Mar 2002 14:29:16 -0800 (PST) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 23 Mar 2002 22:29:15 +0000 (GMT) To: freebsd-audit@freebsd.org Subject: Fix for bin/15510: df(1) does not lineup with large filesystems Date: Sat, 23 Mar 2002 22:29:15 +0000 From: Ian Dowse Message-ID: <200203232229.aa87310@salmon.maths.tcd.ie> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The patch below should address bin/15510. We keep track of the maximum width required for every variable-width field instead of just the first one. Note that this retains the following historical formatting behaviour: - double space after the "Filesystem" column; - double space before the "Mounted on" column; - overlapping of the "Capacity" heading with the "iused" column when the "-i" option is specified. These could easily be removed if desirable. Ian Index: df.c =================================================================== RCS file: /dump/FreeBSD-CVS/src/bin/df/df.c,v retrieving revision 1.36 diff -u -r1.36 df.c --- df.c 22 Feb 2002 20:57:53 -0000 1.36 +++ df.c 23 Mar 2002 21:49:50 -0000 @@ -91,6 +91,16 @@ #define TERA_SI_SZ (TERA_SZ(1000ULL)) #define PETA_SI_SZ (PETA_SZ(1000ULL)) +/* Maximum widths of various fields. */ +struct maxwidths { + int mntfrom; + int total; + int used; + int avail; + int iused; + int ifree; +}; + unsigned long long vals_si [] = {1, KILO_SI_SZ, MEGA_SI_SZ, GIGA_SI_SZ, TERA_SI_SZ, PETA_SI_SZ}; unsigned long long vals_base2[] = {1, KILO_2_SZ, MEGA_2_SZ, GIGA_2_SZ, TERA_2_SZ, PETA_2_SZ}; unsigned long long *valp; @@ -102,28 +112,36 @@ int bread(off_t, void *, int); int checkvfsname(const char *, char **); char *getmntpt(char *); +int longwidth(long); char *makenetvfslist(void); char **makevfslist(char *); void prthuman(struct statfs *, long); void prthumanval(double); -void prtstat(struct statfs *, int); +void prtstat(struct statfs *, struct maxwidths *); long regetmntinfo(struct statfs **, long, char **); -int ufs_df(char *, int); +int ufs_df(char *, struct maxwidths *); unit_t unit_adjust(double *); +void update_maxwidths(struct maxwidths *, struct statfs *); void usage(void); int aflag = 0, hflag, iflag, nflag; struct ufs_args mdev; +static __inline int imax(int a, int b) +{ + return (a > b ? a : b); +} + int main(int argc, char *argv[]) { struct stat stbuf; struct statfs statfsbuf, *mntbuf; + struct maxwidths maxwidths; const char *fstype; char *mntpath, *mntpt, **vfslist; long mntsize; - int ch, i, maxwidth, rv, width; + int ch, i, rv; fstype = "ufs"; @@ -184,27 +202,21 @@ argv += optind; mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); - maxwidth = 0; - for (i = 0; i < mntsize; i++) { - width = strlen(mntbuf[i].f_mntfromname); - if (width > maxwidth) - maxwidth = width; - } + bzero(&maxwidths, sizeof(maxwidths)); + for (i = 0; i < mntsize; i++) + update_maxwidths(&maxwidths, &mntbuf[i]); rv = 0; if (!*argv) { mntsize = regetmntinfo(&mntbuf, mntsize, vfslist); if (vfslist != NULL) { - maxwidth = 0; - for (i = 0; i < mntsize; i++) { - width = strlen(mntbuf[i].f_mntfromname); - if (width > maxwidth) - maxwidth = width; - } + bzero(&maxwidths, sizeof(maxwidths)); + for (i = 0; i < mntsize; i++) + update_maxwidths(&maxwidths, &mntbuf[i]); } for (i = 0; i < mntsize; i++) { if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) - prtstat(&mntbuf[i], maxwidth); + prtstat(&mntbuf[i], &maxwidths); } exit(rv); } @@ -234,13 +246,13 @@ } if (mount(fstype, mntpt, MNT_RDONLY, &mdev) != 0) { - rv = ufs_df(*argv, maxwidth) || rv; + rv = ufs_df(*argv, &maxwidths) || rv; (void)rmdir(mntpt); free(mntpath); continue; } else if (statfs(mntpt, &statfsbuf) == 0) { statfsbuf.f_mntonname[0] = '\0'; - prtstat(&statfsbuf, maxwidth); + prtstat(&statfsbuf, &maxwidths); } else { warn("%s", *argv); rv = 1; @@ -261,9 +273,11 @@ rv = 1; continue; } - if (argc == 1) - maxwidth = strlen(statfsbuf.f_mntfromname) + 1; - prtstat(&statfsbuf, maxwidth); + if (argc == 1) { + bzero(&maxwidths, sizeof(maxwidths)); + update_maxwidths(&maxwidths, &statfsbuf); + } + prtstat(&statfsbuf, &maxwidths); } return (rv); } @@ -372,54 +386,107 @@ * Print out status about a filesystem. */ void -prtstat(struct statfs *sfsp, int maxwidth) +prtstat(struct statfs *sfsp, struct maxwidths *mwp) { static long blocksize; static int headerlen, timesthrough; static const char *header; long used, availblks, inodes; - if (maxwidth < 11) - maxwidth = 11; if (++timesthrough == 1) { + mwp->mntfrom = imax(mwp->mntfrom, strlen("Filesystem")); if (hflag) { header = " Size"; - headerlen = strlen(header); - (void)printf("%-*.*s %-s Used Avail Capacity", - maxwidth, maxwidth, "Filesystem", header); + mwp->total = mwp->used = mwp->avail = strlen(header); } else { header = getbsize(&headerlen, &blocksize); - (void)printf("%-*.*s %-s Used Avail Capacity", - maxwidth, maxwidth, "Filesystem", header); + mwp->total = imax(mwp->total, headerlen); + } + mwp->used = imax(mwp->used, strlen("Used")); + mwp->avail = imax(mwp->avail, strlen("Avail")); + + (void)printf("%-*s %-*s %*s %*s Capacity", mwp->mntfrom, + "Filesystem", mwp->total, header, mwp->used, "Used", + mwp->avail, "Avail"); + if (iflag) { + mwp->iused = imax(mwp->iused, strlen(" iused")); + mwp->ifree = imax(mwp->ifree, strlen("ifree")); + (void)printf(" %*s %*s %%iused", mwp->iused - 2, + "iused", mwp->ifree, "ifree"); } - if (iflag) - (void)printf(" iused ifree %%iused"); (void)printf(" Mounted on\n"); } - (void)printf("%-*.*s", maxwidth, maxwidth, sfsp->f_mntfromname); + (void)printf("%-*s", mwp->mntfrom, sfsp->f_mntfromname); used = sfsp->f_blocks - sfsp->f_bfree; availblks = sfsp->f_bavail + used; if (hflag) { prthuman(sfsp, used); } else { - (void)printf(" %*ld %8ld %8ld", headerlen, + (void)printf(" %*ld %*ld %*ld", mwp->total, fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize), - fsbtoblk(used, sfsp->f_bsize, blocksize), - fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize)); + mwp->used, fsbtoblk(used, sfsp->f_bsize, blocksize), + mwp->avail, fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, + blocksize)); } (void)printf(" %5.0f%%", availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0); if (iflag) { inodes = sfsp->f_files; used = inodes - sfsp->f_ffree; - (void)printf(" %7ld %7ld %5.0f%% ", used, sfsp->f_ffree, - inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0); + (void)printf(" %*ld %*ld %4.0f%% ", mwp->iused, used, + mwp->ifree, sfsp->f_ffree, inodes == 0 ? 100.0 : + (double)used / (double)inodes * 100.0); } else (void)printf(" "); (void)printf(" %s\n", sfsp->f_mntonname); } /* + * Update the maximum field-width information in `mwp' based on + * the filesystem specified by `sfsp'. + */ +void +update_maxwidths(struct maxwidths *mwp, struct statfs *sfsp) +{ + static long blocksize; + int dummy; + + if (blocksize == 0) + getbsize(&dummy, &blocksize); + + mwp->mntfrom = imax(mwp->mntfrom, strlen(sfsp->f_mntfromname)); + mwp->total = imax(mwp->total, longwidth(fsbtoblk(sfsp->f_blocks, + sfsp->f_bsize, blocksize))); + mwp->used = imax(mwp->used, longwidth(fsbtoblk(sfsp->f_blocks - + sfsp->f_bfree, sfsp->f_bsize, blocksize))); + mwp->avail = imax(mwp->avail, longwidth(fsbtoblk(sfsp->f_bavail, + sfsp->f_bsize, blocksize))); + mwp->iused = imax(mwp->iused, longwidth(sfsp->f_files - + sfsp->f_ffree)); + mwp->ifree = imax(mwp->ifree, longwidth(sfsp->f_ffree)); +} + +/* Return the width in characters of the specified long. */ +int +longwidth(long val) +{ + int len; + + len = 0; + /* Negative or zero values require one extra digit. */ + if (val <= 0) { + val = -val; + len++; + } + while (val > 0) { + len++; + val /= 10; + } + + return (len); +} + +/* * This code constitutes the pre-system call Berkeley df code for extracting * information from filesystem superblocks. */ @@ -433,7 +500,7 @@ int rfd; int -ufs_df(char *file, int maxwidth) +ufs_df(char *file, struct maxwidths *mwp) { struct statfs statfsbuf; struct statfs *sfsp; @@ -469,7 +536,7 @@ mntpt = ""; memmove(&sfsp->f_mntonname[0], mntpt, (size_t)MNAMELEN); memmove(&sfsp->f_mntfromname[0], file, (size_t)MNAMELEN); - prtstat(sfsp, maxwidth); + prtstat(sfsp, mwp); (void)close(rfd); return (0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Mar 23 15:33:59 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 939D537B41C for ; Sat, 23 Mar 2002 15:33:56 -0800 (PST) Received: from hades.hell.gr (patr530-a234.otenet.gr [212.205.215.234]) by mailsrv.otenet.gr (8.12.2/8.12.2) with ESMTP id g2NNXrIg003875 for ; Sun, 24 Mar 2002 01:33:54 +0200 (EET) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.2/8.12.2) with ESMTP id g2NNXqbe096649 for ; Sun, 24 Mar 2002 01:33:52 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from charon@localhost) by hades.hell.gr (8.12.2/8.12.2/Submit) id g2NNXq39096648 for audit@freebsd.org; Sun, 24 Mar 2002 01:33:52 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Sun, 24 Mar 2002 01:33:50 +0200 From: Giorgos Keramidas To: audit@freebsd.org Subject: cron manpage (modtime -> modification time) Message-ID: <20020323233350.GA96606@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG How about this? Index: cron/cron.8 =================================================================== RCS file: /home/ncvs/src/usr.sbin/cron/cron/cron.8,v retrieving revision 1.18 diff -2 -u -r1.18 cron.8 --- cron/cron.8 16 Jan 2002 14:12:02 -0000 1.18 +++ cron/cron.8 11 Mar 2002 21:47:52 -0000 @@ -59,15 +59,15 @@ Additionally, .Nm -checks each minute to see if its spool directory's modtime (or the modtime +checks each minute to see if its spool directory's modification time (or the modification time on .Pa /etc/crontab ) has changed, and if it has, .Nm -will then examine the modtime on all crontabs and reload those which have +will then examine the modification time on all crontabs and reload those which have changed. Thus .Nm need not be restarted whenever a crontab file is modified. Note that the .Xr crontab 1 -command updates the modtime of the spool directory whenever it changes a +command updates the modification time of the spool directory whenever it changes a crontab. .Pp To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Mar 23 15:45:34 2002 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.trit.org (bazooka.trit.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 57A3F37B419; Sat, 23 Mar 2002 15:45:32 -0800 (PST) Received: by bazooka.trit.org (Postfix, from userid 1000) id 16D083E2F; Sat, 23 Mar 2002 23:45:32 +0000 (UTC) Received: from bazooka (localhost [127.0.0.1]) by bazooka.trit.org (Postfix) with ESMTP id 12BB93C12E; Sat, 23 Mar 2002 23:45:32 +0000 (UTC) To: Giorgos Keramidas Cc: audit@freebsd.org Subject: Re: cron manpage (modtime -> modification time) In-Reply-To: <20020323233350.GA96606@hades.hell.gr>; from keramida@freebsd.org on "Sun, 24 Mar 2002 01:33:50 +0200" Date: Sat, 23 Mar 2002 23:45:27 +0000 From: Dima Dorfman Message-Id: <20020323234532.16D083E2F@bazooka.trit.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Giorgos Keramidas wrote: > Index: cron/cron.8 ... > @@ -59,15 +59,15 @@ > Additionally, > .Nm > -checks each minute to see if its spool directory's modtime (or the modtime > +checks each minute to see if its spool directory's modification time (or the modification time > on > .Pa /etc/crontab ) I think it would be appropriate to wrap the line as usual (< 80 characters). The change is easy to see, so it shouldn't make life any more difficult for the translators. Likewise for the other two changes. Otherwise, this looks good; modtime is definitely wrong. mtime might be okay, but modification time is even better. Thanks. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Mar 23 15:51:12 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 62A0E37B400 for ; Sat, 23 Mar 2002 15:51:07 -0800 (PST) Received: from hades.hell.gr (patr530-a234.otenet.gr [212.205.215.234]) by mailsrv.otenet.gr (8.12.2/8.12.2) with ESMTP id g2NNosIg014800; Sun, 24 Mar 2002 01:51:01 +0200 (EET) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.2/8.12.2) with ESMTP id g2NNoqbe096888; Sun, 24 Mar 2002 01:50:52 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from charon@localhost) by hades.hell.gr (8.12.2/8.12.2/Submit) id g2NNoofw096887; Sun, 24 Mar 2002 01:50:50 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Sun, 24 Mar 2002 01:50:49 +0200 From: Giorgos Keramidas To: Dima Dorfman Cc: audit@freebsd.org Subject: Re: cron manpage (modtime -> modification time) Message-ID: <20020323235049.GA96851@hades.hell.gr> References: <20020323233350.GA96606@hades.hell.gr> <20020323234532.16D083E2F@bazooka.trit.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020323234532.16D083E2F@bazooka.trit.org> User-Agent: Mutt/1.3.28i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2002-03-23 23:45, Dima Dorfman wrote: > Giorgos Keramidas wrote: > > Index: cron/cron.8 > ... > > @@ -59,15 +59,15 @@ > > Additionally, > > .Nm > > -checks each minute to see if its spool directory's modtime (or the modtime > > +checks each minute to see if its spool directory's modification time (or the modification time > > on > > .Pa /etc/crontab ) > > I think it would be appropriate to wrap the line as usual (< 80 > characters). The change is easy to see, so it shouldn't make life any > more difficult for the translators. That's what kept me from wrapping. I meant to ask too, but thought I could do it in two parts anyway. If it's ok to wrap in the same change (as in, nobody objects throwing flaming torches at the two of us), I'll wrap and make the change later tonight :) Giorgos Keramidas FreeBSD Documentation Project keramida@{freebsd.org,ceid.upatras.gr} http://www.FreeBSD.org/docproj/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Mar 23 16:47:24 2002 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.trit.org (bazooka.trit.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 1647E37B41D for ; Sat, 23 Mar 2002 16:47:18 -0800 (PST) Received: by bazooka.trit.org (Postfix, from userid 1000) id 91CAB3E2F; Sun, 24 Mar 2002 00:47:17 +0000 (UTC) Received: from bazooka (localhost [127.0.0.1]) by bazooka.trit.org (Postfix) with ESMTP id 8D7373C12E; Sun, 24 Mar 2002 00:47:17 +0000 (UTC) To: Giorgos Keramidas Cc: audit@freebsd.org Subject: Re: cron manpage (modtime -> modification time) In-Reply-To: <20020323235049.GA96851@hades.hell.gr>; from keramida@ceid.upatras.gr on "Sun, 24 Mar 2002 01:50:49 +0200" Date: Sun, 24 Mar 2002 00:47:12 +0000 From: Dima Dorfman Message-Id: <20020324004717.91CAB3E2F@bazooka.trit.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Giorgos Keramidas wrote: > On 2002-03-23 23:45, Dima Dorfman wrote: > > Giorgos Keramidas wrote: > > > Index: cron/cron.8 > > ... > > > @@ -59,15 +59,15 @@ > > > Additionally, > > > .Nm > > > -checks each minute to see if its spool directory's modtime (or the modtime > > > +checks each minute to see if its spool directory's modification time (orthe modification time > > > on > > > .Pa /etc/crontab ) > > > > I think it would be appropriate to wrap the line as usual (< 80 > > characters). The change is easy to see, so it shouldn't make life any > > more difficult for the translators. > > That's what kept me from wrapping. I meant to ask too, but thought I could > do it in two parts anyway. If it's ok to wrap in the same change (as in, > nobody objects throwing flaming torches at the two of us), I'll wrap and > make the change later tonight :) Well, you're a translator, so you should know better than me :-). I think what people typically object to is justifying paragraphs after minor wording changes. Specifically, you shouldn't add words to a line that did *not* change to justify a paragraph; I think it's okay to break the line you're changing into two as long as it's clear what the change is. Perhaps an example is in order to demonstrate what I mean. I'll use DocBook since it has more paragraphs that really look like paragraphs, but this applies to manual pages, too. This kind of change, where I break the modified line into two, is okay: % @@ -12,7 +12,8 @@ FreeBSD uses XFree86 to provide users with a powerful graphical user interface. XFree86 is a open-source - implementation of the X Window System. This chapter + implementation of the X Window System (*not* called X Window*s). + This chapter will cover installation and configuration of XFree86 on a FreeBSD system. For more information on XFree86 and video hardware that it supports, check the FreeBSD uses XFree86 to provide users with a powerful graphical user interface. XFree86 is a open-source - implementation of the X Window System. This chapter - will cover installation and configuration of XFree86 on a + implementation of the X Window System (*not* called X Window*s). + This chapter will cover installation and configuration of XFree86 on a FreeBSD system. For more information on XFree86 and video hardware that it supports, check the XFree86 web site. % This looks like I changed something after "will cover", but I didn't. Disclaimer: I'm not a translator. The above is based mostly on previous experiences, my own experiences with trying to figure out what changed (e.g., if I'm not sure that the change was right), and logic. I also don't feel strongly about this, so if you want to do it in two changes, one to change the wording and one to fix the style, feel free :-). To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message