diff options
author | David Howells <dhowells@redhat.com> | 2010-02-22 15:39:39 +0000 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2010-02-22 16:01:39 +0000 |
commit | 9be94079efbccd689ae346184c9600cd6fb4aa9e (patch) | |
tree | 26f2c111ae71e04412b0ae9d18960ba707d1c4fd | |
parent | 5291796474869579f151f7821410e3ef96d1fa7e (diff) | |
download | keyutils-9be94079efbccd689ae346184c9600cd6fb4aa9e.tar.gz |
keyutils historical version 0.3
- Must invoke initialisation from perror() override in libkeyutils
- Minor UI changes
- Bump version to permit building in main repositories.
- Don't attempt to define the error codes in the header file.
- Pass the release ID through to the makefile to affect the shared library name.
- Build in the perror() override to get the key error strings displayed.
- Need a defattr directive after each files directive.
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | keyctl.c | 15 | ||||
-rw-r--r-- | keyutil.c | 51 | ||||
-rw-r--r-- | keyutil.h | 14 | ||||
-rw-r--r-- | keyutils.spec | 59 |
5 files changed, 56 insertions, 87 deletions
@@ -2,7 +2,9 @@ CFLAGS := -g -Wall -O2 INSTALL := install DESTDIR := MAJOR := 0 -VERSION := $(MAJOR).1 +MINOR := 3 +RELEASE := +VERSION := $(MAJOR).$(MINOR)$(RELEASE) NO_GLIBC_KEYERR := 0 NO_GLIBC_KEYSYS := 0 BUILDFOR := @@ -654,11 +654,16 @@ static int act_keyctl_rlist(int argc, char *argv[]) count /= sizeof(key_serial_t); /* list the keys in the keyring */ - pk = keylist; - do { - key = *pk++; - printf("%d%c", key, count == 1 ? '\n' : ' '); - } while (--count); + if (count <= 0) { + printf("\n"); + } + else { + pk = keylist; + for (; count > 0; count--) { + key = *pk++; + printf("%d%c", key, count == 1 ? '\n' : ' '); + } + } return 0; @@ -22,9 +22,9 @@ #ifdef NO_GLIBC_KEYERR static int error_inited; -static int (*libc_xpg_strerror_r)(int errnum, char *buf, size_t n); -static char *(*libc_strerror_r)(int errnum, char *buf, size_t n); static void (*libc_perror)(const char *msg); +static char *(*libc_strerror_r)(int errnum, char *buf, size_t n); +//static int (*libc_xpg_strerror_r)(int errnum, char *buf, size_t n); #define RTLD_NEXT ((void *) -1L) #endif @@ -241,16 +241,46 @@ int keyctl_read_alloc(key_serial_t id, void **_buffer) */ static void error_init(void) { - libc_xpg_strerror_r = dlsym(RTLD_NEXT,"xpg_strerror_r"); - if (!libc_xpg_strerror_r) + char *err; + + error_inited = 1; + + dlerror(); + + libc_perror = dlsym(RTLD_NEXT,"perror"); + if (!libc_perror) { + fprintf(stderr, "Failed to look up next perror\n"); + err = dlerror(); + if (err) + fprintf(stderr, "%s\n", err); abort(); + } + + //fprintf(stderr, "next perror at %p\n", libc_perror); + libc_strerror_r = dlsym(RTLD_NEXT,"strerror_r"); - if (!libc_strerror_r) + if (!libc_strerror_r) { + fprintf(stderr, "Failed to look up next strerror_r\n"); + err = dlerror(); + if (err) + fprintf(stderr, "%s\n", err); abort(); - libc_perror = dlsym(RTLD_NEXT,"perror"); - if (!libc_perror) + } + + //fprintf(stderr, "next strerror_r at %p\n", libc_strerror_r); + +#if 0 + libc_xpg_strerror_r = dlsym(RTLD_NEXT,"xpg_strerror_r"); + if (!libc_xpg_strerror_r) { + fprintf(stderr, "Failed to look up next xpg_strerror_r\n"); + err = dlerror(); + if (err) + fprintf(stderr, "%s\n", err); abort(); - error_inited = 1; + } + + //fprintf(stderr, "next xpg_strerror_r at %p\n", libc_xpg_strerror_r); +#endif } /* end error_init() */ @@ -305,6 +335,7 @@ char *strerror_r(int errnum, char *buf, size_t n) } /* end strerror_r() */ +#if 0 /*****************************************************************************/ /* * overload glibc's strerror_r() with a version that knows about key errors @@ -353,6 +384,7 @@ int xpg_strerror_r(int errnum, char *buf, size_t n) } } /* end xpg_strerror_r() */ +#endif /*****************************************************************************/ /* @@ -360,6 +392,9 @@ int xpg_strerror_r(int errnum, char *buf, size_t n) */ void perror(const char *msg) { + if (!error_inited) + error_init(); + switch (errno) { case ENOKEY: fprintf(stderr, "%s: Requested key not available\n", msg); @@ -74,20 +74,6 @@ typedef uint32_t key_perm_t; #define KEYCTL_NEGATE 13 /* negate a partially constructed key */ #define KEYCTL_SET_REQKEY_KEYRING 14 /* set default request-key keyring */ -/* key management error codes */ -#ifdef NO_GLIBC_KEYERR -#if defined(__i386__) || defined(__PPC64__) || defined(__PPC__) || defined(__x86_64__) - -#define ENOKEY 126 /* Required key not available */ -#define EKEYEXPIRED 127 /* Key has expired */ -#define EKEYREVOKED 128 /* Key has been revoked */ -#define EKEYREJECTED 129 /* Key was rejected by service */ - -#else -#error key management error codes not supported on this arch -#endif -#endif - /* * syscall wrappers */ diff --git a/keyutils.spec b/keyutils.spec deleted file mode 100644 index 58378c2..0000000 --- a/keyutils.spec +++ /dev/null @@ -1,59 +0,0 @@ -%define vermajor 0 -%define version %{vermajor}.1 -%define _exec_prefix / - -Summary: Linux Key Management Utilities -Name: keyutils -Version: %{version} -Release: 1 -License: GPL/LGPL -Group: System Environment/Base -ExclusiveOS: Linux - -Source0: http://people.redhat.com/~dhowells/keyutils/keyutils-%{version}.tar.bz2 - -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot - -%description -Utilities to control the kernel key management facility and to provide -a mechanism by which the kernel call back to userspace to get a key -instantiated. - -%package devel -Summary: Development package for building linux key management utilities -Group: System Environment/Base - -%description devel -This package provides headers and libraries for building key utilities. - -%prep -%setup -q - -%build -make LIBDIR=%{_libdir} - -%install -rm -rf $RPM_BUILD_ROOT -make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} install - -%clean -rm -rf $RPM_BUILD_ROOT - -%files -%defattr(-,root,root,-) -%doc README LICENCE.GPL LICENCE.LGPL -%{_libdir}/libkeyutil.so.%{version} -%{_libdir}/libkeyutil.so.%{vermajor} -/sbin/* -/bin/* -/usr/share/keyutils/* -%{_mandir}/* -%config(noreplace) /etc/* - -%files devel -%{_libdir}/libkeyutil.so -%{_includedir}/* - -%changelog -* Mon Jul 12 2005 David Howells <dhowells@redhat.com> - 0.1-1 -- Package creation. |