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