diff options
author | David Howells <dhowells@redhat.com> | 2011-08-31 17:46:56 +0100 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2011-08-31 17:46:56 +0100 |
commit | 64efa82d6f54eddac1f4d4f5bd8e6ceaba1a413b (patch) | |
tree | 028a152663e2278050e4f3827aa41a89b349abb0 | |
parent | 3bed09463eb231069c41885da2ffd49ee0039cb9 (diff) | |
download | keyutils-64efa82d6f54eddac1f4d4f5bd8e6ceaba1a413b.tar.gz |
Store version info in library and allow it to be displayed
The package version number and build date are stored in the library in:
const char keyutils_version_string[];
const char keyutils_build_string[];
And are displayable with the programs built as part of it:
# keyctl --version
keyctl from keyutils-1.5.3 (Built 2011-08-24)
# request-key --version
request-key from keyutils-1.5.3 (Built 2011-08-24)
The DNS query resolver gets extended version information as it already has its
own version number:
# key.dns_resolver --version
version: 1.0 from keyutils-1.5.3 (2011-08-24)
(the keyutils version is simply appended to the original).
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | key.dns_resolver.c | 5 | ||||
-rw-r--r-- | keyctl.1 | 14 | ||||
-rw-r--r-- | keyctl.c | 13 | ||||
-rw-r--r-- | keyutils.c | 3 | ||||
-rw-r--r-- | keyutils.h | 3 | ||||
-rw-r--r-- | keyutils.spec | 1 | ||||
-rw-r--r-- | request-key.c | 6 |
8 files changed, 51 insertions, 4 deletions
@@ -1,5 +1,5 @@ CPPFLAGS := -I. -CFLAGS := $(CPPFLAGS) -g -Wall -Werror +CFLAGS := -g -Wall -Werror INSTALL := install DESTDIR := SPECFILE := keyutils.spec @@ -99,8 +99,12 @@ $(ARLIB): keyutils.o $(AR) rcs $@ $< endif +VCPPFLAGS := -DPKGBUILD="\"$(shell date -u +%F)\"" +VCPPFLAGS += -DPKGVERSION="\"keyutils-$(VERSION)\"" +VCPPFLAGS += -DAPIVERSION="\"libkeyutils-$(APIVERSION)\"" + keyutils.o: keyutils.c keyutils.h Makefile - $(CC) $(CPPFLAGS) $(CFLAGS) -UNO_GLIBC_KEYERR -o $@ -c $< + $(CC) $(CPPFLAGS) $(VCPPFLAGS) $(CFLAGS) -UNO_GLIBC_KEYERR -o $@ -c $< $(DEVELLIB): $(SONAME) @@ -115,7 +119,7 @@ $(LIBNAME): keyutils.os version.lds Makefile $(CC) $(CFLAGS) -fPIC $(LDFLAGS) $(LIBVERS) -o $@ keyutils.os $(LIBLIBS) keyutils.os: keyutils.c keyutils.h Makefile - $(CC) $(CFLAGS) -fPIC -o $@ -c $< + $(CC) $(CPPFLAGS) $(VCPPFLAGS) $(CFLAGS) -fPIC -o $@ -c $< ############################################################################### # diff --git a/key.dns_resolver.c b/key.dns_resolver.c index 49857a5..249dcf3 100644 --- a/key.dns_resolver.c +++ b/key.dns_resolver.c @@ -649,7 +649,10 @@ int main(int argc, char *argv[]) debug_mode = 1; continue; case 'V': - printf("version: %s\n", DNS_PARSE_VERSION); + printf("version: %s from %s (%s)\n", + DNS_PARSE_VERSION, + keyutils_version_string, + keyutils_build_string); exit(0); case 'v': verbose++; @@ -11,6 +11,8 @@ .SH NAME keyctl - Key management facility control .SH SYNOPSIS +\fBkeyctl\fR --version +.br \fBkeyctl\fR show .br \fBkeyctl\fR add <type> <desc> <data> <keyring> @@ -138,6 +140,18 @@ Any non-ambiguous shortening of a command name may be used in lieu of the full command name. This facility should not be used in scripting as new commands may be added in future that then cause ambiguity. .P +(*) \fBDisplay the package version number\fR +.P +\fBkeyctl --version\fR +.P +This command prints the package version number and build date and exits: +.P +.RS +testbox>keyctl --version +.br +keyctl from keyutils-1.5.3 (Built 2011-08-24) +.RE +.P (*) \fBShow process keyrings\fR .P \fBkeyctl show\fR @@ -27,6 +27,7 @@ struct command { const char *format; }; +static int act_keyctl___version(int argc, char *argv[]); static int act_keyctl_show(int argc, char *argv[]); static int act_keyctl_add(int argc, char *argv[]); static int act_keyctl_padd(int argc, char *argv[]); @@ -63,6 +64,7 @@ static int act_keyctl_reap(int argc, char *argv[]); static int act_keyctl_purge(int argc, char *argv[]); const struct command commands[] = { + { act_keyctl___version, "--version", "" }, { act_keyctl_add, "add", "<type> <desc> <data> <keyring>" }, { act_keyctl_chgrp, "chgrp", "<key> <gid>" }, { act_keyctl_chown, "chown", "<key> <uid>" }, @@ -223,6 +225,17 @@ static void format(void) /*****************************************************************************/ /* + * Display version information + */ +static int act_keyctl___version(int argc, char *argv[]) +{ + printf("keyctl from %s (Built %s)\n", + keyutils_version_string, keyutils_build_string); + return 0; +} + +/*****************************************************************************/ +/* * grab data from stdin */ static char *grab_stdin(void) @@ -21,6 +21,9 @@ #include <asm/unistd.h> #include "keyutils.h" +const char keyutils_version_string[] = PKGVERSION; +const char keyutils_build_string[] = PKGBUILD; + #ifdef NO_GLIBC_KEYERR static int error_inited; static void (*libc_perror)(const char *msg); @@ -14,6 +14,9 @@ #include <stdint.h> +extern const char keyutils_version_string[]; +extern const char keyutils_build_string[]; + /* key serial number */ typedef int32_t key_serial_t; diff --git a/keyutils.spec b/keyutils.spec index 64c8d22..6033af1 100644 --- a/keyutils.spec +++ b/keyutils.spec @@ -95,6 +95,7 @@ rm -rf $RPM_BUILD_ROOT %changelog * Wed Aug 14 2011 David Howells <dhowells@redhat.com> - Adjust the manual page for 'keyctl unlink' to show keyring is optional. +- Add --version support for the keyutils version and build date. * Thu Aug 11 2011 David Howells <dhowells@redhat.com> - 1.5.3-1 - Make the keyutils rpm depend on the same keyutils-libs rpm version. diff --git a/request-key.c b/request-key.c index 4d07129..ade1cea 100644 --- a/request-key.c +++ b/request-key.c @@ -130,6 +130,12 @@ int main(int argc, char *argv[]) char *ktype, *kdesc, *buf, *callout_info; int ret, ntype, dpos, n, fd; + if (argc == 2 && strcmp(argv[1], "--version") == 0) { + printf("request-key from %s (Built %s)\n", + keyutils_version_string, keyutils_build_string); + return 0; + } + signal(SIGSEGV, oops); signal(SIGBUS, oops); signal(SIGPIPE, SIG_IGN); |