From 418d3e93346aac2c3a293ee069069cff88f1d3e7 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Sun, 18 May 2008 19:48:58 +0200 Subject: [PATCH] Embed program version and database version in the generated script --- .gitignore | 1 + Makefile | 18 ++++++++++++++++-- dowkd.in | 7 ++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index cef0b6c..e1a2135 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /dowkd /dowkd.db +/dowkd.blacklist* diff --git a/Makefile b/Makefile index a842e4a..b9a2a13 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,23 @@ BLACKLIST_FILES := data/DSA-1024 data/RSA-2048 \ export LC_ALL=C +.PHONY: all force + all: dowkd -dowkd: dowkd.in $(BLACKLIST_FILES) +dowkd: dowkd.in dowkd.blacklist dowkd.blacklist.md5 force -rm $@ 2> /dev/null || true perl -c dowkd.in - (cat dowkd.in ; sort -u $(BLACKLIST_FILES)) > dowkd + (sed -e s/@PROGRAM_VERSION@/$$(git describe)/ \ + -e s/@DB_VERSION@/$$(cat dowkd.blacklist.md5)/ < dowkd.in ; \ + cat dowkd.blacklist) > dowkd + +dowkd.blacklist: $(BLACKLIST_FILES) + -rm $@ 2> /dev/null || true + sort -u $(BLACKLIST_FILES) -o $@ + +dowkd.blacklist.md5: dowkd.blacklist + -rm $@ 2> /dev/null || true + md5sum $^ | awk '{print $$1}' > $@ + +force: diff --git a/dowkd.in b/dowkd.in index eec6518..2520dfc 100644 --- a/dowkd.in +++ b/dowkd.in @@ -39,6 +39,7 @@ COMMAND is one of: user: examine user SSH keys for weakness; examine all users if no users are given help: show this help screen + version: show version information OPTIONS is one pf: @@ -67,7 +68,8 @@ use File::Temp; use Fcntl; use IO::Handle; -my $db_version = '3'; +my $db_version = '@DB_VERSION@'; +my $program_version = '@PROGRAM_VERSION@'; my $db_file = 'dowkd.db'; @@ -446,6 +448,9 @@ if (@ARGV) { } elsif ($cmd eq 'help') { help; exit 0; + } elsif ($cmd eq 'version') { + print "dowkd $program_version (database $db_version)\n"; + exit 0; } else { die "error: invalid command, use \"help\" to get help\n"; } -- 2.11.4.GIT