i had the idea to implement an expiration date for flashrom binaries (i.e. a time bomb). in the case distributions ship ancient binaries (in the future) this may save a bunch of hardware.
i noted two reactions back then when i proposed this idea on IRC in my todo.txt: <twice11> If I validated software to work on some system, I don't want it to suddenly break one year later. <agaran> twice11: but kind notify that version you use is %d days old (and repeated every multiple of time or 100days or so) could be nice this proof of concept is probably not mergeable - especially the strptime() might be a problem (alternatives welcome), but i still think it is worth to think about something like this. comments? -- Kind regards/Mit freundlichen Grüßen, Stefan Tauner
>From 4ee0db973995d5a0b6903111e149100f6635df55 Mon Sep 17 00:00:00 2001 From: Stefan Tauner <[email protected]> Date: Fri, 8 Jul 2011 13:27:17 +0200 Subject: [PATCH] warn the user if flashrom is x months old Signed-off-by: Stefan Tauner <[email protected]> --- Makefile | 10 +++++++++- flash.h | 3 +++ flashrom.c | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 1 deletions(-) diff --git a/Makefile b/Makefile index a35df06..c77fcbe 100644 --- a/Makefile +++ b/Makefile @@ -225,7 +225,14 @@ RELEASE := 0.9.3 VERSION := $(RELEASE)-r$(SVNVERSION) RELEASENAME ?= $(VERSION) -SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"' +# Get the last commit time of the current branch in ISO 8601 format (i.e. "%Y-%m-%dT%H:%M:%S") by... +# - parsing svn info (ugly) +# - using git log +# - using the current date (rationale: last commit was no later than $NOW for sure) +# - "unknown" +HEADDATE := $(shell LC_ALL=C svn info --xml --non-interactive 2>/dev/null | grep -oP "(?<=<date>).*()?=</date>" || git log -1 --format="%ci" 2>/dev/null | cut -b 1-19 | tr ' ' T || date +"%Y-%m-%dT%H:%M:%S" 2>/dev/null || echo unknown) + +SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"' -D'FLASHROM_HEADDATE="$(HEADDATE)"' # Always enable internal/onboard support for now. CONFIG_INTERNAL ?= yes @@ -600,6 +607,7 @@ export: @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME) @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME) @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile + @sed "s/^HEADDATE.*/HEADDATE := $(HEADDATE)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/ diff --git a/flash.h b/flash.h index 9c6d535..4d47e48 100644 --- a/flash.h +++ b/flash.h @@ -227,6 +227,9 @@ int write_buf_to_file(unsigned char *buf, unsigned long size, const char *filena /* Something happened that shouldn't happen, but we can go on */ #define ERROR_NONFATAL 0x100 +/* Number of months before an appeal to upgrade is displayed at runtime */ +#define OLD_MONTHS 0 + /* cli_output.c */ /* Let gcc and clang check for correct printf-style format strings. */ int print(int type, const char *fmt, ...) __attribute__((format(printf, 2, 3))); diff --git a/flashrom.c b/flashrom.c index d5892ca..6a24306 100644 --- a/flashrom.c +++ b/flashrom.c @@ -21,6 +21,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#define _XOPEN_SOURCE 500 #include <stdio.h> #include <sys/types.h> #ifndef __LIBPAYLOAD__ @@ -31,6 +32,7 @@ #include <stdlib.h> #include <ctype.h> #include <getopt.h> +#include <time.h> #if HAVE_UTSNAME == 1 #include <sys/utsname.h> #endif @@ -1681,8 +1683,21 @@ void print_sysinfo(void) void print_version(void) { + struct tm tm; + time_t now = time(NULL); + time_t then; msg_ginfo("flashrom v%s", flashrom_version); print_sysinfo(); + if (strptime(FLASHROM_HEADDATE, "%Y-%m-%dT%H:%M:%S", &tm) != NULL && + now != (time_t) -1 && (then = mktime(&tm)) != (time_t) -1 && + difftime(now, then) > OLD_MONTHS * 30*24*60*60) { + msg_ginfo("WARNING: This version of flashrom is older than " + "%d months (last change date is %s).\n", + OLD_MONTHS, FLASHROM_HEADDATE); + msg_ginfo("flashrom can be dangerous to use - especially on " + "new hardware that was not\navailable back when this version " + "was released. Please upgrade!\n"); + } } void print_banner(void) -- 1.7.1
_______________________________________________ flashrom mailing list [email protected] http://www.flashrom.org/mailman/listinfo/flashrom
